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

    Frequently Asked Questions

    Is a 15-year mortgage always better than 30-year?

    Not necessarily. A 15-year mortgage saves substantial interest but requires higher monthly payments. If the payment difference invested elsewhere earns more than the rate savings, the 30-year could be financially better. Also, the higher 15-year payment reduces cash flow flexibility.

    Should I compare based on monthly payment or total cost?

    Both matter. Monthly payment determines affordability and cash flow. Total cost measures the true price of the loan. For most homeowners, the right balance depends on their financial situation, investment options, and how long they plan to keep the loan.

    How do I compare loans with different amounts?

    When comparing loans of different amounts (e.g., with different down payments), look at total cost of homeownership: down payment + total interest + PMI costs. A larger down payment reduces the loan but ties up cash that could be invested.

    Ready to run the numbers?

    Open Mortgage Comparison Calculator