\log \left(x + \sqrt{x \cdot x + 1}\right)
\begin{array}{l}
\mathbf{if}\;x \leq -0.9682457514610505:\\
\;\;\;\;\log \left(\left(\frac{0.125}{{x}^{3}} - \left(\frac{0.5}{x} + \frac{0.0625}{{x}^{5}}\right)\right) + \frac{0.0390625}{{x}^{7}}\right)\\
\mathbf{elif}\;x \leq 0.0011232502346767796:\\
\;\;\;\;\mathsf{fma}\left({x}^{3}, -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \log \left(\sqrt{x + \mathsf{hypot}\left(1, x\right)}\right)\\
t_0 + t_0
\end{array}\\
\end{array}
(FPCore (x) :precision binary64 (log (+ x (sqrt (+ (* x x) 1.0)))))
(FPCore (x)
:precision binary64
(if (<= x -0.9682457514610505)
(log
(+
(- (/ 0.125 (pow x 3.0)) (+ (/ 0.5 x) (/ 0.0625 (pow x 5.0))))
(/ 0.0390625 (pow x 7.0))))
(if (<= x 0.0011232502346767796)
(fma (pow x 3.0) -0.16666666666666666 x)
(let* ((t_0 (log (sqrt (+ x (hypot 1.0 x)))))) (+ t_0 t_0)))))double code(double x) {
return log(x + sqrt((x * x) + 1.0));
}
double code(double x) {
double tmp;
if (x <= -0.9682457514610505) {
tmp = log(((0.125 / pow(x, 3.0)) - ((0.5 / x) + (0.0625 / pow(x, 5.0)))) + (0.0390625 / pow(x, 7.0)));
} else if (x <= 0.0011232502346767796) {
tmp = fma(pow(x, 3.0), -0.16666666666666666, x);
} else {
double t_0 = log(sqrt(x + hypot(1.0, x)));
tmp = t_0 + t_0;
}
return tmp;
}




Bits error versus x
| Original | 53.4 |
|---|---|
| Target | 46.0 |
| Herbie | 0.1 |
if x < -0.96824575146105052Initial program 62.8
Simplified62.8
Taylor expanded in x around -inf 0.1
Simplified0.1
if -0.96824575146105052 < x < 0.00112325023467677964Initial program 58.9
Simplified58.9
Taylor expanded in x around 0 0.2
Simplified0.2
if 0.00112325023467677964 < x Initial program 32.9
Simplified0.0
Applied add-sqr-sqrt_binary640.1
Applied log-prod_binary640.1
Final simplification0.1
herbie shell --seed 2022088
(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)))))