GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
dlnrel.f
Go to the documentation of this file.
1 *DECK DLNREL
2  DOUBLE PRECISION FUNCTION dlnrel (X)
3 C***BEGIN PROLOGUE DLNREL
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 DOUBLE 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 DLNREL(X) calculates the double precision natural logarithm of
13 C (1.0+X) for double precision argument X. This routine should
14 C be used when X is small and accurate to calculate the logarithm
15 C accurately (in the relative error sense) in the neighborhood
16 C of 1.0.
17 C
18 C Series for ALNR on the interval -3.75000E-01 to 3.75000E-01
19 C with weighted error 6.35E-32
20 C log weighted error 31.20
21 C significant figures required 30.93
22 C decimal places required 32.01
23 C
24 C***REFERENCES (NONE)
25 C***ROUTINES CALLED D1MACH, DCSEVL, INITDS, XERMSG
26 C***REVISION HISTORY (YYMMDD)
27 C 770601 DATE WRITTEN
28 C 890531 Changed all specific intrinsics to generic. (WRB)
29 C 890531 REVISION DATE from Version 3.2
30 C 891214 Prologue converted to Version 4.0 format. (BAB)
31 C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
32 C***END PROLOGUE DLNREL
33  DOUBLE PRECISION ALNRCS(43), X, XMIN, DCSEVL, D1MACH
34  LOGICAL FIRST
35  SAVE alnrcs, nlnrel, xmin, first
36  DATA alnrcs( 1) / +.1037869356 2743769800 6862677190 98 d+1 /
37  DATA alnrcs( 2) / -.1336430150 4908918098 7660415531 33 d+0 /
38  DATA alnrcs( 3) / +.1940824913 5520563357 9261993747 50 d-1 /
39  DATA alnrcs( 4) / -.3010755112 7535777690 3765377765 92 d-2 /
40  DATA alnrcs( 5) / +.4869461479 7154850090 4563665091 37 d-3 /
41  DATA alnrcs( 6) / -.8105488189 3175356066 8099430086 22 d-4 /
42  DATA alnrcs( 7) / +.1377884779 9559524782 9382514960 59 d-4 /
43  DATA alnrcs( 8) / -.2380221089 4358970251 3699929149 35 d-5 /
44  DATA alnrcs( 9) / +.4164041621 3865183476 3918599019 89 d-6 /
45  DATA alnrcs( 10) / -.7359582837 8075994984 2668370319 98 d-7 /
46  DATA alnrcs( 11) / +.1311761187 6241674949 1522943450 11 d-7 /
47  DATA alnrcs( 12) / -.2354670931 7742425136 6960923301 75 d-8 /
48  DATA alnrcs( 13) / +.4252277327 6034997775 6380529625 67 d-9 /
49  DATA alnrcs( 14) / -.7719089413 4840796826 1081074933 00 d-10 /
50  DATA alnrcs( 15) / +.1407574648 1359069909 2153564721 91 d-10 /
51  DATA alnrcs( 16) / -.2576907205 8024680627 5370786275 84 d-11 /
52  DATA alnrcs( 17) / +.4734240666 6294421849 1543950059 38 d-12 /
53  DATA alnrcs( 18) / -.8724901267 4742641745 3012632926 75 d-13 /
54  DATA alnrcs( 19) / +.1612461490 2740551465 7398331191 15 d-13 /
55  DATA alnrcs( 20) / -.2987565201 5665773006 7107924168 15 d-14 /
56  DATA alnrcs( 21) / +.5548070120 9082887983 0413216972 79 d-15 /
57  DATA alnrcs( 22) / -.1032461915 8271569595 1413339619 32 d-15 /
58  DATA alnrcs( 23) / +.1925023920 3049851177 8785032448 68 d-16 /
59  DATA alnrcs( 24) / -.3595507346 5265150011 1897078442 66 d-17 /
60  DATA alnrcs( 25) / +.6726454253 7876857892 1945742267 73 d-18 /
61  DATA alnrcs( 26) / -.1260262416 8735219252 0824256375 46 d-18 /
62  DATA alnrcs( 27) / +.2364488440 8606210044 9161589555 19 d-19 /
63  DATA alnrcs( 28) / -.4441937705 0807936898 8783891797 33 d-20 /
64  DATA alnrcs( 29) / +.8354659446 4034259016 2412939946 66 d-21 /
65  DATA alnrcs( 30) / -.1573155941 6479562574 8992535210 66 d-21 /
66  DATA alnrcs( 31) / +.2965312874 0247422686 1543697066 66 d-22 /
67  DATA alnrcs( 32) / -.5594958348 1815947292 1560132266 66 d-23 /
68  DATA alnrcs( 33) / +.1056635426 8835681048 1872841386 66 d-23 /
69  DATA alnrcs( 34) / -.1997248368 0670204548 3149994666 66 d-24 /
70  DATA alnrcs( 35) / +.3778297781 8839361421 0498559999 99 d-25 /
71  DATA alnrcs( 36) / -.7153158688 9081740345 0381653333 33 d-26 /
72  DATA alnrcs( 37) / +.1355248846 3674213646 5020245333 33 d-26 /
73  DATA alnrcs( 38) / -.2569467304 8487567430 0798293333 33 d-27 /
74  DATA alnrcs( 39) / +.4874775606 6216949076 4595199999 99 d-28 /
75  DATA alnrcs( 40) / -.9254211253 0849715321 1323733333 33 d-29 /
76  DATA alnrcs( 41) / +.1757859784 1760239233 2697600000 00 d-29 /
77  DATA alnrcs( 42) / -.3341002667 7731010351 3770666666 66 d-30 /
78  DATA alnrcs( 43) / +.6353393618 0236187354 1802666666 66 d-31 /
79  DATA first /.true./
80 C***FIRST EXECUTABLE STATEMENT DLNREL
81  IF (first) THEN
82  nlnrel = initds(alnrcs, 43, 0.1*REAL(d1mach(3)))
83  xmin = -1.0d0 + sqrt(d1mach(4))
84  ENDIF
85  first = .false.
86 C
87  IF (x .LE. (-1.d0)) CALL xermsg('SLATEC', 'DLNREL', 'X IS LE -1'
88  + , 2, 2)
89  IF (x .LT. xmin) CALL xermsg('SLATEC', 'DLNREL',
90  + 'ANSWER LT HALF PRECISION BECAUSE X TOO NEAR -1', 1, 1)
91 C
92  IF (abs(x).LE.0.375d0) dlnrel = x*(1.d0 -
93  1 x*dcsevl(x/.375d0, alnrcs, nlnrel))
94 C
95  IF (abs(x).GT.0.375d0) dlnrel = log(1.0d0+x)
96 C
97  RETURN
98  END
octave_value log(void) const
Definition: ov.h:1190
double precision function dlnrel(X)
Definition: dlnrel.f:2
function initds(OS, NOS, ETA)
Definition: initds.f:2
subroutine xermsg(LIBRAR, SUBROU, MESSG, NERR, LEVEL)
Definition: xermsg.f:2
T abs(T x)
Definition: pr-output.cc:3062
octave_value sqrt(void) const
Definition: ov.h:1200