solving payoff amount x in last period using a IRR using mysql

Posted on 2008-10-11
Last Modified: 2013-12-13
I want to pick an IRR=r (say 15%), and determine how much would have to be paid in the last period of the cash flow sequence to achieve this IRR.
using wikipedia e.g.
0      -100
1      40
2      59
3      55
4      x

Solving the summation equation for x
x = the amount that needs to be paid to reach an internal rate of return of 15%
r = .15
NPV = 0 = -100 + 40/(1+.15)^1 + 59/(1+.15)^2 + 55/(1+.15)^3 + x/(1+.15)^4 for x
0= -100 + 34.78261 + 44.61248 + 36.16339 + x/(1+.15)^4
0 = 15.5585 + x/(1+.15)^4
-15.5585 = x/1.749006
-15.5585*1.749006 = x
-27.2119 = x

(note: in this example the value of x is negative, but in most cases it will be positive)

please see for progress to date
Question by:derekstattin
  • 2
  • 2
LVL 24

Expert Comment

ID: 22696408
I think I understand the problem.

Assume that your data are stored in an array like this

$seq = array(0=>-100, 1=>40, 2=>59, 3=>55);
$period_to_solve = 4;
$rate = 0.15;

//First sum everything up
for ($x=0; $x<$period_to_solve; $x++)
$sum += $seq[$x] * pow($rate + 1, $x);

// NPV = {sum} + x/(1+rate)^4
//  -{sum} * (1+rate)^4 = x
$final_period = 0 - $sum * pow(1+$rate,$period_to_solve);

Author Comment

ID: 22696935
Thank you for the example.
It all seems to work except on little thing
The $sum should be equal to 15.5585. I ran another example using 30, 32, and 40, but the results in Excel are not the same as using the function above.
Thanks for the help,
LVL 24

Accepted Solution

mankowitz earned 500 total points
ID: 22698340
Sorry, my mistake. I think I misread the formula. Change

$sum += $seq[$x] * pow($rate + 1, $x);


$sum += $seq[$x] / pow($rate + 1, $x);

Author Comment

ID: 22698698
Great,  thanks so much. I should have noticed that. Now I will try to integrate this in with
I will post a couple more questions shortly.

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question