NAG Library Manual, Mark 28.3
Interfaces:
FL
CL
CPP
AD
NAG CL Interface Introduction
S (Specfun) Chapter Contents
S (Specfun) Chapter Introduction
s01ba:
FL
CL
CPP
AD
NAG CL Interface
s01bac (log_shifted)
Keyword Search:
NAG Library Manual, Mark 28.3
Interfaces:
FL
CL
CPP
AD
NAG CL Interface Introduction
S (Specfun) Chapter Contents
S (Specfun) Chapter Introduction
s01ba:
FL
CL
CPP
AD
▸
▿
Contents
1
Purpose
2
Specification
3
Description
4
References
5
Arguments
6
Error Indicators and Warnings
7
Accuracy
8
Parallelism and Performance
9
Further Comments
▸
▿
10
Example
10.1
Program Text
10.2
Program Data
10.3
Program Results
© The Numerical Algorithms Group Ltd. 2022
Settings help
CL Name Style:
Short (
a00aac
)
Long (
impl_details
)
Full (
nag_info_impl_details
)
1
Purpose
s01bac
returns a value of the shifted logarithmic function,
ln
(
1
+
x
)
.
2
Specification
copy
#include <nag.h>
double
s01bac
(
double
x
,
NagError *
fail
)
The function may be called by the names:
s01bac
,
nag_specfun_log_shifted
or
nag_shifted_log
.
3
Description
s01bac
computes values of
ln
(
1
+
x
)
, retaining full relative precision even when
|
x
|
is small. The function is based on the Chebyshev expansion
ln
1
+
p
2
+
2
p
x
¯
1
+
p
2
-
2
p
x
¯
=
4
∑
k
=
0
∞
p
2
k
+
1
2
k
+
1
T
2
k
+
1
(
x
¯
)
.
Setting
x
¯
=
x
(
1
+
p
2
)
2
p
(
x
+
2
)
, and choosing
p
=
q
-
1
q
+
1
,
q
=
2
4
the expansion is valid in the domain
x
∈
[
1
2
-
1
,
2
-
1
]
.
Outside this domain,
ln
(
1
+
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:
x
–
double
Input
On entry
: the argument
x
of the function.
Constraint
:
x
>
-
1.0
.
2:
fail
–
NagError *
Input/Output
The NAG error argument (see
Section 7
in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See
Section 3.1.2
in the Introduction to the NAG Library CL Interface for further information.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG
for assistance.
See
Section 7.5
in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See
Section 8
in the Introduction to the NAG Library CL Interface for further information.
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
ln
(
1
+
x
)
, in
s01bac
.
8
Parallelism and Performance
s01bac
is not threaded in any implementation.
9
Further Comments
Empirical tests show that the time taken for a call of
s01bac
usually lies between about
1.25
and
2.5
times the time for a call to the standard logarithm function.
10
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.
10.1
Program Text
Program Text (s01bace.c)
10.2
Program Data
Program Data (s01bace.d)
10.3
Program Results
Program Results (s01bace.r)
NAG Library Manual, Mark 28.3
Interfaces:
FL
CL
CPP
AD
NAG CL Interface Introduction
S (Specfun) Chapter Contents
S (Specfun) Chapter Introduction
s01ba:
FL
CL
CPP
AD
© The Numerical Algorithms Group Ltd. 2022