Reputation: 268
I am trying to compute the interest rate of mortgage in python .
I have below formula. a/{[(1+r)^n]-1}/[r(1+r)^n]=p
Here I have the value for a ,n , p.
is it possible to calculate r using these values in python. Any pointers will help.
Upvotes: 0
Views: 168
Reputation: 474
You can have a look at Sympy package which could help.
from sympy.solvers import solve
from sympy import Symbol
x = Symbol('x')
solve(x**2 - 1, x)
Replace x**2 - 1 by your equation with respect to r (shift p to the left side).
Upvotes: 0