Generate and return the expression log(1 + x)
robustly (without numerical underflow).
- Parameters
-
[in] | x | : The input scalar, or array of arbitrary rank, shape, and size, of either
-
type
complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128), or
-
type
real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
representing the x value whose log(1 + x) is to be returned.
|
- Returns
log1p
: The output scalar (or array) of the same type and kind (and shape) as the input x
representing log(1 + x)
without underflow.
Possible calling interfaces ⛓
Generate and return the expression log(1 + x) robustly (without numerical underflow).
This module contains procedures and generic interfaces for computing log(1 + x) more precisely for ti...
- Warning
- The condition
x > -1.
must hold.
The condition x < huge(x)
must hold.
When the input arguments are of type complex
, these conditions must hold for the real
components of the numbers.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1
.
-
The
pure
procedure(s) documented herein become impure
when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1
.
By default, these procedures are pure
in release
build and impure
in debug
and testing
builds.
- See also
- getLog1p
get1mexp
getLogAddExp
getLogSubExp
getLogSumExp
Example usage ⛓
11 real(RKH) :: log1p_ref
12 real(RKH),
allocatable :: inaccuracy(:)
13 real,
parameter :: EPS
= epsilon(
0.)
14 type(display_type) :: disp
21 call disp%show(
"log1p_ref = log(1._RKH + real(x, RKH)) ! reference high-precision value for comparison")
22 log1p_ref
= log(
1._RKH + real(x,
RKH))
25 call disp%show(
"log1p = [log(1. + x), getLog1p(x)]")
29 call disp%show(
"inaccuracy = abs(log1p_ref - log1p)")
30 inaccuracy
= abs(log1p_ref
- log1p)
33 call disp%show(
"getRankDense(inaccuracy)")
42 call disp%show(
"log1p_ref = log(1._RKH + real(x, RKH)) ! reference high-precision value for comparison")
43 log1p_ref
= log(
1._RKH + real(x,
RKH))
46 call disp%show(
"log1p = [log(1. + x), getLog1p(x)]")
50 call disp%show(
"inaccuracy = abs(log1p_ref - log1p)")
51 inaccuracy
= abs(log1p_ref
- log1p)
54 call disp%show(
"getRankDense(inaccuracy)")
63 call disp%show(
"log1p_ref = log(1._RKH + real(x, RKH)) ! reference high-precision value for comparison")
64 log1p_ref
= log(
1._RKH + real(x,
RKH))
67 call disp%show(
"log1p = [log(1. + x), getLog1p(x)]")
71 call disp%show(
"inaccuracy = abs(log1p_ref - log1p)")
72 inaccuracy
= abs(log1p_ref
- log1p)
75 call disp%show(
"getRankDense(inaccuracy)")
84 call disp%show(
"log1p_ref = log(1._RKH + real(x, RKH)) ! reference high-precision value for comparison")
85 log1p_ref
= log(
1._RKH + real(x,
RKH))
88 call disp%show(
"log1p = [log(1. + x), getLog1p(x)]")
92 call disp%show(
"inaccuracy = abs(log1p_ref - log1p)")
93 inaccuracy
= abs(log1p_ref
- log1p)
96 call disp%show(
"getRankDense(inaccuracy)")
105 call disp%show(
"log1p_ref = log(1._RKH + real(x, RKH)) ! reference high-precision value for comparison")
106 log1p_ref
= log(
1._RKH + real(x,
RKH))
109 call disp%show(
"log1p = [log(1. + x), getLog1p(x)]")
113 call disp%show(
"inaccuracy = abs(log1p_ref - log1p)")
114 inaccuracy
= abs(log1p_ref
- log1p)
117 call disp%show(
"getRankDense(inaccuracy)")
122 call disp%show(
"x = -sqrt(tiny(x))")
126 call disp%show(
"log1p_ref = log(1._RKH + real(x, RKH)) ! reference high-precision value for comparison")
127 log1p_ref
= log(
1._RKH + real(x,
RKH))
130 call disp%show(
"log1p = [log(1. + x), getLog1p(x)]")
134 call disp%show(
"inaccuracy = abs(log1p_ref - log1p)")
135 inaccuracy
= abs(log1p_ref
- log1p)
138 call disp%show(
"getRankDense(inaccuracy)")
145 call disp%show(
"[log(1._RKH + tiny(0._RKH)), getLog1p(tiny(0._RKH))]")
152 call disp%show(
"[log(1._RKH - tiny(0._RKH)), getLog1p(-tiny(0._RKH))]")
Generate and return the Dense rank of the input scalar string or contiguous array of rank 1 in ascend...
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
This module contains procedures and generic interfaces for obtaining various rankings of elements of ...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
integer, parameter RKH
The scalar integer constant of intrinsic default kind, representing the highest-precision real kind t...
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
3log1p_ref
= log(
1._RKH + real(x,
RKH))
5+0.641853873624048428757248807764032325
8+0.641853869,
+0.641853869
9inaccuracy
= abs(log1p_ref
- log1p)
11+0.466271420024162380776403232463151234E-8,
+0.466271420024162380776403232463151234E-8
19log1p_ref
= log(
1._RKH + real(x,
RKH))
21+0.119209282445354457087579157062530716E-6
24+0.119209282E-6,
+0.119209282E-6
25inaccuracy
= abs(log1p_ref
- log1p)
27+0.564688581015773773391555126390782510E-21,
+0.564688581015773773391555126390782510E-21
35log1p_ref
= log(
1._RKH + real(x,
RKH))
37+0.596046429990338561858253177370804989E-7
40+0.00000000,
+0.596046448E-7
41inaccuracy
= abs(log1p_ref
- log1p)
43+0.596046429990338561858253177370804989E-7,
+0.177635676881417468226291950107140174E-14
51log1p_ref
= log(
1._RKH + real(x,
RKH))
53-0.596046465517475349863325579799436107E-7
56-0.596046448E-7,
-0.596046448E-7
57inaccuracy
= abs(log1p_ref
- log1p)
59+0.177635690998633255797994361065338507E-14,
+0.177635690998633255797994361065338507E-14
67log1p_ref
= log(
1._RKH + real(x,
RKH))
69+0.108420217248550443394867808332882734E-18
72+0.00000000,
+0.108420217E-18
73inaccuracy
= abs(log1p_ref
- log1p)
75+0.108420217248550443394867808332882734E-18,
+0.587747175411143753984368268611122839E-38
83log1p_ref
= log(
1._RKH + real(x,
RKH))
85-0.108420217248550443406622751841105609E-18
88+0.00000000,
-0.108420217E-18
89inaccuracy
= abs(log1p_ref
- log1p)
91+0.108420217248550443406622751841105609E-18,
+0.587747175411143753984368268611122839E-38
97+0.336210314311209350626267781732175260E-4931
98[
log(
1._RKH + tiny(
0._RKH)),
getLog1p(
tiny(
0._RKH))]
99+0.00000000000000000000000000000000000,
+0.336210314311209350626267781732175260E-4931
103+0.336210314311209350626267781732175260E-4931
104[
log(
1._RKH - tiny(
0._RKH)),
getLog1p(
-tiny(
0._RKH))]
105+0.00000000000000000000000000000000000,
-0.336210314311209350626267781732175260E-4931
- Test:
- test_pm_mathLog1p
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
-
If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
-
If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
- Copyright
- Computational Data Science Lab
- Author:
- Amir Shahmoradi, Thursday 1:45 AM, August 22, 2019, Dallas, TX
Definition at line 136 of file pm_mathLog1p.F90.