Internal rate of return calculation with a growing perpetuity

230 Views Asked by At

I'm pretty new in coding and I'm trying to learn it for application in finance.

I should to find the r variable in this equation that I'm sharing. Can someone help me?

enter image description here

Basically I have one cashflow that I invest now with a negative sign in front of it, and a sequence of positive cashflow that I'll receive in n years in future. I have to discount to the present each cashflow with r as a variable, and the total sum between this negative cashflow in year 0 and the others in year 1, 2, 3 etc discounted at the year 0 has to bring 0. Plus, the last positive cashflow, I assume that grows forever at a certain growth rate.

I use this code (second image) to tell the computer to find me the r variable, but I don't know hot to write the last cashflow growing forever.

Can someone help me?

enter image description here

1

There are 1 best solutions below

0
On

You will probably obtain the most expressive calculation using sympys solve().

import sympy as smp

r = smp.symbols('r', Real=True)

eq = 123.43 / (1 + r) + 137.67 / (1 + r) ** 2 + 153.54 / (1 + r) ** 3 \
    + 171.21 / (1 + r) ** 4 + 190.88 / (1 + r) ** 5 + 190.88 * 1.0093 \
    / (r - 0.0093) * (1 + r) ** 5 - 3756.07

answer = smp.solve(eq, r)

print(answer)