COMPOUND 3CW "06 December 2007" "mathcw-1.00"

Table of contents


NAME

compoundf, compound, compoundl, compoundw, compoundq, compoundll, compounddf, compoundd, compounddl, compounddll - compound interest factor

SYNOPSIS

cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ]

#include <mathcw.h>

extern float compoundf (float rate, float num_periods);

extern double compound (double rate, double num_periods);

extern long double compoundl (long double rate, long double num_periods);

extern __float80 compoundw (__float80 rate, __float80 num_periods);

extern __float128 compoundq (__float128 rate, __float128 num_periods);

extern long_long_double compoundll (long_long_double rate, long_long_double num_periods);

extern decimal_float compounddf (decimal_float rate, decimal_float num_periods);

extern decimal_double compoundd (decimal_double rate, decimal_double num_periods);

extern decimal_long_double compounddl (decimal_long_double rate, decimal_long_double num_periods);

extern decimal_long_long_double compounddll (decimal_long_long_double rate, decimal_long_long_double num_periods);

NB: Functions with prototypes containing underscores in type names may be available only with certain extended compilers.


DESCRIPTION

Given r, the interest rate for one period (i.e., percentage divided by 100), and the number of periods, n, compute the compound interest factor, given by
compound(r,n) = (1 + r)**n        [where r > -1]
              = exp(log((1 + r)**n))
              = exp(n * log(1 + r))
              = exp(n * log1p(r))
The last formula is numerically stable, and is used for the computation.

For example, a principal amount P invested at 5% annual interest and compounded weekly for 30 years would yield

Pw = P * compound(0.05 / 52, 30 * 52) ~= 4.478 P
The yield with monthly compounding is
Pm = P * compound(0.05 / 12, 30 * 12) ~= 4.467 P
The yield with quarterly compounding is
pq = P / compound(0.10 / 4, 30 * 4) ~= 4.440 P
The yield with annual compounding is
Pa = P * compound(0.05 , 30) ~= 4.322 P

With instantaneous compounding, take the limit of arbitrarily large t in compound(r / t, 30 * t) to get a value of about 4.482 P when the annual rate is 5%.


RETURN VALUES

Return the compound interest factor.

ERRORS

If the first argument is a NaN, set errno to EDOM, and return that argument. If the first argument is less than or equal to -1.0, set errno to EDOM, and return a NaN.

SEE ALSO

annuity(3CW), exp(3CW), log1p(3CW).