According to this function temporal is just a count down starting at one to the number of cash flows.
Also produces 12.01
So on that logic. Smaller data.
$investment = 100000;
$flow = array(10000, 20000, 30000, 40000, 50000);
function irr ($investment, $flow) {
for ($n = 0; $n < 100; $n += 0.0001) {
$pv = 0;
for ($i = 0; $i < count($flow); $i++) {
$pv = $pv + $flow[$i] / pow(1 + $n, $i + 1);
}
if ($pv <= $investment) {
return round($n * 10000) / 100;
}
}
}
var_dump(irr($investment, $flow));
The definition here: http://www.rentalsoftware.com/internal_rate_of_return.htm the example given
an investmet of $50 with a return of $10 = $60 resulting in an IRR of 20% (20.01)
$investment = 50;
$flow = array(60);
# Output 20.01
So I assume this IRR function is working.