\log \left(x + \sqrt{x \cdot x + 1}\right)
\begin{array}{l}
\mathbf{if}\;x \leq -1.1457422521714031:\\
\;\;\;\;\log \left(\frac{0.125}{{x}^{3}} + \frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 1.3153391522167552:\\
\;\;\;\;\left(x + 0.075 \cdot {x}^{5}\right) - {x}^{3} \cdot 0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + x\right)\\
\end{array}
(FPCore (x) :precision binary64 (log (+ x (sqrt (+ (* x x) 1.0)))))
(FPCore (x)
:precision binary64
(if (<= x -1.1457422521714031)
(log (+ (/ 0.125 (pow x 3.0)) (/ -0.5 x)))
(if (<= x 1.3153391522167552)
(- (+ x (* 0.075 (pow x 5.0))) (* (pow x 3.0) 0.16666666666666666))
(log (+ x x)))))double code(double x) {
return log(x + sqrt((x * x) + 1.0));
}
double code(double x) {
double tmp;
if (x <= -1.1457422521714031) {
tmp = log((0.125 / pow(x, 3.0)) + (-0.5 / x));
} else if (x <= 1.3153391522167552) {
tmp = (x + (0.075 * pow(x, 5.0))) - (pow(x, 3.0) * 0.16666666666666666);
} else {
tmp = log(x + x);
}
return tmp;
}




Bits error versus x
Results
| Original | 52.5 |
|---|---|
| Target | 44.9 |
| Herbie | 0.3 |
if x < -1.1457422521714031Initial program 62.9
Simplified62.9
Taylor expanded in x around -inf 0.3
Simplified0.3
if -1.1457422521714031 < x < 1.31533915221675524Initial program 58.6
Simplified58.6
Taylor expanded in x around 0 0.2
if 1.31533915221675524 < x Initial program 30.7
Simplified0.0
Applied add-log-exp_binary6463.5
Applied add-log-exp_binary6463.5
Applied sum-log_binary6463.5
Simplified63.5
Taylor expanded in x around inf 0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2022087
(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)))))