Calling math people!

Kntx

Platinum Member
Dec 11, 2000
2,270
0
71
I wish I could have a chat with my 17 year old self right now. He'd know how to do this...

So I have to implement an IRR (internal rate of return) calc for a system I'm working on. This is a sample problem I came up with from my stock portfolio :)

-3712/(1-r) + 256/(1-r)^2 + 286/(1-r)^3 + 298/(1-r)^4 + 6930/(1-r)^5 = 0

The gist is you want to find the discount rate at which the net present value of a cash flow from an investment is 0. The variable "r" is the discount rate we are looking for. So I sketch it all out and realize I have no clue how to solve for r, doh!

So... who loves math?



 

drebo

Diamond Member
Feb 24, 2006
7,034
1
81
There's an accounting trick to solve for IRR, but I'll be damned if I remember how to do it.
 

Kntx

Platinum Member
Dec 11, 2000
2,270
0
71
Anyway, I have it mostly figured out.

The real equation is

?cash_flow<i>/(1+rate)^t<i> = 0

Which you can rewrite as...

?cash_flow<i>(1+rate)^-t<i> = 0

Cash flow is known, the rate is unknown. A a root finding method can be used to determine the rate. Newton?s method seems to be the best candidate. May I say thank god for wikipedia.

edited to use angle brackets for my <i> becuase sqaure ones made things italic.
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0

Substitute x = 1-r into your equation, and then multiply both sides by x^5:

(-3712) x^4 + (256) x^3 + (286) x^2 + (248) x + 6930 = 0.

This is, of course, a simply polynomial that you can solve using the normal methods.

Throwing this into an online polynomial root finder shows that the two real solutaton to this
are approximately x~=-1.156 and x~=1.216, or r~=2.156 and r~=-0.216.