GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
alnrel.f
Go to the documentation of this file.
1 *DECK ALNREL
2  FUNCTION alnrel (X)
3 C***BEGIN PROLOGUE ALNREL
4 C***PURPOSE Evaluate ln(1+X) accurate in the sense of relative error.
5 C***LIBRARY SLATEC (FNLIB)
6 C***CATEGORY C4B
7 C***TYPE SINGLE PRECISION (ALNREL-S, DLNREL-D, CLNREL-C)
8 C***KEYWORDS ELEMENTARY FUNCTIONS, FNLIB, LOGARITHM
9 C***AUTHOR Fullerton, W., (LANL)
10 C***DESCRIPTION
11 C
12 C ALNREL(X) evaluates ln(1+X) accurately in the sense of relative
13 C error when X is very small. This routine must be used to
14 C maintain relative error accuracy whenever X is small and
15 C accurately known.
16 C
17 C Series for ALNR on the interval -3.75000D-01 to 3.75000D-01
18 C with weighted error 1.93E-17
19 C log weighted error 16.72
20 C significant figures required 16.44
21 C decimal places required 17.40
22 C
23 C***REFERENCES (NONE)
24 C***ROUTINES CALLED CSEVL, INITS, R1MACH, XERMSG
25 C***REVISION HISTORY (YYMMDD)
26 C 770401 DATE WRITTEN
27 C 890531 Changed all specific intrinsics to generic. (WRB)
28 C 890531 REVISION DATE from Version 3.2
29 C 891214 Prologue converted to Version 4.0 format. (BAB)
30 C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
31 C 900326 Removed duplicate information from DESCRIPTION section.
32 C (WRB)
33 C***END PROLOGUE ALNREL
34  dimension alnrcs(23)
35  LOGICAL first
36  SAVE alnrcs, nlnrel, xmin, first
37  DATA alnrcs( 1) / 1.0378693562 743770e0 /
38  DATA alnrcs( 2) / -.1336430150 4908918e0 /
39  DATA alnrcs( 3) / .0194082491 35520563e0 /
40  DATA alnrcs( 4) / -.0030107551 12753577e0 /
41  DATA alnrcs( 5) / .0004869461 47971548e0 /
42  DATA alnrcs( 6) / -.0000810548 81893175e0 /
43  DATA alnrcs( 7) / .0000137788 47799559e0 /
44  DATA alnrcs( 8) / -.0000023802 21089435e0 /
45  DATA alnrcs( 9) / .0000004164 04162138e0 /
46  DATA alnrcs(10) / -.0000000735 95828378e0 /
47  DATA alnrcs(11) / .0000000131 17611876e0 /
48  DATA alnrcs(12) / -.0000000023 54670931e0 /
49  DATA alnrcs(13) / .0000000004 25227732e0 /
50  DATA alnrcs(14) / -.0000000000 77190894e0 /
51  DATA alnrcs(15) / .0000000000 14075746e0 /
52  DATA alnrcs(16) / -.0000000000 02576907e0 /
53  DATA alnrcs(17) / .0000000000 00473424e0 /
54  DATA alnrcs(18) / -.0000000000 00087249e0 /
55  DATA alnrcs(19) / .0000000000 00016124e0 /
56  DATA alnrcs(20) / -.0000000000 00002987e0 /
57  DATA alnrcs(21) / .0000000000 00000554e0 /
58  DATA alnrcs(22) / -.0000000000 00000103e0 /
59  DATA alnrcs(23) / .0000000000 00000019e0 /
60  DATA first /.true./
61 C***FIRST EXECUTABLE STATEMENT ALNREL
62  IF (first) THEN
63  nlnrel = inits(alnrcs, 23, 0.1*r1mach(3))
64  xmin = -1.0 + sqrt(r1mach(4))
65  ENDIF
66  first = .false.
67 C
68  IF (x .LE. (-1.0)) CALL xermsg ('SLATEC', 'ALNREL', 'X IS LE -1',
69  + 2, 2)
70  IF (x .LT. xmin) CALL xermsg ('SLATEC', 'ALNREL',
71  + 'ANSWER LT HALF PRECISION BECAUSE X TOO NEAR -1', 1, 1)
72 C
73  IF (abs(x).LE.0.375) alnrel = x*(1. -
74  1 x*csevl(x/.375, alnrcs, nlnrel))
75  IF (abs(x).GT.0.375) alnrel = log(1.0+x)
76 C
77  RETURN
78  END
function alnrel(X)
Definition: alnrel.f:3
function csevl(X, CS, N)
Definition: csevl.f:3
function inits(OS, NOS, ETA)
Definition: inits.f:3
octave_int< T > xmin(const octave_int< T > &x, const octave_int< T > &y)
static T abs(T x)
Definition: pr-output.cc:1678
real function r1mach(i)
Definition: r1mach.f:23
subroutine xermsg(LIBRAR, SUBROU, MESSG, NERR, LEVEL)
Definition: xermsg.f:3