I need to port the IRR function found in Excel and VB to ActionScript.
Any idea how to find the "source" to such functions? does anyone have this implemented in some other c-like language?
This is fairly easy to code using an iterative solver such as the bisection method or Newton's method. If your cash flows C_t_j
occur at times t_j
then the internal rate of return r
satisfies sum j = 1
to n
of
C_t_j / (1 + r)^t_j
equals zero. Call this f(r)
. Then f'(r)
is sum j = 1
to n
of
-t_j * C_t_j / (1 + r)^(t_j+1).
Now you can apply Newton's method to solve for r
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With