nag_shifted_log (s01bac) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_shifted_log (s01bac)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_shifted_log (s01bac) returns a value of the shifted logarithmic function, ln1+x.

2  Specification

#include <nag.h>
#include <nags.h>
double  nag_shifted_log (double x, NagError *fail)

3  Description

nag_shifted_log (s01bac) computes values of ln1+x, retaining full relative precision even when x is small. The function is based on the Chebyshev expansion
ln1+p2+2px- 1+p2-2px- =4k=0p2k+1 2k+1 T2k+1x-.
Setting x-= x1+p2 2px+2 , and choosing p= q-1 q+1 , q=24 the expansion is valid in the domain x 12-1,2-1 .
Outside this domain, ln1+x is computed by the standard logarithmic function.

4  References

Lyusternik L A, Chervonenkis O A and Yanpolskii A R (1965) Handbook for Computing Elementary Functions p. 57 Pergamon Press

5  Arguments

1:     xdoubleInput
On entry: the argument x of the function.
Constraint: x>-1.0.
2:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_REAL_ARG_LE
On entry, x=value.
Constraint: x>-1.0.

7  Accuracy

The returned result should be accurate almost to machine precision, with a limit of about 20 significant figures due to the precision of internal constants. Note however that if x lies very close to -1.0 and is not exact (for example if x is the result of some previous computation and has been rounded), then precision will be lost in the computation of 1+x, and hence ln1+x, in nag_shifted_log (s01bac).

8  Further Comments

Empirical tests show that the time taken for a call of nag_shifted_log (s01bac) usually lies between about 1.25 and 2.5 times the time for a call to the standard logarithm function.

9  Example

The example program reads values of the argument x from a file, evaluates the function at each value of x and prints the results.

9.1  Program Text

Program Text (s01bace.c)

9.2  Program Data

Program Data (s01bace.d)

9.3  Program Results

Program Results (s01bace.r)


nag_shifted_log (s01bac) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012