(FPCore (x) :precision binary32 (asinh x))
float code(float x) { return asinhf(x); }
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l} \\ \sinh^{-1} x \end{array}
Sampling outcomes in binary32 precision:
Herbie found 2 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) { return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x); }
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l} \\ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \end{array}
(FPCore (x) :precision binary32 (copysign (asinh x) x))
float code(float x) { return copysignf(asinhf(x), x); }
function code(x) return copysign(asinh(x), x) end
function tmp = code(x) tmp = sign(x) * abs(asinh(x)); end
\begin{array}{l} \\ \mathsf{copysign}\left(\sinh^{-1} x, x\right) \end{array}
Initial program 32.3%
Applied rewrites99.7%
(FPCore (x) :precision binary32 (copysign x x))
float code(float x) { return copysignf(x, x); }
function code(x) return copysign(x, x) end
function tmp = code(x) tmp = sign(x) * abs(x); end
\begin{array}{l} \\ \mathsf{copysign}\left(x, x\right) \end{array}
Initial program 32.3%
Applied rewrites99.7%
Taylor expanded in x around 0
unpow1
54.1
metadata-eval
54.1
sqrt-pow1
54.1
pow2
54.1
rem-sqrt-square-rev
54.1
asinh-def-rev
54.1
sqr-abs-rev
54.1
pow2
54.1
+-commutative
54.1
+-commutative
54.1
pow2
54.1
Applied rewrites54.1%
herbie shell --seed 2025085
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))