\log \left(x + \sqrt{x \cdot x + 1}\right)\begin{array}{l}
\mathbf{if}\;x \leq -1.330733025502329 \cdot 10^{+154}:\\
\;\;\;\;\log \left(\frac{-1}{x}\right)\\
\mathbf{elif}\;x \leq -0.005692362598187211:\\
\;\;\;\;\log \left(\frac{-1}{x - \sqrt{x \cdot x + 1}}\right)\\
\mathbf{elif}\;x \leq 1.352819344293148 \cdot 10^{+154}:\\
\;\;\;\;\log \left(\frac{-1}{\frac{-1}{x + \sqrt{x \cdot x + 1}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\log x\\
\end{array}(FPCore (x) :precision binary64 (log (+ x (sqrt (+ (* x x) 1.0)))))
(FPCore (x)
:precision binary64
(if (<= x -1.330733025502329e+154)
(log (/ -1.0 x))
(if (<= x -0.005692362598187211)
(log (/ -1.0 (- x (sqrt (+ (* x x) 1.0)))))
(if (<= x 1.352819344293148e+154)
(log (/ -1.0 (/ -1.0 (+ x (sqrt (+ (* x x) 1.0))))))
(log x)))))double code(double x) {
return log(x + sqrt((x * x) + 1.0));
}
double code(double x) {
double tmp;
if (x <= -1.330733025502329e+154) {
tmp = log(-1.0 / x);
} else if (x <= -0.005692362598187211) {
tmp = log(-1.0 / (x - sqrt((x * x) + 1.0)));
} else if (x <= 1.352819344293148e+154) {
tmp = log(-1.0 / (-1.0 / (x + sqrt((x * x) + 1.0))));
} else {
tmp = log(x);
}
return tmp;
}




Bits error versus x
Results
| Original | 53.5 |
|---|---|
| Target | 45.6 |
| Herbie | 40.4 |
if x < -1.33073302550232894e154Initial program 64.0
rmApplied flip-+_binary64_173264.0
Simplified64.0
Taylor expanded around 0 42.9
if -1.33073302550232894e154 < x < -0.005692362598187211Initial program 61.1
rmApplied flip-+_binary64_173260.6
Simplified0.1
if -0.005692362598187211 < x < 1.35281934429314794e154Initial program 47.7
rmApplied flip-+_binary64_173259.5
Simplified59.5
rmApplied flip--_binary64_173359.5
Simplified47.8
if 1.35281934429314794e154 < x Initial program 64.0
Taylor expanded around 0 42.9
Final simplification40.4
herbie shell --seed 2020270
(FPCore (x)
:name "Hyperbolic arcsine"
:precision binary64
:herbie-target
(if (< x 0.0) (log (/ -1.0 (- x (sqrt (+ (* x x) 1.0))))) (log (+ x (sqrt (+ (* x x) 1.0)))))
(log (+ x (sqrt (+ (* x x) 1.0)))))