
(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 6 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 (log1p x) x))
float code(float x) {
return copysignf(log1pf(x), x);
}
function code(x) return copysign(log1p(x), x) end
\begin{array}{l}
\\
\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)
\end{array}
Initial program 38.2%
Taylor expanded in x around 0 16.3%
log1p-def52.9%
Simplified52.9%
unpow252.9%
*-un-lft-identity52.9%
times-frac53.2%
+-commutative53.2%
add-sqr-sqrt28.0%
fabs-sqr28.0%
add-sqr-sqrt52.9%
Applied egg-rr52.9%
Taylor expanded in x around 0 31.3%
log1p-def67.4%
unpow167.4%
sqr-pow35.5%
fabs-sqr35.5%
sqr-pow57.6%
unpow157.6%
Simplified57.6%
Final simplification57.6%
(FPCore (x) :precision binary32 (copysign (log (+ x (hypot 1.0 x))) x))
float code(float x) {
return copysignf(logf((x + hypotf(1.0f, x))), x);
}
function code(x) return copysign(log(Float32(x + hypot(Float32(1.0), x))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)
\end{array}
Initial program 38.2%
*-un-lft-identity38.2%
*-commutative38.2%
log-prod38.2%
*-un-lft-identity38.2%
*-un-lft-identity38.2%
add-sqr-sqrt22.6%
fabs-sqr22.6%
add-sqr-sqrt30.8%
+-commutative30.8%
hypot-1-def43.7%
metadata-eval43.7%
Applied egg-rr43.7%
+-rgt-identity43.7%
Simplified43.7%
Final simplification43.7%
(FPCore (x) :precision binary32 (copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))
float code(float x) {
return copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
}
function code(x) return copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x) end
function tmp = code(x) tmp = sign(x) * abs(log(((x * single(2.0)) + (single(0.5) * (single(1.0) / x))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)
\end{array}
Initial program 38.2%
*-un-lft-identity38.2%
*-commutative38.2%
log-prod38.2%
*-un-lft-identity38.2%
*-un-lft-identity38.2%
add-sqr-sqrt22.6%
fabs-sqr22.6%
add-sqr-sqrt30.8%
+-commutative30.8%
hypot-1-def43.7%
metadata-eval43.7%
Applied egg-rr43.7%
+-rgt-identity43.7%
Simplified43.7%
Taylor expanded in x around inf 31.4%
Final simplification31.4%
(FPCore (x) :precision binary32 (copysign (log (* x 2.0)) x))
float code(float x) {
return copysignf(logf((x * 2.0f)), x);
}
function code(x) return copysign(log(Float32(x * Float32(2.0))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((x * single(2.0)))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)
\end{array}
Initial program 38.2%
*-un-lft-identity38.2%
*-commutative38.2%
log-prod38.2%
*-un-lft-identity38.2%
*-un-lft-identity38.2%
add-sqr-sqrt22.6%
fabs-sqr22.6%
add-sqr-sqrt30.8%
+-commutative30.8%
hypot-1-def43.7%
metadata-eval43.7%
Applied egg-rr43.7%
+-rgt-identity43.7%
Simplified43.7%
Taylor expanded in x around inf 30.7%
*-commutative30.7%
Simplified30.7%
Final simplification30.7%
(FPCore (x) :precision binary32 (copysign (log x) x))
float code(float x) {
return copysignf(logf(x), x);
}
function code(x) return copysign(log(x), x) end
function tmp = code(x) tmp = sign(x) * abs(log(x)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log x, x\right)
\end{array}
Initial program 38.2%
Taylor expanded in x around inf 15.6%
mul-1-neg15.6%
log-rec15.6%
remove-double-neg15.6%
Simplified15.6%
Final simplification15.6%
(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 38.2%
*-un-lft-identity38.2%
*-commutative38.2%
log-prod38.2%
*-un-lft-identity38.2%
*-un-lft-identity38.2%
add-sqr-sqrt22.6%
fabs-sqr22.6%
add-sqr-sqrt30.8%
+-commutative30.8%
hypot-1-def43.7%
metadata-eval43.7%
Applied egg-rr43.7%
+-rgt-identity43.7%
Simplified43.7%
Taylor expanded in x around 0 52.6%
Final simplification52.6%
(FPCore (x) :precision binary32 (let* ((t_0 (/ 1.0 (fabs x)))) (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
float t_0 = 1.0f / fabsf(x);
return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x) t_0 = Float32(Float32(1.0) / abs(x)) return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t\_0\right) + t\_0}\right), x\right)
\end{array}
\end{array}
herbie shell --seed 2024033
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:herbie-target
(copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 (/ 1.0 (fabs x))) (/ 1.0 (fabs x)))))) x)
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))