


EXP(3M)               MATHEMATICAL LIBRARY                EXP(3M)



NAME
     exp, expm1, exp2, exp10, log, log1p, log2, log10, pow,  com-
     pound, annuity - exponential, logarithm, power

SYNOPSIS
     #include <math.h>

     double exp(x)
     double x;

     double expm1(x)
     double x;

     double exp2(x)
     double x;

     double exp10(x)
     double x;

     double log(x)
     double x;

     double log1p(x)
     double x;

     double log2(x)
     double x;

     double log10(x)
     double x;

     double pow(x, y)
     double x, y;

     double compound(r, n)
     double r, n;

     double annuity(r, n)
     double r, n;

DESCRIPTION
     exp() returns the exponential function _e**_x.

     expm1() returns _e**_x-_1 accurately even for tiny _x.

     exp2() and exp10() return _2**_x and _1_0**_x respectively.

     log() returns the natural logarithm of _x.

     log1p() returns log(1+x) accurately even for tiny _x.





Sun Release 4.1    Last change: 24 March 1988                   1






EXP(3M)               MATHEMATICAL LIBRARY                EXP(3M)



     log2() and log10() return the logarithm to  base  2  and  10
     respectively.

     pow() returns _x**_y.  pow(_x ,0.0) is 1 for all x, in  confor-
     mance  with  4.3BSD,  as  discussed  in  the  _F_l_o_a_t_i_n_g-_P_o_i_n_t
     _P_r_o_g_r_a_m_m_e_r'_s _G_u_i_d_e.

     compound() and annuity() are functions important  in  finan-
     cial computations of the effect of interest at periodic rate
     _r over _n periods.  compound(_r,  _n)  computes  (_1+_r)**_n,  the
     compound  interest  factor.   Given an initial principal _P_0,
     its value after _n periods is just Pn = _P_0 * compound(_r,  _n).
     annuity(_r,  _n) computes (_1 - (_1+_r)**-_n)/_r, the present value
     of annuity factor.   Given  an  initial  principal  _P_0,  the
     equivalent  periodic payment is just p = _P_0 / annuity(_r, _n).
     compound() and annuity()  are  computed  using  log1p()  and
     expm1()  to  avoid gratuitous inaccuracy for small-magnitude
     _r.  compound() and annuity() are not defined for _r <= -1.

     Thus a principal amount _P_0 placed at 5% annual interest com-
     pounded quarterly for 30 years would yield

          P30 = _P_0 * compound(.05/4, 30.0 * 4)

     while a conventional fixed-rate 30-year home loan of  amount
     _P_0 at 10% annual interest would be amortized by monthly pay-
     ments in the amount

          p = _P_0 / annuity( .10/12, 30.0 * 12)

SEE ALSO
     matherr(3M)

DIAGNOSTICS
     All these functions  handle  exceptional  arguments  in  the
     spirit of ANSI/IEEE Std 754-1985.  Thus for x == +-0, log(_x)
     is -oo with a division by zero exception; for x < 0, includ-
     ing  -oo,  log(_x)  is  a quiet NaN with an invalid operation
     exception; for x == +oo or a quiet NaN, log(_x) is x  without
     exception; for x a signaling NaN, log(_x) is a quiet NaN with
     an invalid operation exception; for x  ==  1,  log(_x)  is  0
     without  exception;  for  any  other positive x, log(_x) is a
     normalized number with an inexact exception.

     In addition, exp(), exp2(), exp10(), log(), log2(),  log10()
     and pow() may also set errno and call matherr(3M).









Sun Release 4.1    Last change: 24 March 1988                   2



