user1047873
user1047873

Reputation: 268

Calculate interest rate of mortgage payment in python

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

Answers (1)

aurelien_morel
aurelien_morel

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

Related Questions