Mortgage Comparison Calculator Formula

Understand the math behind the mortgage comparison calculator. Each variable explained with a worked example.

Formulas Used

Loan A Monthly Payment

payment_a = pmt_a

Loan B Monthly Payment

payment_b = pmt_b

Monthly Payment Difference

payment_diff = abs(pmt_a - pmt_b)

Loan A Total Interest

total_interest_a = pmt_a * na - loan_amount_a

Loan B Total Interest

total_interest_b = pmt_b * nb - loan_amount_b

Interest Savings (lower total)

interest_savings = abs((pmt_a * na - loan_amount_a) - (pmt_b * nb - loan_amount_b))

Variables

VariableDescriptionDefault
loan_amount_aLoan A Amount(USD)350000
rate_aLoan A Interest Rate(%)6.5
term_aLoan A Term(years)30
loan_amount_bLoan B Amount(USD)350000
rate_bLoan B Interest Rate(%)6
term_bLoan B Term(years)15
raDerived value= rate_a / 100 / 12calculated
naDerived value= term_a * 12calculated
pmt_aDerived value= ra > 0 ? loan_amount_a * ra * pow(1 + ra, na) / (pow(1 + ra, na) - 1) : loan_amount_a / nacalculated
rbDerived value= rate_b / 100 / 12calculated
nbDerived value= term_b * 12calculated
pmt_bDerived value= rb > 0 ? loan_amount_b * rb * pow(1 + rb, nb) / (pow(1 + rb, nb) - 1) : loan_amount_b / nbcalculated

How It Works

Comparing Mortgage Options

Comparing mortgages requires looking beyond the monthly payment to understand total cost over the loan life.

Key Comparison Factors

  • Monthly payment: Shorter terms have higher payments but lower total cost
  • Total interest: The true cost of borrowing over the full term
  • Opportunity cost: Lower payments free cash for other investments
  • Common Comparisons

  • 30-year vs 15-year fixed
  • Fixed rate vs ARM
  • Different lender offers
  • Buying points vs no points
  • Decision Framework

    Choose the lower payment if cash flow is tight or you can invest the difference at a return exceeding the rate savings. Choose the lower total cost if you plan to hold the loan to maturity.

    Worked Example

    Comparing a $350,000 loan at 6.5% for 30 years vs 6.0% for 15 years.

    loan_amount_a = 350000rate_a = 6.5term_a = 30loan_amount_b = 350000rate_b = 6term_b = 15
    1. 01Loan A (30yr at 6.5%): $2,212.24/month
    2. 02Loan B (15yr at 6.0%): $2,953.98/month
    3. 03Monthly difference: $2,953.98 - $2,212.24 = $741.74
    4. 04Loan A total interest: $2,212.24 x 360 - $350,000 = $446,406
    5. 05Loan B total interest: $2,953.98 x 180 - $350,000 = $181,716
    6. 06Interest savings with Loan B: $446,406 - $181,716 = $264,690

    Ready to run the numbers?

    Open Mortgage Comparison Calculator