CodeCogs - An iteractive open source Numerical library Welcome... Login
CodeCogs
shopping cart
OSXWindowsLinux
Search CodeCogs
Numerical Components

Valid RSS

FinanceAccounting

xnpv

Only available under a commercial licence
COST (GBP)
this unit 4.68
sub units 0.00
add a commercial licence to your cart
0
viewed 1944 times and licensed 1 times

Calculate net present value for a series of non-periodic cash flows. Excel: XNPV

Controller: CodeCogs  Contact Controller
+View version details
Contents hide toc
buy now     add cart

Interface

#include <codecogs/finance/accounting/xnpv.h>

using namespace Finance::Accounting;

double xnpv (double rate, double values[], int dates[], int nV)
Calculate net present value for a series of non-periodic cash flows. Excel: XNPV

Function Documentation

Xnpv Calculator
  
Add calculator to website or email
 
doublexnpvdoublerate
double*values
int*dates
intnV )
Calculate the net present value for a schedule of cash flows which are not necessarily periodic. values contains the series of cash flows made on the specific dates. Values which are a cost, (or paymemt) should be entered as negative values.

The following equation is used:

XNPV\ =\ \sum_{a=0}^{N-1}\ \frac{P_a}     {(1.0+rate)^{\frac{(d_a-d_0)}{365.0}}}

Where: Pa is the payment at point a . d0 is the date of the first payment.
Example 1:
Consider an investment that requires a £10,000 cash payment on January 1, 1998, and returns: £2,750 on March 1, 1998; £4,250 on October 30, 1998; £3,250 on February 15, 1999; and £2,750 on April 1, 1999. Assume that the cash flows are discounted at 9 percent. The net present value is:
#include <iostream>
#include <codecogs/finance/accounting/xnpv.h>
 
int main(int argc, char *argv[])
{
  double pmts[]={-10000, 2750, 4250, 3250, 2750};
  int dates[]={34334,34393,34636,34744,34789};
 
  std::cout<<"Net present value: ";
  std::cout<<Finance::Accounting::xnpv(0.09, pmts, dates, 5);
  std::cout<<std::endl;
 
  return 0;
}
Output:
Net present value: 2089.5

use a rate of 0.09 .

payments on specific dates.

are made.

Parameters:
rateThe discount rate to apply to the cash flows. For 9%
valuesAn array of cash flows that correspond to a series of
datesAn array of dates on which the corresponding payments
Returns:
The net present value of the investment.
Authors:
James Warren (July 2005)
Source Code:

To view or download source code you need to buy a Commercial licence.

buy now     add cart

Not a member, then Register with CodeCogs. Already a Member, then Login.


Page Comments

Format Excel Equations

  You must login to leave a messge


Last Modified: 18 Oct 07 @ 17:07     Page Rendered: 2010-03-10 17:34:16

Valid CSS!   Valid XHTML 1.0 Transitional