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

Table of contents


NAME

annuityf, annuity, annuityl, annuityw, annuityq, annuityll, annuitydf, annuityd, annuitydl, annuitydll - present value of annuity factor

SYNOPSIS

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

#include <mathcw.h>

extern float annuityf (float rate, float num_periods);

extern double annuity (double rate, double num_periods);

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

extern __float80 annuityw (__float80 rate, __float80 num_periods);

extern __float128 annuityq (__float128 rate, __float128 num_periods);

extern long_long_double annuityll (long_long_double rate, long_long_double num_periods);

extern decimal_float annuitydf (decimal_float rate, decimal_float num_periods);

extern decimal_double annuityd (decimal_double rate, decimal_double num_periods);

extern decimal_long_double annuitydl (decimal_long_double rate, decimal_long_double num_periods);

extern decimal_long_long_double annuitydll (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 present value of annuity factor, given by
annuity(r,n) = (1 - (1 + r)**(-n)) / r      [where r > -1]
             = (1 - exp(log((1 + r)**(-n)))) / r
             = (1 - exp(-n * log(1 + r))) / r
             = -expm1(-n * log1p(r)) / r
The last formula is used for the computation. It is numerically stable, and avoids the severe loss of leading digits that is implicit in the first equation when |r| is small.

If the value of an annuity at maturity (i.e., when its full amount has been paid) is P, its value n periods earlier is P / annuity(r,n).

A mortgage for the borrower is just an annuity for the lender. For example, a fixed-rate 30-year mortgage for an amount P at 10% annual interest would require weekly payments of

pw = P / annuity(0.10 / 52, 30 * 52) ~= 0.002024 P
or monthly payments of
pm = P / annuity(0.10 / 12, 30 * 12) ~= 0.008776 P
or quarterly payments of
pq = P / annuity(0.10 / 4, 30 * 4) ~= 0.026361 P
or annual payments of
pa = P / annuity(0.10, 30) ~= 0.106079 P.

The last result demonstrates that the total repayment of the mortgage with annual payments will cost about 30 * 0.106 P = 3.18 P, 68.5% of which is interest. Reducing the loan to 20 years cuts the total interest paid back to about 57%, and reducing the loan to 10 years drops the total interest paid to about 38.5%.

The future value of an annuity is the sum of the values of interest-compounded equal periodic payments of P after n periods, assuming payment is made at the end of the period. The first payment therefore is compounded for n - 1 periods, the second for n - 2 periods, ..., and the last is not compounded at all. The sum is therefore

future value of annuity = P(1 + r)**(n - 1) + P(1 + r)**(n - 2) + ... + P(1 + r)**0
                        = P sum(k=0:(n - 1)) (1 + r)**k
                        = P ((1 + r)**n - 1) / r
                        = P (1 + r)**n * (1 -  (1 + r)**(-n)) / r
                        = P * compound(r,n) * annuity(r,n)

RETURN VALUES

Return the present value of annuity 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

compound(3CW), expm1(3CW), log1p(3CW).