.\" @(#)exp2.3m 1.4 93/09/01 SMI; from UCB 4.3 BSD .TH exp2 3M "1 Sep 1993" .SH NAME exp2, exp10, log2, compound, annuity \- exponential, logarithm, financial .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B \-lsunmath -lm .RI "[ " "library" " \|.\|.\|. ]" .LP .B #include .LP .BI "double exp2(double " "x" ); .LP .BI "double exp10(double " "x" ); .LP .BI "double log2(double " "x" ); .LP .BI "double compound(double " "r" , .BI "double " "n" ); .LP .BI "double annuity(double " "r" , .BI "double " "n" ); .SH DESCRIPTION .IX "exp2 function" "" "\fLexp2\fP \(em exponential function" .IX "exp10 function" "" "\fLexp10\fP \(em exponential function" .IX "log2 function" "" "\fLlog2\fP \(em logarithm, base 2" .IX "mathematical functions" log2 "" "\fLlog2\fP \(em logarithm, base 2" .IX "logarithm, base 2 log2" "" "logarithm, base 2 \(em \fLlog2\fP" .LP .B exp2(\|) and .B exp10(\|) return .I 2**x and .I 10**x respectively. .LP .B log2(\|) returns the logarithm to base 2. .KS .LP .B compound(\|) and .B annuity(\|) are functions important in financial computations of the effect of interest at periodic rate .I r over .I n periods. .BI compound( r , n ) computes .IR (1+r)**n , the compound interest factor. Given an initial principal .I P0, its value after .I n periods is just .IB "Pn = P0 *" compound( r , n ). .BI annuity( r , n ) computes .I (1 \- (1+r)**\-n)/r, the present value of annuity factor. Given an initial principal .I P0, the equivalent periodic payment is just .I p = P0 / .BI annuity( r , n ). .B compound(\|) and .B annuity(\|) are computed using .B log1p(\|) and .B expm1(\|) to avoid gratuitous inaccuracy for small-magnitude .IR r . .B compound(\|) and .B annuity(\|) are not defined for .I r <= \-1. .PP Thus a principal amount .I P0 placed at 5% annual interest compounded quarterly for 30 years would yield .ft I .nf P30 = P0 * \fBcompound(\fP.05/4, 30.0 * 4\fB)\fP .fi .ft R while a conventional fixed-rate 30-year home loan of amount .I P0 at 10% annual interest would be amortized by monthly payments in the amount .ft I .nf p = P0 / \fBannuity(\fP.10/12, 30.0 * 12\fB)\fP. .fi .ft R .KE .SH "SEE ALSO" .BR exp (3M)