Leader

Wednesday 8 April 2015

Alternative function: Present value of lump sum

See also the time value of money for other related Matlab functions.

Download
pvLump.m

Introduction
The present value of a lump sum of cash is the value of cash available in the future, right now.

But why should the value of something be now compared to in the future? This is a core concept of what is known as the "time value of money", which basically states that money is worth more now than it is if received in the future. The reason for this is interest - if you have money now, you have the opportunity to earn interest on it. If you only get the money later, you miss this opportunity.

This concept also applies to cash flows, but is slightly more complex as the interest needs to be applied at multiple points in time - see npvFlow.m.

For example, for a lump sum, assuming a positive interest rate; £1000 in 2 years time is worth £1000 in 2 years, whereas £1000 now is worth £1000+2 years interest in 2 years time. But what is £1000 in 2 years time worth to us right now? This value is the present value (PV).

So, for a lump sum, the equation is a rearranged form of the future value (FV) compound interest equation (see fvLump.m). Intuitively, for compounding interest, the FV is the PV plus the interest from each time point:

FV = PV * (1+r)^n,

where r = interest rate and n = number of time periods.

This means to calculate the PV, the equation rearranges to:

PV = FV / (1+r)^n.

This is the equation we will implement in a simple Matlab function, pvLump.m.




Examples
Here's a couple of examples of questions this equation and function can help answer.

How much money do you need now to have earn £1000 in 4 years time with no additional saving? The annual interest rate is 2.5% 
PV = 1000 / (1+0.025)^4 = £905.95.

Code in Matlab: pvLump(1000, 0.025, 4)


Would you prefer to receive £4,000 now, or £10,000 in 5 years? The interest rate is a constant 8%.
The PV of £4000 now is £4000.
We need to work out the value right now (PV) of £10,000 in 5 years.
PV = 10000 / (1+0.08)^5
PV = £6809 now.

Code in Matlab: pvLump(10000, 0.08, 5)

In this case (with only 8% interest available), patience pays off. £10,000 in 5 years is worth the equivalent of £6809 right now, where as £4000 right now is only worth £4000.

We can confirm this by looking at it the other way around. If we calculate the future value of £4000 in 5 years at 8% using the compound interest equation:
FV = 4000 * (1+0.08)^5 = £5877. That's less than £10,000.
(and for completeness the PV of £5877 in 5 years = 5877 / (1+0.08)^5 = £4000).


Would you prefer to receive £9,000 now, or £11,000 in 38 months? The annual interest rate is 7.7%.
In this case, the reasoning is the same, but the time period is different is months rather than years. An annual interest rate of 0.077 (7.7%) is worth 0.077/12 per month. So the PV of £11,000 in 38 months is:
PV = 11000 / (1+0.08/12)^38 = £8546.
It's better to have the £9000 now.

Code in Matlab: pvLump(11000, 0.077/12, 38)


Code run-through
function pv = pvLump(lumpSum, rate, periods)

This function takes the value of the lump sum (lumpSum), the interest rate (rate), and the number of periods (periods) as inputs and returns its present value as an output (pv).

c=lumpSum;
t=periods;
r=rate;

The first part of the function simply copies the input in to new single letter variables. There's not much point in doing this - it's just to make the equation part simpler to read. Technically it's inefficient in the sense that it wastes memory, but our inputs are so small and the waste of memory so insignificant that it's really not worth worrying about!

pv = c/(1+r)^t;

The PV is then simply calculated as per the equation.

This function is nice and simple, we'll use it to build upon to upon when calculating the PV of cash flows in npvFlow.m.

2 comments:

wiz said...

thank you so much this code really helped me code my project

wiz said...

can i ask how do you do random iterations of the code

AdSense