Biomathematicus

Science, Technology, Engineering, Art, Mathematics

«Hi there. I have a buyer for your $500k house. We are willing to pay $600k. Please sell it to me :)»

Would you sell? What about $700k? How to compute the point of financial equilibrium? It is relatively easy, but you need to understand amortization and annuities.

Yet another reason why Algebra II is important in high school. Texas removed it as a requirement for school graduation in 2013. It is in Algebra II that students get exposed to compound interest and annuities. Without this knowledge, it is easy to fall prey of detrimental financial schemes, even if they sound naively appealing.

Let’s start by taking scammers out of the way. I frequently receive calls inquiring if I’m willing to sell my home for cash. It’s crucial to remember: If someone approaches you at your doorstep offering cash, they are not your friends. Their aim is to make a quick profit at your expense. Or they simply want your financial information. These scammers deserve no further attention.

However, some are offers from legitimate realtors representing genuine buyers. They come, exuding confidence, armed with information on comparable houses in the area to propose a “fair” price. They even will tell you “we are ready to pay above market value!

The average new home price in the United States was $505,700 in April 2024, according to the Bureau of the Census (image below). Let’s round a hypothetical house to a market value (Zillow?) of $500k for simplicity. Let’s assume there is a $400k mortgage. According to Freddie Mac, «about 90 percent of homebuyers chose the 30-year fixed-rate mortgage in 2016. Six percent of homebuyers chose 15-year fixed-rate loans, 2 percent chose adjustable-rate mortgages (ARMs), and 2 percent chose loans with other terms.» The Federal Reserve of St. Louis keeps nice data about 30-year mortgage rates. Let’s use early 2020 as a baseline, with an average rate of 3.5% for a 30-year mortgage.

For homeowners with mortgages, the asset isn’t just the home—it’s the home plus the mortgage. In this example, with values initially loaded in the fields below used for the computations, the mortgage increases the value of the home by $193,079.78, which is the interest paid on an existing mortgage versus the interest paid on a new mortgage of the same duration and size, taking into consideration the present value of the amortization tables. Now, add the cost of moving (let’s assume $15k) and renovations ($50k). Thus, your $500k home with a 3.5% 30-year mortgage of $400k should sell for $750k for you not to lose money given a current mortgage rate of 7.1%. This, of course, would create market distortion, which simply tells you that it is in your best financial interest to hold onto that mortgage and refinance every time interest rates go down. Of course, life happens; not every one can afford to stay put. But we are discussing here those who do not want to move and might find themselves pushed by potential buyers. Even better: If mortgage rates were stable, people would gain mobility and equity much more easily, but the only ones winning with volatile mortgage rates are the financial institutions.

But how do you compare these values? With a fixed-rate mortgage, all payments are equal but principal and interest vary. For simplicity (and with a little loss of precision), let’s assume that the total interest is paid at equal payments over the life of the loan. This, of course, is not how it happens (as one would learn in Algebra II), but it works as a baseline. Thus, the calculation reduced to the present value of an annuity considered as the total interest paid evenly split for the duration of the mortgage, gives a value that is roughly 10% below what you obtain by computing the exact present values of the amortization tables.

A detailed explanation of computations is below the comparison. The amortization tables are at the bottom. The most important thing is This: Add the value of Today’s Value of Cost of Selling the Mortgage (see below) to the market value of your home to get a fair price. Also, you might want to add the cost of moving and renovations. In many cases, it takes the house to a price that is not consistent with the market… but that simply tells you what you are losing by selling.

Below you can see a few random numbers generated for the exercise; feel free to replace them with your own figures to conduct a comparison. The content below and JavaScript program were generated by GPT-4. It took some effort to get the correct answers.

Current Mortgage

Replacement Mortgage

Simplified Calculation with Annuities

Exact Calculation with Present Value of Amortization

Understanding the Mortgage Comparison Tool

This tool is designed to calculate the difference in interest costs between an existing mortgage and a new mortgage of the same duration and size. It aids homeowners in determining a fair sale price by considering these costs. Below is a detailed explanation of how these calculations are performed:

Understanding the Components

  • Existing Mortgage: Your current home loan, which has an ongoing interest rate and a remaining duration until it is fully paid off.
  • New Mortgage: A hypothetical mortgage reflecting a potential scenario where you refinance or acquire a new loan for a similar amount and duration as your current mortgage but at a potentially different interest rate.

Calculation Steps

  1. Interest Paid on Existing Mortgage:
    • Principal: The original loan amount or the current outstanding balance.
    • Interest Rate: The annual interest rate of your existing mortgage.
    • Remaining Duration: The number of years left to pay on your existing mortgage.
    • The monthly payment is calculated using an annuity formula based on these inputs. The total interest paid over the remaining period is then derived from the sum of monthly payments minus the principal.
  2. Interest Paid on New Mortgage:
    • Uses the same principal as the existing mortgage for comparison purposes.
    • New Interest Rate: Typically reflects current market rates.
    • Same Duration: Ensures that the comparison between the two mortgages is fair and on equal terms.
    • Calculate the monthly payment and total interest using the annuity formula, similar to the existing mortgage.
  3. Comparison of Interest Costs:
    • The difference in interest between the existing and new mortgage is calculated. This difference reflects how much more or less you would pay if you switched to a new mortgage.
  4. Adjustment to Sale Price:
    • If the interest on the new mortgage is higher, the difference should be added to the sale price of your home to compensate for the increased costs you would incur with a new mortgage.

Additional Calculations for a More Precise Evaluation

  1. Simplified Calculation with Annuities:
    • This section divides the "Nominal Cost of Selling the Mortgage" by the number of months remaining and uses the annuity formula to compute "Today's Value of Cost of Selling the Mortgage." This gives a simplified view of the financial impact over time.
  2. Exact Calculation with Present Value of Amortization:
    • This advanced section calculates the present value of the difference in interest for each payment period from the amortization tables. Each difference is converted into its present value and summed up to provide an exact measure of the cost of selling the mortgage.

    To compute this, we evaluate the interest difference between the current and replacement mortgage at each payment interval. We then discount these differences back to their present value using the inflation rate as the discount factor, accumulating these to reflect the total financial impact more precisely.

Application in Real Scenarios

This tool is particularly useful in real estate markets where prices and interest rates fluctuate significantly. Homeowners can use this calculator to make informed decisions about selling their property and understanding the financial implications of their current and potential new mortgages. By adding the difference in interest payments to the sale price, homeowners can ensure they are compensated for any additional costs arising from new financing conditions.

This detailed calculation allows homeowners to approach potential sales and refinancing options with a clear understanding of their financial implications, ensuring they make decisions that are financially sound.

Here is the source code for the calculations:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mortgage Comparison Tool</title>
<script>
function formatCurrency(value) {
    return '$' + Number(value).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}

function calculateAmortization(principal, rate, years) {
    rate /= 100; // Correct the division by 100 for percentage
    let monthlyRate = rate / 12;
    let numberOfPayments = years * 12;
    let monthlyPayment = principal * monthlyRate / (1 - (Math.pow(1 + monthlyRate, -numberOfPayments)));
    let totalInterest = monthlyPayment * numberOfPayments - principal;
    return { monthlyPayment, totalInterest, principal, monthlyRate, numberOfPayments };
}

function updateValues() {
    let principal = parseFloat(document.getElementById('balance').value.replace(/[$,]/g, ''));
    let currentInterestRate = parseFloat(document.getElementById('currentInterestRate').value);
    let currentYears = parseFloat(document.getElementById('currentPeriod').value);
    let currentAmortization = calculateAmortization(principal, currentInterestRate, currentYears);
    document.getElementById('currentMonthlyPayment').value = formatCurrency(currentAmortization.monthlyPayment);
    document.getElementById('currentInterestPaid').value = formatCurrency(currentAmortization.totalInterest);

    let marketRate = parseFloat(document.getElementById('marketInterestRate').value);
    let replacementAmortization = calculateAmortization(principal, marketRate, currentYears);
    document.getElementById('replacementPeriod').value = currentYears;
    document.getElementById('replacementMonthlyPayment').value = formatCurrency(replacementAmortization.monthlyPayment);
    document.getElementById('replacementInterestPaid').value = formatCurrency(replacementAmortization.totalInterest);

    let nominalCost = replacementAmortization.totalInterest - currentAmortization.totalInterest;
    document.getElementById('nominalCost').value = formatCurrency(nominalCost);

    let inflationRate = parseFloat(document.getElementById('inflationRate').value) / 100;
    let months = currentYears * 12;
    let monthlyNominalCost = nominalCost / months;
    let presentValueAnnuity = monthlyNominalCost * ((1 - Math.pow(1 + inflationRate / 12, -months)) / (inflationRate / 12));
    document.getElementById('presentValue').value = formatCurrency(presentValueAnnuity);

    generateAmortizationTable('currentTable', currentAmortization, currentYears, principal, 'Current Mortgage');
    generateAmortizationTable('replacementTable', replacementAmortization, currentYears, principal, 'Replacement Mortgage');
    calculateExactPV(currentAmortization, replacementAmortization, inflationRate, months);
}

function generateAmortizationTable(id, amortization, years, initialPrincipal, title) {
    let table ='<h2>' + title + '</h2>' + `<table border="1" style="border-collapse: collapse; border-color: black;"><tr><th>Month</th><th>Total Paid</th><th>Interest Paid</th><th>Principal Paid</th><th>Remaining Balance</th></tr>`;
    let balance = initialPrincipal;
    let monthlyRate = amortization.monthlyRate;
    let monthlyPayment = amortization.monthlyPayment;
    for (let month = 1; month <= years * 12; month++) {
        let interest = balance * monthlyRate;
        let principalPaid = monthlyPayment - interest;
        balance -= principalPaid;
        if (balance < 0) {
            principalPaid += balance; // Adjust the last payment
            balance = 0;
        }
        table += `<tr><td>${month}</td><td>${formatCurrency(monthlyPayment)}</td><td>${formatCurrency(interest)}</td><td>${formatCurrency(principalPaid)}</td><td>${formatCurrency(balance)}</td></tr>`;
        if (balance === 0) break;
    }
    table += '</table>';
    document.getElementById(id).innerHTML = table;
}

function calculateExactPV(current, replacement, rate, periods) {
    let totalPV = 0;
    for (let month = 1; month <= periods; month++) {
        let currentInterest = current.principal * current.monthlyRate;
        let replacementInterest = replacement.principal * replacement.monthlyRate;
        let diffInterest = replacementInterest - currentInterest;
        let pv = diffInterest / Math.pow(1 + rate / 12, month);
        totalPV += pv;
        current.principal -= (current.monthlyPayment - currentInterest);
        replacement.principal -= (replacement.monthlyPayment - replacementInterest);
    }
    document.getElementById('exactPV').value = formatCurrency(totalPV);
}

window.onload = function() {
    document.getElementById('currentInterestRate').value = 3.5;
    document.getElementById('currentPeriod').value = 25;
    document.getElementById('marketInterestRate').value = 7.1;
    document.getElementById('inflationRate').value = 3;
    document.getElementById('balance').value = formatCurrency(400000);
    updateValues();
}
</script>
</head>
<body>
<table>
    <tr><td><h2>Current Mortgage</h2></td></tr>
    <tr><td><label>Interest Rate of Existing Mortgage (%): </label></td><td><input type="number" id="currentInterestRate" oninput="updateValues()" step="0.01"></td></tr>
    <tr><td><label>Period Left (years): </label></td><td><input type="number" id="currentPeriod" oninput="updateValues()" step="0.01"></td></tr>
    <tr><td><label>Balance: </label></td><td><input type="text" id="balance" oninput="updateValues()"></td></tr>
    <tr><td><label>Monthly Payment: </label></td><td><input type="text" id="currentMonthlyPayment" readonly></td></tr>
    <tr><td><label>Interest Paid: </label></td><td><input type="text" id="currentInterestPaid" readonly></td></tr>
    <tr><td><h2>Replacement Mortgage</h2></td></tr>
    <tr><td><label>Market Interest Rate of Comparable Loan (%): </label></td><td><input type="number" id="marketInterestRate" oninput="updateValues()" step="0.01"></td></tr>
    <tr><td><label>Period Left (years): </label></td><td><input type="text" id="replacementPeriod" readonly></td></tr>
    <tr><td><label>Monthly Payment: </label></td><td><input type="text" id="replacementMonthlyPayment" readonly></td></tr>
    <tr><td><label>Interest Paid: </label></td><td><input type="text" id="replacementInterestPaid" readonly></td></tr>
    <tr><td><h2>Simplified Calculation with Annuities</h2></td></tr>
    <tr><td><label>Assumed annual inflation rate (%): </label></td><td><input type="number" id="inflationRate" oninput="updateValues()" step="0.01"></td></tr>
    <tr><td><label>Nominal Cost of Selling the Mortgage: </label></td><td><input type="text" id="nominalCost" readonly></td></tr>
    <tr><td><label>Today's Value of Cost of Selling the Mortgage: </label></td><td><input type="text" id="presentValue" readonly></td></tr>
    <tr><td><h2>Exact Calculation with Present Value of Amortization</h2></td></tr>
    <tr><td><label>Today's Value of Cost of Selling the Mortgage (Exact): </label></td><td><input type="text" id="exactPV" readonly></td></tr>
</table>
<div id="currentTable"></div>
<div id="replacementTable"></div>
</body>
</html>