Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.1

Request #8624 quickly execution
Submitted: 2006-09-03 18:53 UTC
From: b_j at tar dot hu Assigned: alejandrop
Status: Closed Package: Math_Finance (version 1.0.0)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2006-09-03 18:53 UTC] b_j at tar dot hu (Barczi J√≥zsef)
Description: ------------ Math/Finance.php presentValue: //$pv = (-$pmt * (1 + $rate * $type) * ((pow(1 + $rate, $nper) - 1) / $rate) - $fv) / pow(1 + $rate, $nper); $q=pow(1 + $rate, $nper); $pv = (-$pmt * (1 + $rate * $type) * (($q - 1) / $rate) - $fv) / $q; futureValue: //$fv = -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate; $q=pow(1 + $rate, $nper); $fv = -$pv * $q - $pmt * (1 + $rate * $type) * ($q - 1) / $rate; payment: //$pmt = (-$fv - $pv * pow(1 + $rate, $nper)) / (1 + $rate * $type) / ((pow(1 + $rate, $nper) - 1) / $rate); $q=pow(1 + $rate, $nper); //$pmt = (-$fv - $pv * $q) / (1 + $rate * $type) / (($q - 1) / $rate); $pmt = (-$fv - $pv * $q * $rate) / ((1 + $rate * $type) * ($q - 1)) ; _tvm: //return $pv * pow(1 + $rate, $nper) + $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate + $fv; $q=pow(1 + $rate, $nper); return $pv * $q + $pmt * (1 + $rate * $type) * ($q - 1) / $rate + $fv; _dtvm: /* return $nper * $pv * pow(1 + $rate, $nper - 1) + $pmt * ($type * (pow(1 + $rate, $nper) - 1) / $rate + (1 + $rate * $type) * ($nper * $rate * pow(1 + $rate, $nper - 1) - pow(1 + $rate, $nper) + 1) / pow($rate,2)); */ $q =pow(1 + $rate, $nper); $q1=pow(1 + $rate, $nper - 1); $q2=pow($rate,2); return $nper * $pv * $q1 + $pmt * ($type * ($q - 1) / $rate + (1 + $rate * $type) * ($nper * $rate * $q1 - $q + 1) / $q2);

Comments

 [2007-03-10 12:13 UTC] alejandrop (Alejandro Pedraza)
Fixed for next version. (you made a mistake in the last operation in the payment function by the way)