(FPCore (x) :precision binary64 (log (+ x (sqrt (+ (* x x) 1.0)))))
(FPCore (x)
:precision binary64
(if (<= x -8.787849164671579)
(log (/ -0.5 x))
(if (<= x 2.0878989945823202e-20)
(fma -0.16666666666666666 (pow x 3.0) x)
(+ (log 2.0) (log x)))))double code(double x) {
return log((x + sqrt(((x * x) + 1.0))));
}
double code(double x) {
double tmp;
if (x <= -8.787849164671579) {
tmp = log((-0.5 / x));
} else if (x <= 2.0878989945823202e-20) {
tmp = fma(-0.16666666666666666, pow(x, 3.0), x);
} else {
tmp = log(2.0) + log(x);
}
return tmp;
}
function code(x) return log(Float64(x + sqrt(Float64(Float64(x * x) + 1.0)))) end
function code(x) tmp = 0.0 if (x <= -8.787849164671579) tmp = log(Float64(-0.5 / x)); elseif (x <= 2.0878989945823202e-20) tmp = fma(-0.16666666666666666, (x ^ 3.0), x); else tmp = Float64(log(2.0) + log(x)); end return tmp end
code[x_] := N[Log[N[(x + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := If[LessEqual[x, -8.787849164671579], N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.0878989945823202e-20], N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision] + x), $MachinePrecision], N[(N[Log[2.0], $MachinePrecision] + N[Log[x], $MachinePrecision]), $MachinePrecision]]]
\log \left(x + \sqrt{x \cdot x + 1}\right)
\begin{array}{l}
\mathbf{if}\;x \leq -8.787849164671579:\\
\;\;\;\;\log \left(\frac{-0.5}{x}\right)\\
\mathbf{elif}\;x \leq 2.0878989945823202 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\log 2 + \log x\\
\end{array}




Bits error versus x
| Original | 52.5 |
|---|---|
| Target | 45.2 |
| Herbie | 1.4 |
if x < -8.78784916467157906Initial program 63.1
Simplified63.1
Taylor expanded in x around -inf 0.4
if -8.78784916467157906 < x < 2.0878989945823202e-20Initial program 59.4
Simplified59.4
Taylor expanded in x around 0 0.2
Simplified0.2
if 2.0878989945823202e-20 < x Initial program 31.1
Simplified1.8
Taylor expanded in x around inf 4.4
Simplified4.4
Final simplification1.4
herbie shell --seed 2022178
(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)))))