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 \mathop{\ln\/}\nolimits x can always be computed from its ascending power series after preliminary scaling. Suppose first 1/10\leq x\leq 10. Then we take square roots repeatedly until |y| is sufficiently small, where

4.45.1y=x^{{2^{{-m}}}}-1.

After computing \mathop{\ln\/}\nolimits\!\left(1+y\right) from (4.6.1)

For other values of x set x=10^{m}\xi, where 1/10\leq\xi\leq 10 and m\in\Integer. Then

Exponentials

Let x have any real value. First, rescale via

Then

and since |y|\leq\frac{1}{2}\mathop{\ln\/}\nolimits 10=1.15\dots, e^{y} can be computed straightforwardly from (4.2.19).

Trigonometric Functions

Let x have any real value. We first compute \xi=x/\pi, followed by

4.45.6
m=\left\lfloor\xi+\tfrac{1}{2}\right\rfloor,
\theta=\pi(\xi-m).

Then

and since |\theta|\leq\frac{1}{2}\pi=1.57\dots, \mathop{\sin\/}\nolimits\theta and \mathop{\cos\/}\nolimits\theta 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 \mathop{\mathrm{arctan}\/}\nolimits x 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+x^{2})^{{1/2}}-1)/x, we have

4.45.82\mathop{\mathrm{arctan}\/}\nolimits\frac{(1+x^{2})^{{1/2}}-1}{x}=\mathop{%
\mathrm{arctan}\/}\nolimits x,0<x<\infty.

Beginning with x_{0}=x, generate the sequence

4.45.9x_{n}=\frac{(1+x^{2}_{{n-1}})^{{1/2}}-1}{x_{{n-1}}},n=1,2,3,\dots,

until x_{n} is sufficiently small. We then compute \mathop{\mathrm{arctan}\/}\nolimits x_{n} from (4.24.3), followed by

4.45.10\mathop{\mathrm{arctan}\/}\nolimits x=2^{n}\mathop{\mathrm{arctan}\/}\nolimits
x%
_{n}.

Another method, when x is large, is to sum

4.45.11\mathop{\mathrm{arctan}\/}\nolimits x=\frac{\pi}{2}-\frac{1}{x}+\frac{1}{3x^{3%
}}-\frac{1}{5x^{5}}+\dots;

compare (4.24.4).

As an example, take x=9.47376. Then

4.45.12
x_{1}=0.90000\dots,
x_{2}=0.38373\dots,
x_{3}=0.18528\dots,
x_{4}=0.09185\dots.

From (4.24.3) \mathop{\mathrm{arctan}\/}\nolimits x_{4}=0.09160\dots. From (4.45.10)

4.45.13\mathop{\mathrm{arctan}\/}\nolimits x=16\mathop{\mathrm{arctan}\/}\nolimits x_%
{4}=1.46563\dots.

As a check, from (4.45.11)

4.45.14\mathop{\mathrm{arctan}\/}\nolimits x=1.57079\ldots-0.10555\ldots+0.00039%
\ldots-\cdots=1.46563\dots.

For the remaining inverse trigonometric functions, we may use the identities provided by the fourth row of Table 4.16.3. For example, \mathop{\mathrm{arcsin}\/}\nolimits x=\mathop{\mathrm{arctan}\/}\nolimits\!%
\left(x(1-x^{2})^{{-1/2}}\right).

Hyperbolic and Inverse Hyperbolic Functions

The hyperbolic functions can be computed directly from the definitions (4.28.1)–(4.28.7). The inverses \mathop{\mathrm{arcsinh}\/}\nolimits, \mathop{\mathrm{arccosh}\/}\nolimits, and \mathop{\mathrm{arctanh}\/}\nolimits can be computed from the logarithmic forms given in §4.37(iv), with real arguments. For \mathop{\mathrm{arccsch}\/}\nolimits, \mathop{\mathrm{arcsech}\/}\nolimits, and \mathop{\mathrm{arccoth}\/}\nolimits 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 \mathop{\ln\/}\nolimits z and e^{z}

See §1.9(i) for the precise relationship of \mathop{\mathrm{ph}\/}\nolimits z 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 \mathop{W\/}\nolimits-Function

For x\in[-1/e,\infty) the principal branch \mathop{\mathrm{Wp}\/}\nolimits\!\left(x\right) can be computed by solving the defining equation We^{W}=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 t\geq 0) when x is close to -1/e, 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 \mathop{\mathrm{Wm}\/}\nolimits\!\left(x\right) in the interval [-1/e,0).

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