Inspectable Arithmetic for the Pay Off Mortgage vs Invest Calculator (Cash-Flow Neutral)
Version 1.2
Last verified: May 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 mortgage paydown versus investing under explicit rules. The user chooses one of two mutually exclusive ways to supply discretionary cash in addition to the regular mortgage payment P:
- Monthly extra cash: a fixed extra amount E every month. While a mortgage exists, P + E is split between the mortgage (scheduled payment plus allocated extra paydown) and the portfolio. After payoff, the full monthly budget P + E is invested each month.
- Lump sum at start: a one-time amount S applied at the beginning of month 1 only (before that month’s mortgage interest and scheduled payment). There is no recurring E in this mode. The same allocation slider splits S between extra principal and the portfolio. After payoff, only P is invested each month (because there was no recurring extra in this mode).
The calculator reports mortgage balance, investment portfolio value, and net worth over time under constant return assumptions.
For the narrative framing behind the cash-flow-neutral comparison, see Pay Off Your Mortgage Faster or Invest?
Definitions
All accruals below are monthly time steps unless noted.
Inputs
- B0: initial mortgage balance
- P: regular mortgage payment per month
- Mode (exclusive): either monthly extra cash (inputs E and optional monthly budget tied to P) or lump sum (input S ≥ 0). The engine sets E = 0 in lump mode regardless of other fields.
- E: extra cash available per month (monthly mode only; E = 0 in lump mode)
- S: lump sum at start of month 1 (lump mode only; S = 0 in monthly mode)
- a: allocation slider (0–100), interpreted as % of the relevant discretionary cash allocated to investing (right end of slider). The remainder goes to extra mortgage principal.
- Recurring extra to mortgage: EM = (1 − a/100) E
- Recurring extra to invest: EI = (a/100) E
- r: Canadian nominal annual mortgage rate, compounded semi-annually (%)
- R: expected investment return before fees (annual, %)
- f: investment fees (annual, %)
- g: home price growth rate (annual, %)
- H0: current home value
- T: time horizon in years
- N = 12T: time horizon in months
Derived constants
Mortgage monthly rate:
i = (1 + (r/100) / 2)1/6 − 1
Canadian mortgage rates are generally quoted as nominal annual rates compounded semi-annually. The calculator converts the entered mortgage rate to an equivalent monthly rate before applying mortgage interest.
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 used after the mortgage is paid off (same symbol in both modes):
Budget = P + E
In lump mode, E = 0, so Budget = P. In monthly mode, Budget = P + E.
Mode A: Mortgage Payment Computed From Mortgage Inputs
If Use mortgage calculator is enabled (the mode that reuses payment logic from the Canada Mortgage Calculator), the calculator computes the regular mortgage payment P using the standard amortization formula.
Let:
- L = H0 − DownPayment
- i = (1 + (r/100) / 2)1/6 − 1
- n = 12 · AmortYears
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 (Canadian nominal annual mortgage rate), 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% Canadian nominal annual mortgage rate). 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. State at the end of month t is written Bt, Vt; month 0 records initial B0, V0 = 0.
Lump-sum pre-step (only month t = 1, only if S > 0)
If lump mode is active and S > 0, the engine applies the following before interest due and the scheduled payment for that month. Let B− denote the mortgage balance at the start of the iteration (for t = 1, this is B0), and V− the portfolio at the start of the iteration (for t = 1, this is V0 = 0).
Split the lump using the same slider a as for recurring extra:
SM = (1 − a/100) S (portion intended for mortgage principal)
SI = (a/100) S (portion intended for investing)
Extra principal from the lump cannot exceed the outstanding balance. Any mortgage-intended amount beyond what is needed to prepay the balance is redirected to the portfolio:
LumpPrincipal = min(max(0, SM), B−)
Overflow = SM − LumpPrincipal
Update balance and portfolio before the rest of the month:
B′ = max(0, B− − LumpPrincipal)
V′ = V− + SI + Overflow
For t = 1, the simulation then continues using B′ and V′ as the starting balance and portfolio for that same month’s interest, mortgage payment, contributions, and compounding (below). For t > 1, this pre-step is skipped (S is not applied again).
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 at Start of Month t After Any Lump Pre-step
For t = 1, “Bt−1” in the interest formula below is the balance after the lump pre-step when S > 0 (i.e. B′ above); for t > 1 it is the prior month’s ending balance. The same applies to V when composing contributions.
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. For t = 1 with S > 0, Vt−1 is the portfolio already increased by the lump pre-step (SI + Overflow).
Case 2: Mortgage Paid Off (Bt−1 ≤ 0)
Once the mortgage balance reaches zero (including after the lump pre-step), the engine invests the entire monthly budget:
Ct = Budget = P + E
In lump mode, E = 0, so each post-payoff contribution is Ct = P.
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:
- Mortgage balance: BN
- Investment portfolio value: VN
- Home value: HN = H0(1 + g/100)T
- Net worth: max(0, HN − BN) + VN
- Total interest paid: Σ InterestDuet over months where a mortgage payment is made
- Total interest earned: Σ InterestEarnedt
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). In monthly mode, that means all of E to mortgage versus all of E to investing. In lump mode, that means all of S to extra principal versus all of S to the portfolio at the start of month 1. The same recurrence (including the lump pre-step when applicable) is used.
Break-even gross return
The calculator may report a gross return R (before fees) at which the two extreme strategies tie at the horizon: a = 0 versus a = 100, holding all other inputs fixed. In monthly mode, both paths use the same E. In lump mode, both paths use the same S and E = 0. If there is no discretionary cash (E = 0 and S = 0), this quantity is not defined.
Assumptions
- All calculations are performed in monthly time steps.
- The entered mortgage rate is treated as a Canadian nominal annual mortgage rate compounded semi-annually, then converted to the equivalent monthly rate before interest is applied to the outstanding balance.
- Investment returns are modeled as constant and deterministic.
- Investment fees are modeled as a constant annual % subtracted from expected return, then converted to a monthly geometric return.
- Contributions are applied before investment growth each month (beginning-of-period contributions).
- In lump-sum mode, S is applied only once, at the beginning of month 1, before that month’s mortgage interest and scheduled payment; it is not repeated in later months.
- Home price growth is modeled as constant compounding at rate g (no volatility).
- Taxes, transaction costs, refinancing, prepayment penalties, and behavioral changes are not modeled unless explicitly added elsewhere.
Implementation Notes
- The slider allocates discretionary cash only: recurring (E) in monthly mode, or the lump (S) in lump mode. The regular payment P always goes to the mortgage until payoff.
- Monthly and lump inputs are mutually exclusive in the UI; the engine does not apply both E and S in the same run.
- The mortgage recurrence uses i = (1 + (r/100) / 2)1/6 − 1 for monthly mortgage interest, not simple APR/12 division.
- In the payoff month, any portion of the intended mortgage payment not required to close the mortgage is automatically redirected into investing (“remainderFromMortgage”).
- After payoff, the engine invests Budget = P + E each month (so P only when E = 0).
- Projected payoff month search uses the same lump pre-step on month 1 when S > 0, then the same monthly mortgage recurrence with EM from recurring E only.
Sources and References
If any discrepancy is identified between this documentation and the calculator output, the arithmetic in the engine governs.