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
. 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
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.