Getting strange result including $i$ while calculating extended period of mortgage.

45 Views Asked by At

I'm trying to solve a problem about how long a mortgage needs to be extended if the monthly payments are to remain the same and interest rate increases, the code is shown below. However I notice that when the difference between my annual $r$ and $r_1$ is larger than about $0.02$, I keep getting a strange number including $i$. For example when my $r=0.05$ and $r_1=0.08$, I got enter image description here. I don't know what this result means.

But when my $r=0.05$ and $r_1=0.07$, it works fine and I can get the result of $756$ months. Why would that happen? Then what should my answer be when I have $r$ increasing from $0.05$ to $0.08$?

clear;
P = 1000000;
r = 0.05/12;
n = 12*30;
A = ((r*(1+r)^n)*P)/((1+r)^n-1);
r1 = 0.08/12;
n1 = 12*25;
P1 = (A/r)*(1-1/(1+r)^n1);
A1 = ((r1*(1+r1)^n1)*P1)/((1+r1)^n1-1);
syms n
vpa(solve(A==((r1*(1+r1)^n)*P1)/((1+r1)^n-1),n))-n1
2

There are 2 best solutions below

0
On BEST ANSWER

You've encountered complex numbers. I suspect what it means is that the equation you're trying to solve has no real solution, so your solver is giving you a complex solution.

If the monthly payment is not enough to cover the interest on the principal, you won't be able to extend the mortgage amortization.

0
On

Just a few comments.

If I am not mistaken, your calculations seem to be unaccurate. You are looking for the zero of function

$$F(r_1,n)=P_1\frac{r_1 (1+r_1)^n}{(1+r_1)^n-1}-(A+n_1)$$ which has an explicit solution.

Let $Z=(1+r_1)^n$ $$\frac Z{Z-1}=\frac{A+n_1 } {P_1\,r_1 }=k\implies Z=\frac k{k-1}\implies n=\frac{\log \left(\frac{k}{k-1}\right)}{\log (1+r_1)}$$ that is to say $$\color{blue}{n=\frac{1 }{\log (1+r_1)}~\log \left(\frac{A+n_1}{A+n_1-P_1\, r_1}\right)}$$ which shows the problem when $A+n_1\leq P_1\, r_1$

I give you below the numbers I obtained for various values of $r_1$ $$\left( \begin{array}{cc} r_1 & n \\ 0.0700 & 498.781\\ 0.0705 & 517.623\\ 0.0710 & 539.558\\ 0.0715 & 565.708\\ 0.0720 & 597.941\\ 0.0725 & 639.699\\ 0.0730 & 698.493\\ 0.0735 & 796.738\\ 0.0740 & 1130.18\\ \end{array} \right)$$

For $r_1>0.07407$, there is no more real solution.

Notice that $$F(0.07,756)=-244.767 \qquad \text{while} \qquad F(0.07,499)=-0.420$$