JMSLTM Numerical Library 5.0.1

com.imsl.finance
Class Finance

java.lang.Object
  extended by com.imsl.finance.Finance

public class Finance
extends Object

Collection of finance functions.


Field Summary
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
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.

See Also:
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.

See Also:
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:

sumlimits_{i = {it start}}^{it end} 
  {it interest}_i

where {it interest}_i is computed from ipmt for the ith 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
See Also:
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:

sumlimits_{i = {it start}}^{it end} 
  {it principal}_i

where {it principal}_i is computed from ppmt for the ith 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
See Also:
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,

{rm{cost}} times 
  {rm{rate}} times {{{rm{month}}} over {12}}


If period = life,

left( {{rm{cost}} - 
  {rm{total}},{rm{depreciation}},{rm{from}},{rm{periods}}} right) 
  times {rm{rate}} times {{12{rm{ - month}}} over {12}}


If period other than 1 or life,

,left( 
  {{rm{cost}} - {rm{total}},{rm{depreciation}},{rm{from}},
  {rm{prior periods}}} right) times rate

where

,rate, = 1 - left( {{{{rm{salvage}}} 
  over {{rm{cost}}}}} right)^{left( {{1 over {life}}} right)}

NOTE: rate 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
See Also:
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:

left[ {{it cost} - {it salvage}left( 
  {it {total,depreciation,from,prior,periods}} right)} right], 
  {{{it factor} over {it life}}}

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
See Also:
Example

dollarde

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

{it idollar} + left( {{it fractionalDollar} - 
  {it idollar}} right) times {{10^{left( {{it ifrac} + 1} right)} } 
  over {it fraction}}

where {it idollar} is the integer part of {it fractionalDollar}, and {it ifrac} is the integer part of {rm {log}}({it fraction}).

Parameters:
fractionalDollar - a double, a fractional number
fraction - an int, the denominator
Returns:
a double, the dollar price expressed as a decimal number
See Also:
Example

dollarfr

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

{it idollar} + {{{it decimalDollar} - 
  {it idollar}} over {10^{left( {{it ifrac} + 1} right)} / 
  {it fraction}}}

where {it idollar} is the integer part of the {it decimalDollar}, and {it ifrac} is the integer part of log({it fraction}).

Parameters:
decimalDollar - a double, a decimal number
fraction - a int, the denominator
Returns:
a double, a dollar price expressed as a fraction
See Also:
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:

left( {1 + {{it nominalRate} over 
  {it nper}}} right)^{it nper} - 1

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
See Also:
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 rate = 0,

{it pv} + 
 {it pmt} times {it nper} + {it fv} = 0

If rate ne 0,

{it pv}
 (1 + {it rate})^{it nper}  + {it pmt} left[ {1 + {it rate} left( 
 {it when} right)} right] {{(1 + {it rate})^{it nper}  - 1} over 
 {it rate}} + {it fv} = 0

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
See Also:
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:

sumlimits_{i = 1}^{it count} {left( 
  {{it principal} times {it schedule}_i } right)}

where {it schedule}_i = interest rate at the ith 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
See Also:
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:

left{ {{it pv}left( {1 + {it rate}} 
  right)^{{it nper} - 1}  + {it pmt} left( {1 + {it rate} times 
  {it when}} right) {{{left( {1 + {it rate}} right)^{{it nper} - 1} } 
  over {it rate}}} } right} {it rate}

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
See Also:
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:

0 = sumlimits_{i = 1}^{it count} 
  {{{it value}_i } over {left( {1 + {it rate}} right)^i }}

where {it value}_i = the ith cash flow, {it rate} 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
See Also:
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:

0 = sumlimits_{i = 1}^{it count} 
  {{{it value}_i } over {left( {1 + {it rate}} right)^i }}

where {it value}_i = the ith cash flow, {it rate} 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:

{left{ {{{ - left( {it pnpv} right)left( 
  {1 + {it reinvestRate}} right)^{it nper} } over {left( {it nnpv} 
  right)left( {1 + {it financeRate}} right)}}} right}^{{1 over 
  {{it nper} - 1}}} } - 1

where {it pnpv} is calculated from npv for positive values in value using reinvestRate, {it nnpv} 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
See Also:
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:

left[ {left( {1 + {it effectiveRate}} 
  right)^{^{{1 over {it nper}}} }  - 1} right] times {it nper}

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
See Also:
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 rate = 0,

{it pv} + 
 {it pmt} times {it nper} + {it fv} = 0

If rate ne 0,

{it pv}
 (1 + {it rate})^{it nper}  + {it pmt} left[ {1 + {it rate} left( 
 {it when} right)} right] {{(1 + {it rate})^{it nper}  - 1} over 
 {it rate}} + {it fv} = 0

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
See Also:
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:

sumlimits_{i = 1}^{count} {{{it value}_i} 
  over {left( {1 + {it rate}} right)}^i }

where {it value}_i = the ith 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
See Also:
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 rate = 0,

{it pv} 
  + {it pmt} times {it nper} + {it fv} = 0

If {it rate} ne 0,

{it pv}(1 + {it rate})^{it nper}  + {it pmt} left[ {1 + {it rate} 
  left( {it when} right)} right] {{(1 + {it rate})^{it nper}  - 1} 
  over {it rate}} + {it fv} = 0

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
See Also:
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:

{it payment}_i  - {it interest}_i

where {it payment}_i is computed from pmt for the ith period, {it interest}_i is calculated from ipmt for the ith 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
See Also:
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 {it rate} = 0,

{it pv} 
  + {it pmt} times {it nper} + {it fv} = 0

If {it rate} ne 0,

{it pv}(1 + {it rate})^{it nper}  + {it pmt} left[ {1 + {it rate} 
  left( {it when} right)} right] {{(1 + {it rate})^{it nper}  - 1} 
  over {it rate}} + {it fv} = 0

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
See Also:
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 {it rate} = 0,

{it pv} 
  + {it pmt} times {it nper} + {it fv} = 0

If {it rate} ne 0,

{it pv}(1 + {it rate})^{it nper}  + {it pmt} left[ {1 + {it rate} 
  left( {it when} right)} right] {{(1 + {it rate})^{it nper}  - 1} 
  over {it rate}} + {it fv} = 0

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
See Also:
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 {it rate} = 0,

{it pv} 
  + {it pmt} times {it nper} + {it fv} = 0

If {it rate} ne 0,

{it pv}(1 + {it rate})^{it nper}  + {it pmt} left[ {1 + {it rate} 
  left( {it when} right)} right] {{(1 + {it rate})^{it nper}  - 1} 
  over {it rate}} + {it fv} = 0

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
See Also:
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:

{{it cost} - {it salvage}} / {it life}

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
See Also:
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:

({it cost} - {it salvage})({it per}),,
  {{({it life} + 1)left( {it life} right)} over 2}

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
See Also:
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 no_sl = 0,

sumlimits_{i = {it start} + 1}^{it end} {{it ddb}_i }

If no_sl ne 0,

A + 
  sumlimits_{i = k}^{it end} {{{{{it cost}} - A - {it salvage}} 
  over {{it end} - k + 1}}}

where {it ddb}_i is computed from ddb for the ith period. k = the first period where straight line depreciation is greater than the depreciation using the double-declining balance method.

A = sumlimits_{i = {it start} + 1}^{k - 1} 
  {{it ddb}_i}

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
See Also:
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:

0 = sumlimits_{i = 1}^{it count} 
  {{{{it value}_i } over {left( {1 + {it rate}} right)^{{{d_i  - d_1 } 
  over {365}}} }}}

In the equation above, d_i represents the ith payment date. d_1 represents the 1st payment date. {it value} represents the ith cash flow. {it rate} 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
See Also:
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:

0 = sumlimits_{i = 1}^{it count} 
  {{{{it value}_i } over {left( {1 + {it rate}} right)^{{{d_i  - d_1 } 
  over {365}}} }}}

In the equation above, d_i represents the ith payment date. d_1 represents the 1st payment date. {it value} represents the ith cash flow. {it rate} 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:

sumlimits_{i = 1}^{it count} 
  {{{{it value}_i } over {left( {1 + {it rate}} right)^{left( 
  {d_i  - d_1 } right)/365}}}}

In the equation above, d_i represents the ith payment date, d_1 represents the first payment date, {it value}_i represents the ith 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
See Also:
Example

JMSLTM Numerical Library 5.0.1

Copyright © 1970-2008 Visual Numerics, Inc.
Built July 8 2008.