Mortgage Affordability Calculator Formula

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

Formulas Used

Affordable Home Price

affordable_home_price = monthly_rate > 0 ? max_monthly_payment * (pow(1 + monthly_rate, num_payments) - 1) / (monthly_rate * pow(1 + monthly_rate, num_payments)) + down_payment : max_monthly_payment * num_payments + down_payment

Maximum Loan Amount

max_loan_amount = monthly_rate > 0 ? max_monthly_payment * (pow(1 + monthly_rate, num_payments) - 1) / (monthly_rate * pow(1 + monthly_rate, num_payments)) : max_monthly_payment * num_payments

Estimated Monthly Payment

estimated_monthly_payment = max_monthly_payment

Variables

VariableDescriptionDefault
annual_incomeAnnual Gross Income(USD)85000
monthly_debtsMonthly Debt Payments(USD)500
down_paymentDown Payment(USD)50000
annual_rateInterest Rate(%)6.5
loan_term_yearsLoan Term(years)30
monthly_incomeDerived value= annual_income / 12calculated
max_housing_paymentDerived value= monthly_income * 0.28calculated
max_total_paymentDerived value= monthly_income * 0.36 - monthly_debtscalculated
max_monthly_paymentDerived value= min(max_housing_payment, max_total_payment)calculated
monthly_rateDerived value= annual_rate / 12 / 100calculated
num_paymentsDerived value= loan_term_years * 12calculated

How It Works

How Mortgage Affordability Is Calculated

Lenders use the 28/36 rule to determine how much you can afford:

  • 28% Rule: Your monthly housing payment should not exceed 28% of gross monthly income
  • 36% Rule: Your total monthly debts (including housing) should not exceed 36% of gross monthly income
  • The calculator takes the lower of these two limits and works backward to find the maximum loan amount you qualify for.

    Worked Example

    You earn $85,000/year with $500/month in existing debts, $50,000 down payment, at 6.5% for 30 years.

    annual_income = 85000monthly_debts = 500down_payment = 50000annual_rate = 6.5loan_term_years = 30
    1. 01Monthly income: $85,000 / 12 = $7,083.33
    2. 0228% rule max housing payment: $7,083.33 * 0.28 = $1,983.33
    3. 0336% rule max total debts: $7,083.33 * 0.36 - $500 = $2,050.00
    4. 04Use lower value: $1,983.33
    5. 05Max loan amount at 6.5% for 30 years: $313,770
    6. 06Affordable home price: $313,770 + $50,000 = $363,770