Inspectable Arithmetic for the Pay Off Mortgage vs Invest Calculator (Cash-Flow Neutral)

Version 1.0
Last updated: February 2026

Transparent arithmetic is the operating system of this calculator.

This document publishes the full formulae, computational structure, and assumptions used to generate the outputs displayed on the calculator page.

No opinions. No hidden assumptions. Just arithmetic.

Purpose

This calculator compares two strategies under a cash-flow-neutral rule: A fixed monthly cash budget is assumed. While a mortgage exists, cash is allocated between: mortgage payments (regular payment + optional extra paydown), and investment contributions. After the mortgage is paid off, the entire monthly budget is invested. The calculator reports mortgage balance, investment portfolio value, and net worth over time under constant return assumptions.

Definitions

All quantities below are monthly.

Inputs

Derived constants

Mortgage monthly rate:

i = r / (100 · 12)

Net annual investment return (after fees):

Rnet = (R − f) / 100

Monthly geometric investment return:

μ = (1 + Rnet)1/12 − 1

(Clamped internally so that Rnet ≥ −0.999.)

Monthly budget (cash-flow neutral):

Budget = P + E

Mode A: Mortgage Payment Computed From Mortgage Inputs

If “Use mortgage calculator” is enabled, the calculator computes the regular mortgage payment P using the standard amortization formula.

Let:

Then:

P = L/n if r = 0
P = L · i / (1 − (1+i)−n) if r > 0

The simulation then proceeds using B0 = L and that computed P.

Mode B: Mortgage Payment Entered Manually

If “Use mortgage calculator” is disabled, the user supplies: B0 (current mortgage balance), r (APR), P (monthly payment). The payoff time becomes whatever amortizes under those values.

Fallback: If B0 ≤ 0 in manual mode, the engine estimates a principal from payment using a rough default (25 years, 5% APR). This is a non-ideal fallback intended to keep the calculator functioning.

Core Simulation (Monthly Recurrence)

The simulation advances month-by-month for t = 1, 2, …, N.

Home value

Home value is compounded in monthly steps:

Ht = H0 · (1 + g/100)t/12

Equity and net worth (end of month)

Equityt = max(0, Ht − Bt)
NetWortht = Equityt + Vt

where Vt is investment portfolio value.

Case 1: Mortgage Still Outstanding (Bt−1 > 0)

Step 1 — Mortgage interest due

InterestDuet = Bt−1 · i

Step 2 — Intended mortgage payment

Regular payment always goes to the mortgage, plus the allocated portion of extra cash:

Mtintended = P + EM

But payment cannot exceed what is needed to close the mortgage this month:

Mtactual = min(Mtintended, Bt−1 + InterestDuet)

Step 3 — Principal paid and new balance

PrincipalPaidt = max(0, Mtactual − InterestDuet)
Bt = max(0, Bt−1 − PrincipalPaidt)

If Mtactual > 0, interest paid increments by InterestDuet.

Step 4 — Investment contribution while mortgage exists

The investment contribution has two parts: the allocated investing portion of extra cash EI, and any remainder from an over-large intended mortgage payment in the final payoff month:

Remaindert = Mtintended − Mtactual
Ct = EI + Remaindert

Step 5 — Investment update (contribution first, then compound)

Vt′ = Vt−1 + Ct
InterestEarnedt = Vt′ · μ
Vt = Vt′ · (1 + μ)

Investment value is clamped to never go below zero.

Case 2: Mortgage Paid Off (Bt−1 ≤ 0)

Once the mortgage balance reaches zero, the engine invests the entire monthly budget:

Ct = Budget = P + E

Then applies the same “contribution first, then compound” update:

Vt′ = Vt−1 + Ct
InterestEarnedt = Vt′ · μ
Vt = Vt′ · (1 + μ)

Reported Outputs

At the end of the horizon t = N, the calculator reports:

Key facts (extreme allocations)

The “Key facts” section computes two additional full simulations using identical inputs: 100% mortgage allocation (a = 0) and 100% investing allocation (a = 100). Those outputs are produced by the same simulation logic above.

Assumptions

  1. All calculations are performed in monthly time steps.
  2. Mortgage interest is modeled as APR/12 applied to the outstanding balance each month.
  3. Investment returns are modeled as constant and deterministic.
  4. Investment fees are modeled as a constant annual % subtracted from expected return, then converted to a monthly geometric return.
  5. Contributions are applied before investment growth each month (beginning-of-period contributions).
  6. Home price growth is modeled as constant compounding at rate g (no volatility).
  7. Taxes, transaction costs, refinancing, prepayment penalties, and behavioral changes are not modeled unless explicitly added elsewhere.

Implementation Notes

If any discrepancy is identified between this documentation and the calculator output, the arithmetic in the engine governs.