JMSLTM Numerical Library 7.2.0
com.imsl.finance

## Class Finance

• ```public class Finance
extends Object```
Collection of finance functions.
• ### Field Summary

Fields
Modifier and Type Field and Description
`static int` `AT_BEGINNING_OF_PERIOD`
Flag used to indicate that payment is made at the beginning of each period.
`static int` `AT_END_OF_PERIOD`
Flag used to indicate that payment is made at the end of each period.
• ### Method Summary

Methods
Modifier and Type Method and Description
`static double` ```cumipmt(double rate, int nper, double pv, int start, int end, int when)```
Returns the cumulative interest paid between two periods.
`static double` ```cumprinc(double rate, int nper, double pv, int start, int end, int when)```
Returns the cumulative principal paid between two periods.
`static double` ```db(double cost, double salvage, int life, int period, int month)```
Returns the depreciation of an asset using the fixed-declining balance method.
`static double` ```ddb(double cost, double salvage, int life, int period, double factor)```
Returns the depreciation of an asset using the double-declining balance method.
`static double` ```dollarde(double fractionalDollar, int fraction)```
Converts a fractional price to a decimal price.
`static double` ```dollarfr(double decimalDollar, int fraction)```
Converts a decimal price to a fractional price.
`static double` ```effect(double nominalRate, int nper)```
Returns the effective annual interest rate.
`static double` ```fv(double rate, int nper, double pmt, double pv, int when)```
Returns the future value of an investment.
`static double` ```fvschedule(double principal, double[] schedule)```
Returns the future value of an initial principal taking into consideration a schedule of compound interest rates.
`static double` ```ipmt(double rate, int period, int nper, double pv, double fv, int when)```
Returns the interest payment for an investment for a given period.
`static double` `irr(double[] pmt)`
Returns the internal rate of return for a schedule of cash flows.
`static double` ```irr(double[] pmt, double guess)```
Returns the internal rate of return for a schedule of cash flows.
`static double` ```mirr(double[] value, double financeRate, double reinvestRate)```
Returns the modified internal rate of return for a schedule of periodic cash flows.
`static double` ```nominal(double effectiveRate, int nper)```
Returns the nominal annual interest rate.
`static double` ```nper(double rate, double pmt, double pv, double fv, int when)```
Returns the number of periods for an investment for which periodic, and constant payments are made and the interest rate is constant.
`static double` ```npv(double rate, double[] value)```
Returns the net present value of a stream of equal periodic cash flows, which are subject to a given discount rate.
`static double` ```pmt(double rate, int nper, double pv, double fv, int when)```
Returns the periodic payment for an investment.
`static double` ```ppmt(double rate, int period, int nper, double pv, double fv, int when)```
Returns the payment on the principal for a specified period.
`static double` ```pv(double rate, int nper, double pmt, double fv, int when)```
Returns the net present value of a stream of equal periodic cash flows, which are subject to a given discount rate.
`static double` ```rate(int nper, double pmt, double pv, double fv, int when)```
Returns the interest rate per period of an annuity.
`static double` ```rate(int nper, double pmt, double pv, double fv, int when, double guess)```
Returns the interest rate per period of an annuity with an initial guess.
`static double` ```sln(double cost, double salvage, int life)```
Returns the depreciation of an asset using the straight line method.
`static double` ```syd(double cost, double salvage, int life, int per)```
Returns the depreciation of an asset using the sum-of-years digits method.
`static double` ```vdb(double cost, double salvage, int life, int start, int end, double factor, boolean no_sl)```
Returns the depreciation of an asset for any given period using the variable-declining balance method.
`static double` ```xirr(double[] pmt, Date[] dates)```
Returns the internal rate of return for a schedule of cash flows.
`static double` ```xirr(double[] pmt, Date[] dates, double guess)```
Returns the internal rate of return for a schedule of cash flows with a user supplied initial guess.
`static double` ```xnpv(double rate, double[] value, Date[] dates)```
Returns the present value for a schedule of cash flows.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### AT_BEGINNING_OF_PERIOD

`public static final int AT_BEGINNING_OF_PERIOD`
Flag used to indicate that payment is made at the beginning of each period.
Constant Field Values
• #### AT_END_OF_PERIOD

`public static final int AT_END_OF_PERIOD`
Flag used to indicate that payment is made at the end of each period.
Constant Field Values
• ### Method Detail

• #### cumipmt

```public static double cumipmt(double rate,
int nper,
double pv,
int start,
int end,
int when)```
Returns the cumulative interest paid between two periods. It is computed using the following:

where is computed from `ipmt` for the th period.
Parameters:
`rate` - a `double`, the interest rate
`nper` - an `int`, the total number of payment periods
`pv` - a `double`, the present value
`start` - an `int`, the first period in the caclulation. Periods are numbered starting with one.
`end` - an `int`, the last period in the calculation
`when` - an `int`, the time in each period when the payment is made, either `AT_END_OF_PERIOD` or `AT_BEGINNING_OF_PERIOD`
Returns:
a `double`, the cumulative interest paid between the first period and the last period
Example
• #### cumprinc

```public static double cumprinc(double rate,
int nper,
double pv,
int start,
int end,
int when)```
Returns the cumulative principal paid between two periods. It is computed using the following:

where is computed from `ppmt` for the th period.
Parameters:
`rate` - a `double`, the interest rate
`nper` - an `int`, the total number of payment periods
`pv` - a `double`, the present value
`start` - an `int`, the first period in the calculation. Periods are numbered starting with one.
`end` - an `int`, the last period in the calculation
`when` - an `int`, the time in each period when the payment is made, either `AT_END_OF_PERIOD` or `AT_BEGINNING_OF_PERIOD`.
Returns:
a `double`, the cumulative principal paid between the first period and the last period
Example
• #### db

```public static double db(double cost,
double salvage,
int life,
int period,
int month)```
Returns the depreciation of an asset using the fixed-declining balance method. Method `db` varies depending on the specified value for the argument period, see table below.

If period = 1,

If period = life,

If period other than 1 or life,

where

NOTE: is rounded to three decimal places.

Parameters:
`cost` - a `double`, the initial cost of the asset
`salvage` - a `double`, the salvage value of the asset
`life` - an `int`, the number of periods over which the asset is being depreciated
`period` - an `int`, the period for which the depreciation is to be computed
`month` - an `int`, the number of months in the first year
Returns:
a `double`, the depreciation of an asset for a specified period using the fixed-declining balance method
Example
• #### ddb

```public static double ddb(double cost,
double salvage,
int life,
int period,
double factor)```
Returns the depreciation of an asset using the double-declining balance method. It is computed using the following:

Parameters:
`cost` - a `double`, the initial cost of the asset
`salvage` - a `double`, the salvage value of the asset
`life` - an `int`, the number of periods over which the asset is being depreciated
`period` - an `int`, the period
`factor` - a `double`, the rate at which the balance declines
Returns:
a `double`, the depreciation of an asset for a specified period
Example
• #### dollarde

```public static double dollarde(double fractionalDollar,
int fraction)```
Converts a fractional price to a decimal price. It is computed using the following:

where is the integer part of , and is the integer part of .

Parameters:
`fractionalDollar` - a `double`, a fractional number
`fraction` - an `int`, the denominator
Returns:
a `double`, the dollar price expressed as a decimal number
Example
• #### dollarfr

```public static double dollarfr(double decimalDollar,
int fraction)```
Converts a decimal price to a fractional price. It is computed using the following:

where is the integer part of the , and is the integer part of .
Parameters:
`decimalDollar` - a `double`, a decimal number
`fraction` - an `int`, the denominator
Returns:
a `double`, a dollar price expressed as a fraction
Example
• #### effect

```public static double effect(double nominalRate,
int nper)```
Returns the effective annual interest rate. The nominal interest rate is the periodically-compounded interest rate as stated on the face of a security. The effective annual interest rate is computed using the following:

Parameters:
`nominalRate` - a `double`, the nominal interest rate
`nper` - an `int`, the number of compounding periods per year
Returns:
a `double`, the effective annual interest rate
Example
• #### fv

```public static double fv(double rate,
int nper,
double pmt,
double pv,
int when)```
Returns the future value of an investment. The future value is the value, at some time in the future, of a current amount and a stream of payments. It can be found by solving the following:

If ,

If ,

Parameters:
`rate` - a `double`, the interest rate
`nper` - an `int`, the total number of payment periods
`pmt` - a `double`, the payment made in each period
`pv` - a `double`, the present value
`when` - an `int`, the time in each period when the payment is made, either `AT_END_OF_PERIOD` or `AT_BEGINNING_OF_PERIOD`
Returns:
a `double`, the future value of an investment
Example
• #### fvschedule

```public static double fvschedule(double principal,
double[] schedule)```
Returns the future value of an initial principal taking into consideration a schedule of compound interest rates. It is computed using the following:

where interest rate at the th period, and the count is `schedule.length`.
Parameters:
`principal` - a `double`, the present value
`schedule` - a `double` array of interest rates to apply
Returns:
a `double`, the future value of an initial principal
Example
• #### ipmt

```public static double ipmt(double rate,
int period,
int nper,
double pv,
double fv,
int when)```
Returns the interest payment for an investment for a given period. It is computed using the following:

Parameters:
`rate` - a `double`, the interest rate
`period` - an `int`, the payment period
`nper` - an `int`, the total number of periods
`pv` - a `double`, the present value
`fv` - a `double`, the future value
`when` - an `int`, the time in each period when the payment is made, either `AT_END_OF_PERIOD` or `AT_BEGINNING_OF_PERIOD`
Returns:
a `double`, the interest payment for a given period for an investment
Example
• #### irr

`public static double irr(double[] pmt)`
Returns the internal rate of return for a schedule of cash flows. It is found by solving the following:

where = the cash flow, is the internal rate of return, and count is `pmt.length`.
Parameters:
`pmt` - a `double` array which contains cash flow values which occur at regular intervals
Returns:
a `double`, the internal rate of return
Example
• #### irr

```public static double irr(double[] pmt,
double guess)```
Returns the internal rate of return for a schedule of cash flows. It is found by solving the following:

where = the cash flow, is the internal rate of return.
Parameters:
`pmt` - a `double` array which contains cash flow values which occur at regular intervals
`guess` - a `double` value which represents an initial guess at the return value from this function
Returns:
a `double`, the internal rate of return
• #### mirr

```public static double mirr(double[] value,
double financeRate,
double reinvestRate)```
Returns the modified internal rate of return for a schedule of periodic cash flows. The modified internal rate of return differs from the ordinary internal rate of return in assuming that the cash flows are reinvested at the cost of capital, not at the internal rate of return. It also eliminates the multiple rates of return problem. It is computed using the following:

where is calculated from `npv` for positive values in `value` using `reinvestRate`, is calculated from `npv` for negative values in `value` using `financeRate`, and `nper` = `value.length`.
Parameters:
`value` - a `double` array of cash flows
`financeRate` - a `double`, the interest you pay on the money you borrow
`reinvestRate` - a `double`, the interest rate you receive on the cash flows
Returns:
a `double`, the modified internal rate of return
Example
• #### nominal

```public static double nominal(double effectiveRate,
int nper)```
Returns the nominal annual interest rate. The nominal interest rate is the interest rate as stated on the face of a security. It is computed using the following:

Parameters:
`effectiveRate` - a `double`, the effective interest rate
`nper` - an `int`, the number of compounding periods per year
Returns:
a `double`, the nominal annual interest rate
Example
• #### nper

```public static double nper(double rate,
double pmt,
double pv,
double fv,
int when)```
Returns the number of periods for an investment for which periodic, and constant payments are made and the interest rate is constant. It can be found by solving the following:

If ,

If ,

Parameters:
`rate` - a `double`, the interest rate
`pmt` - a `double`, the payment
`pv` - a `double`, the present value
`fv` - a `double`, the future value
`when` - an `int`, the time in each period when the payment is made, either `AT_END_OF_PERIOD` or `AT_BEGINNING_OF_PERIOD`
Returns:
an `int`, the number of periods for an investment
Example
• #### npv

```public static double npv(double rate,
double[] value)```
Returns the net present value of a stream of equal periodic cash flows, which are subject to a given discount rate. It is found by solving the following:

where = the th cash flow, and count is `value.length`.
Parameters:
`rate` - a `double`, the interest rate per period. It must not be -1.
`value` - a `double` array of equally-spaced cash flows
Returns:
a `double`, the net present value of the investment
Example
• #### pmt

```public static double pmt(double rate,
int nper,
double pv,
double fv,
int when)```
Returns the periodic payment for an investment. It can be found by solving the following:

If ,

If ,

Parameters:
`rate` - a `double`, the interest rate
`nper` - an `int`, the total number of periods
`pv` - a `double`, the present value
`fv` - a `double`, the future value
`when` - an `int`, the time in each period when the payment is made, either `AT_END_OF_PERIOD` or `AT_BEGINNING_OF_PERIOD`
Returns:
a `double`, the interest payment for a given period for an investment
Example
• #### ppmt

```public static double ppmt(double rate,
int period,
int nper,
double pv,
double fv,
int when)```
Returns the payment on the principal for a specified period. It is computed using the following:

where is computed from `pmt` for the th period, is calculated from `ipmt` for the th period.
Parameters:
`rate` - a `double`, the interest rate
`period` - an `int`, the payment period
`nper` - an `int`, the total number of periods
`pv` - a `double`, the present value
`fv` - a `double`, the future value
`when` - an `int`, the time in each period when the payment is made, either `AT_END_OF_PERIOD` or `AT_BEGINNING_OF_PERIOD`
Returns:
a `double`, the payment on the principal for a given period
Example
• #### pv

```public static double pv(double rate,
int nper,
double pmt,
double fv,
int when)```
Returns the net present value of a stream of equal periodic cash flows, which are subject to a given discount rate. It can be found by solving the following:

If ,

If ,

Parameters:
`rate` - a `double`, the interest rate per period
`nper` - an `int`, the number of periods
`pmt` - a `double`, the payment made each period
`fv` - a `double`, the annuity's value after the last payment
`when` - an `int`, the time in each period when the payment is made, either `AT_END_OF_PERIOD` or `AT_BEGINNING_OF_PERIOD`
Returns:
a `double`, the present value of the investment
Example
• #### rate

```public static double rate(int nper,
double pmt,
double pv,
double fv,
int when)```
Returns the interest rate per period of an annuity. rate is calculated by iteration and can have zero or more solutions. It can be found by solving the following:

If ,

If ,

Parameters:
`nper` - an `int`, the number of periods
`pmt` - a `double`, the payment made each period
`pv` - a `double`, the present value
`fv` - a `double`, the annuity's value after the last payment
`when` - an `int`, the time in each period when the payment is made, either `AT_END_OF_PERIOD` or `AT_BEGINNING_OF_PERIOD`
Returns:
a `double`, the interest rate per period of an annuity
Example
• #### rate

```public static double rate(int nper,
double pmt,
double pv,
double fv,
int when,
double guess)```
Returns the interest rate per period of an annuity with an initial guess. rate is calculated by iteration and can have zero or more solutions. It can be found by solving the following:

If ,

If ,

Parameters:
`nper` - an `int`, the number of periods
`pmt` - a `double`, the payment made each period
`pv` - a `double`, the present value
`fv` - a `double`, the annuity's value after the last payment
`when` - an `int`, the time in each period when the payment is made, either `AT_END_OF_PERIOD` or `AT_BEGINNING_OF_PERIOD`
`guess` - a `double` value which represents an initial guess at the interest rate per period of an annuity
Returns:
a `double`, the interest rate per period of an annuity
Example
• #### sln

```public static double sln(double cost,
double salvage,
int life)```
Returns the depreciation of an asset using the straight line method. It is computed using the following:

Parameters:
`cost` - a `double`, the initial cost of the asset
`salvage` - a `double`, the salvage value of the asset
`life` - an `int`, the number of periods over which the asset is being depreciated
Returns:
a `double`, the straight line depreciation of an asset for one period
Example
• #### syd

```public static double syd(double cost,
double salvage,
int life,
int per)```
Returns the depreciation of an asset using the sum-of-years digits method. It is computed using the following:

Parameters:
`cost` - a `double`, the initial cost of the asset
`salvage` - a `double`, the salvage value of the asset
`life` - an `int`, the number of periods over which the asset is being depreciated
`per` - an `int`, the period
Returns:
a `double`, the sum-of-years digits depreciation of an asset
Example
• #### vdb

```public static double vdb(double cost,
double salvage,
int life,
int start,
int end,
double factor,
boolean no_sl)```
Returns the depreciation of an asset for any given period using the variable-declining balance method. It is computed using the following:

If ,

If ,

where is computed from `ddb` for the th period. = the first period where straight line depreciation is greater than the depreciation using the double-declining balance method.

Parameters:
`cost` - a `double`, the initial cost of the asset
`salvage` - a `double`, the salvage value of the asset
`life` - an `int`, the number of periods over which the asset is being depreciated
`start` - an `int`, the initial period for the calculation
`end` - an `int`, the final period for the calculation
`factor` - a `double`, the rate at which the balance declines
`no_sl` - a `boolean` flag. If true, do not switch to straight-line depreciation even when the depreciation is greater than the declining balance calculation.
Returns:
a `double`, the depreciation of the asset
Example
• #### xirr

```public static double xirr(double[] pmt,
Date[] dates)```
Returns the internal rate of return for a schedule of cash flows. It is not necessary that the cash flows be periodic. It can be found by solving the following:

In the equation above, represents the th payment date. represents the 1st payment date. represents the th cash flow. is the internal rate of return, and count is `pmt.length`.
Parameters:
`pmt` - a `double` array which contains cash flow values which correspond to a schedule of payments in dates
`dates` - a `Date` array which contains a schedule of payment dates
Returns:
a `double`, the internal rate of return
Example
• #### xirr

```public static double xirr(double[] pmt,
Date[] dates,
double guess)```
Returns the internal rate of return for a schedule of cash flows with a user supplied initial guess. It is not necessary that the cash flows be periodic. It can be found by solving the following:

In the equation above, represents the th payment date. represents the 1st payment date. represents the th cash flow. is the internal rate of return. Count is `pmt.length`.
Parameters:
`pmt` - a `double` array which contains cash flow values which correspond to a schedule of payments in dates
`dates` - a `Date` array which contains a schedule of payment dates
`guess` - a `double` value which represents an initial guess at the return value from this function
Returns:
a `double`, the internal rate of return
• #### xnpv

```public static double xnpv(double rate,
double[] value,
Date[] dates)```
Returns the present value for a schedule of cash flows. It is not necessary that the cash flows be periodic. It is computed using the following:

In the equation above, represents the th payment date, represents the first payment date, represents the th cash flow. and count is `value.length`
Parameters:
`rate` - a `double`, the interest rate
`value` - a `double` array containing the cash flows
`dates` - a `Date` array which contains a schedule of payment dates
Returns:
a `double`, the present value