Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing Excel and VB's IRR function

I need to port the IRR function found in Excel and VB to ActionScript.

  • Excel IRR formula

Any idea how to find the "source" to such functions? does anyone have this implemented in some other c-like language?

like image 684
mmattax Avatar asked Feb 09 '09 21:02

mmattax


1 Answers

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.

like image 164
jason Avatar answered Oct 27 '22 01:10

jason