Digital Library of Mathematical Functions
About the Project
NIST
4 Elementary FunctionsComputation

§4.45 Methods of Computation

Contents

§4.45(i) Real Variables

Logarithms

The function lnx can always be computed from its ascending power series after preliminary scaling. Suppose first 1/10x10. Then we take square roots repeatedly until |y| is sufficiently small, where

4.45.1 y=x2-m-1.

After computing ln(1+y) from (4.6.1)

4.45.2 lnx=2mln(1+y).

For other values of x set x=10mξ, where 1/10ξ10 and m. Then

4.45.3 lnx=lnξ+mln10.

Exponentials

Let x have any real value. First, rescale via

4.45.4 m =xln10+12,
y =x-mln10.

Then

4.45.5 x=10my,

and since |y|12ln10=1.15, y can be computed straightforwardly from (4.2.19).

Trigonometric Functions

Let x have any real value. We first compute ξ=x/π, followed by

4.45.6 m =ξ+12,
θ =π(ξ-m).

Then

4.45.7 sinx =(-1)msinθ,
cosx =(-1)mcosθ,

and since |θ|12π=1.57, sinθ and cosθ can be computed straightforwardly from (4.19.1) and (4.19.2).

The other trigonometric functions can be found from the definitions (4.14.4)–(4.14.7).

Inverse Trigonometric Functions

The function arctanx can always be computed from its ascending power series after preliminary transformations to reduce the size of x. From (4.24.15) with u=v=((1+x2)1/2-1)/x, we have

4.45.8 2arctanx1+(1+x2)1/2=arctanx,
0<x<.

Beginning with x0=x, generate the sequence

4.45.9 xn=xn-11+(1+xn-12)1/2,
n=1,2,3,,

until xn is sufficiently small. We then compute arctanxn from (4.24.3), followed by

4.45.10 arctanx=2narctanxn.

Another method, when x is large, is to sum

4.45.11 arctanx=π2-1x+13x3-15x5+;

compare (4.24.4).

As an example, take x=9.47376. Then

4.45.12 x1 =0.90000,
x2 =0.38373,
x3 =0.18528,
x4 =0.09185.

From (4.24.3) arctanx4=0.09160. From (4.45.10)

4.45.13 arctanx=16arctanx4=1.46563.

As a check, from (4.45.11)

4.45.14 arctanx=1.57079-0.10555+0.00039-=1.46563.

For the remaining inverse trigonometric functions, we may use the identities provided by the fourth row of Table 4.16.3. For example, arcsinx=arctan(x(1-x2)-1/2).

Hyperbolic and Inverse Hyperbolic Functions

The hyperbolic functions can be computed directly from the definitions (4.28.1)–(4.28.7). The inverses arcsinh, arccosh, and arctanh can be computed from the logarithmic forms given in §4.37(iv), with real arguments. For arccsch, arcsech, and arccoth we have (4.37.7)–(4.37.9).

Other Methods

See Luther (1995), Ziv (1991), Cody and Waite (1980), Rosenberg and McNamee (1976), Carlson (1972a). For interval-arithmetic algorithms, see Markov (1981). For Shift-and-Add and CORDIC algorithms, see Muller (1997), Merrheim (1994), Schelin (1983). For multiprecision methods, see Smith (1989), Brent (1976).

§4.45(ii) Complex Variables

For lnz and z

4.45.15 lnz =ln|z|+phz,
-πphzπ,
4.45.16 z =z(cos(z)+sin(z)).

See §1.9(i) for the precise relationship of phz to the arctangent function.

The trigonometric functions may be computed from the definitions (4.14.1)–(4.14.7), and their inverses from the logarithmic forms in §4.23(iv), followed by (4.23.7)–(4.23.9). Similarly for the hyperbolic and inverse hyperbolic functions; compare (4.28.1)–(4.28.7), §4.37(iv), and (4.37.7)–(4.37.9).

For other methods see Miel (1981).

§4.45(iii) Lambert W-Function

For x[-1/,) the principal branch Wp(x) can be computed by solving the defining equation WW=x numerically, for example, by Newton’s rule (§3.8(ii)). Initial approximations are obtainable, for example, from the power series (4.13.6) (with t0) when x is close to -1/, from the asymptotic expansion (4.13.10) when x is large, and by numerical integration of the differential equation (4.13.4) (§3.7) for other values of x.

Similarly for Wm(x) in the interval [-1/,0).

See also Barry et al. (1995b) and Chapeau-Blondeau and Monir (2002).