
(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 14 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
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -1.0)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= t_0 0.05000000074505806)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
x)
(copysign (* 2.0 (log (sqrt (+ x (hypot 1.0 x))))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -1.0f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.05000000074505806f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf((2.0f * logf(sqrtf((x + hypotf(1.0f, x))))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-1.0)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (t_0 <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(0.075) * (x ^ Float32(5.0))))), x); else tmp = copysign(Float32(Float32(2.0) * log(sqrt(Float32(x + hypot(Float32(1.0), x))))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-1.0)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.05000000074505806)) tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + (single(0.075) * (x ^ single(5.0)))))); else tmp = sign(x) * abs((single(2.0) * log(sqrt((x + hypot(single(1.0), x)))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t\_0 \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \log \left(\sqrt{x + \mathsf{hypot}\left(1, x\right)}\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -1Initial program 49.4%
flip-+7.5%
frac-2neg7.5%
log-div7.5%
pow27.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.5%
add-sqr-sqrt7.3%
fma-def6.7%
Applied egg-rr10.3%
fma-udef10.8%
unpow210.8%
associate--r+46.0%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-in98.5%
remove-double-neg98.5%
sub-neg98.5%
Simplified98.5%
expm1-log1p-u-0.0%
expm1-udef-0.0%
add-sqr-sqrt-0.0%
sqrt-unprod-0.0%
sqr-neg-0.0%
sqrt-unprod-0.0%
add-sqr-sqrt-0.0%
Applied egg-rr-0.0%
expm1-def-0.0%
expm1-log1p98.5%
Simplified98.5%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0500000007Initial program 22.5%
+-commutative22.5%
hypot-1-def22.6%
flip-+22.3%
hypot-1-def22.4%
hypot-1-def22.3%
add-sqr-sqrt22.6%
+-commutative22.6%
hypot-1-def22.5%
+-commutative22.5%
div-sub22.6%
Applied egg-rr22.5%
div-sub22.7%
fma-udef22.7%
unpow222.7%
associate--r+22.7%
+-inverses22.7%
metadata-eval22.7%
Simplified22.7%
Taylor expanded in x around 0 100.0%
if 0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 52.4%
add-sqr-sqrt52.3%
pow252.3%
log-pow52.5%
+-commutative52.5%
hypot-1-def98.5%
add-sqr-sqrt98.5%
fabs-sqr98.5%
add-sqr-sqrt98.5%
Applied egg-rr98.5%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.05000000074505806)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ (fabs x) (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(0.075) * (x ^ Float32(5.0))))), x); else tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + (single(0.075) * (x ^ single(5.0)))))); else tmp = sign(x) * abs(log((abs(x) + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
flip-+7.5%
frac-2neg7.5%
log-div7.5%
pow27.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.5%
add-sqr-sqrt7.3%
fma-def6.7%
Applied egg-rr10.3%
fma-udef10.8%
unpow210.8%
associate--r+46.0%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-in98.5%
remove-double-neg98.5%
sub-neg98.5%
Simplified98.5%
expm1-log1p-u-0.0%
expm1-udef-0.0%
add-sqr-sqrt-0.0%
sqrt-unprod-0.0%
sqr-neg-0.0%
sqrt-unprod-0.0%
add-sqr-sqrt-0.0%
Applied egg-rr-0.0%
expm1-def-0.0%
expm1-log1p98.5%
Simplified98.5%
if -1 < x < 0.0500000007Initial program 22.5%
+-commutative22.5%
hypot-1-def22.6%
flip-+22.3%
hypot-1-def22.4%
hypot-1-def22.3%
add-sqr-sqrt22.6%
+-commutative22.6%
hypot-1-def22.5%
+-commutative22.5%
div-sub22.6%
Applied egg-rr22.5%
div-sub22.7%
fma-udef22.7%
unpow222.7%
associate--r+22.7%
+-inverses22.7%
metadata-eval22.7%
Simplified22.7%
Taylor expanded in x around 0 100.0%
if 0.0500000007 < x Initial program 52.4%
+-commutative52.4%
hypot-1-def98.5%
Simplified98.5%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.05000000074505806)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(0.075) * (x ^ Float32(5.0))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + (single(0.075) * (x ^ single(5.0)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
flip-+7.5%
frac-2neg7.5%
log-div7.5%
pow27.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.5%
add-sqr-sqrt7.3%
fma-def6.7%
Applied egg-rr10.3%
fma-udef10.8%
unpow210.8%
associate--r+46.0%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-in98.5%
remove-double-neg98.5%
sub-neg98.5%
Simplified98.5%
expm1-log1p-u-0.0%
expm1-udef-0.0%
add-sqr-sqrt-0.0%
sqrt-unprod-0.0%
sqr-neg-0.0%
sqrt-unprod-0.0%
add-sqr-sqrt-0.0%
Applied egg-rr-0.0%
expm1-def-0.0%
expm1-log1p98.5%
Simplified98.5%
if -1 < x < 0.0500000007Initial program 22.5%
+-commutative22.5%
hypot-1-def22.6%
flip-+22.3%
hypot-1-def22.4%
hypot-1-def22.3%
add-sqr-sqrt22.6%
+-commutative22.6%
hypot-1-def22.5%
+-commutative22.5%
div-sub22.6%
Applied egg-rr22.5%
div-sub22.7%
fma-udef22.7%
unpow222.7%
associate--r+22.7%
+-inverses22.7%
metadata-eval22.7%
Simplified22.7%
Taylor expanded in x around 0 100.0%
if 0.0500000007 < x Initial program 52.4%
Taylor expanded in x around 0 52.4%
unpow252.4%
hypot-1-def98.5%
rem-square-sqrt98.5%
fabs-sqr98.5%
rem-square-sqrt98.5%
Simplified98.5%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / x))), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) - (single(0.5) / x)))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
flip-+7.5%
frac-2neg7.5%
log-div7.5%
pow27.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.5%
add-sqr-sqrt7.3%
fma-def6.7%
Applied egg-rr10.3%
fma-udef10.8%
unpow210.8%
associate--r+46.0%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-in98.5%
remove-double-neg98.5%
sub-neg98.5%
Simplified98.5%
Taylor expanded in x around -inf 97.0%
*-commutative97.0%
associate-*r/97.0%
metadata-eval97.0%
Simplified97.0%
if -1 < x < 0.0500000007Initial program 22.5%
+-commutative22.5%
hypot-1-def22.6%
flip-+22.3%
hypot-1-def22.4%
hypot-1-def22.3%
add-sqr-sqrt22.6%
+-commutative22.6%
hypot-1-def22.5%
+-commutative22.5%
div-sub22.6%
Applied egg-rr22.5%
div-sub22.7%
fma-udef22.7%
unpow222.7%
associate--r+22.7%
+-inverses22.7%
metadata-eval22.7%
Simplified22.7%
Taylor expanded in x around 0 99.8%
if 0.0500000007 < x Initial program 52.4%
Taylor expanded in x around 0 52.4%
unpow252.4%
hypot-1-def98.5%
rem-square-sqrt98.5%
fabs-sqr98.5%
rem-square-sqrt98.5%
Simplified98.5%
Final simplification98.8%
(FPCore (x)
:precision binary32
(if (<= x -0.03999999910593033)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.03999999910593033f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.03999999910593033)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.03999999910593033)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.03999999910593033:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.0399999991Initial program 50.8%
flip-+9.9%
frac-2neg9.9%
log-div9.9%
pow29.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.9%
add-sqr-sqrt9.8%
fma-def9.3%
Applied egg-rr12.8%
fma-udef13.3%
unpow213.3%
associate--r+47.5%
+-inverses98.4%
metadata-eval98.4%
metadata-eval98.4%
metadata-eval98.4%
neg-sub098.4%
sub-neg98.4%
+-commutative98.4%
distribute-neg-in98.4%
remove-double-neg98.4%
sub-neg98.4%
Simplified98.4%
expm1-log1p-u2.9%
expm1-udef3.0%
add-sqr-sqrt-0.0%
sqrt-unprod3.0%
sqr-neg3.0%
sqrt-unprod3.0%
add-sqr-sqrt3.0%
Applied egg-rr3.0%
expm1-def2.9%
expm1-log1p98.4%
Simplified98.4%
if -0.0399999991 < x < 0.0500000007Initial program 21.4%
+-commutative21.4%
hypot-1-def21.5%
flip-+21.3%
hypot-1-def21.4%
hypot-1-def21.3%
add-sqr-sqrt21.5%
+-commutative21.5%
hypot-1-def21.4%
+-commutative21.4%
div-sub21.4%
Applied egg-rr21.4%
div-sub21.6%
fma-udef21.6%
unpow221.6%
associate--r+21.6%
+-inverses21.6%
metadata-eval21.6%
Simplified21.6%
Taylor expanded in x around 0 99.9%
if 0.0500000007 < x Initial program 52.4%
Taylor expanded in x around 0 52.4%
unpow252.4%
hypot-1-def98.5%
rem-square-sqrt98.5%
fabs-sqr98.5%
rem-square-sqrt98.5%
Simplified98.5%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
Taylor expanded in x around 0 49.4%
unpow249.4%
hypot-1-def98.5%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt12.5%
Simplified12.5%
Taylor expanded in x around -inf 96.8%
if -1 < x < 1Initial program 24.2%
+-commutative24.2%
hypot-1-def24.3%
flip-+24.0%
hypot-1-def24.1%
hypot-1-def24.0%
add-sqr-sqrt24.3%
+-commutative24.3%
hypot-1-def24.2%
+-commutative24.2%
div-sub24.2%
Applied egg-rr24.2%
div-sub24.3%
fma-udef24.3%
unpow224.3%
associate--r+24.4%
+-inverses24.4%
metadata-eval24.4%
Simplified24.4%
Taylor expanded in x around 0 98.5%
if 1 < x Initial program 50.2%
Taylor expanded in x around inf 98.0%
associate-+r+98.0%
+-commutative98.0%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.0%
associate-*r/98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in x around 0 98.8%
Final simplification98.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / x))), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) - (single(0.5) / x)))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
flip-+7.5%
frac-2neg7.5%
log-div7.5%
pow27.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.5%
add-sqr-sqrt7.3%
fma-def6.7%
Applied egg-rr10.3%
fma-udef10.8%
unpow210.8%
associate--r+46.0%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-sub098.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-in98.5%
remove-double-neg98.5%
sub-neg98.5%
Simplified98.5%
Taylor expanded in x around -inf 97.0%
*-commutative97.0%
associate-*r/97.0%
metadata-eval97.0%
Simplified97.0%
if -1 < x < 1Initial program 24.2%
+-commutative24.2%
hypot-1-def24.3%
flip-+24.0%
hypot-1-def24.1%
hypot-1-def24.0%
add-sqr-sqrt24.3%
+-commutative24.3%
hypot-1-def24.2%
+-commutative24.2%
div-sub24.2%
Applied egg-rr24.2%
div-sub24.3%
fma-udef24.3%
unpow224.3%
associate--r+24.4%
+-inverses24.4%
metadata-eval24.4%
Simplified24.4%
Taylor expanded in x around 0 98.5%
if 1 < x Initial program 50.2%
Taylor expanded in x around inf 98.0%
associate-+r+98.0%
+-commutative98.0%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.0%
associate-*r/98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in x around 0 98.8%
Final simplification98.2%
(FPCore (x) :precision binary32 (if (<= x -20.0) (copysign 14.333333333333334 x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(14.333333333333334f, x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-20.0)) tmp = copysign(Float32(14.333333333333334), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-20.0)) tmp = sign(x) * abs(single(14.333333333333334)); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -20:\\
\;\;\;\;\mathsf{copysign}\left(14.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -20Initial program 46.9%
Taylor expanded in x around inf 6.2%
associate-+r+-0.0%
+-commutative-0.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
associate-*r/-0.0%
metadata-eval-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified26.6%
if -20 < x < 1Initial program 25.9%
Taylor expanded in x around 0 20.6%
log1p-def91.1%
rem-square-sqrt43.9%
fabs-sqr43.9%
rem-square-sqrt90.3%
Simplified90.3%
Taylor expanded in x around 0 95.2%
if 1 < x Initial program 50.2%
Taylor expanded in x around inf 97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
Simplified97.3%
Final simplification79.6%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
Taylor expanded in x around 0 49.4%
unpow249.4%
hypot-1-def98.5%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt12.5%
Simplified12.5%
Taylor expanded in x around -inf 96.8%
if -1 < x < 1Initial program 24.2%
Taylor expanded in x around 0 20.3%
log1p-def92.4%
rem-square-sqrt44.9%
fabs-sqr44.9%
rem-square-sqrt92.4%
Simplified92.4%
Taylor expanded in x around 0 96.7%
if 1 < x Initial program 50.2%
Taylor expanded in x around inf 97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
Simplified97.3%
Final simplification96.9%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
Taylor expanded in x around 0 49.4%
unpow249.4%
hypot-1-def98.5%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt12.5%
Simplified12.5%
Taylor expanded in x around -inf 96.8%
if -1 < x < 1Initial program 24.2%
Taylor expanded in x around 0 20.3%
log1p-def92.4%
rem-square-sqrt44.9%
fabs-sqr44.9%
rem-square-sqrt92.4%
Simplified92.4%
Taylor expanded in x around 0 96.7%
if 1 < x Initial program 50.2%
Taylor expanded in x around inf 98.0%
associate-+r+98.0%
+-commutative98.0%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.0%
associate-*r/98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in x around 0 98.8%
Final simplification97.2%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign 14.333333333333334 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(14.333333333333334f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(14.333333333333334), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(14.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
Taylor expanded in x around inf 5.9%
associate-+r+-0.0%
+-commutative-0.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
associate-*r/-0.0%
metadata-eval-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified26.5%
if -1 < x Initial program 32.6%
Taylor expanded in x around 0 28.1%
log1p-def77.1%
rem-square-sqrt44.8%
fabs-sqr44.8%
rem-square-sqrt77.1%
Simplified77.1%
Final simplification64.6%
(FPCore (x) :precision binary32 (if (or (<= x -20.0) (not (<= x 5.0))) (copysign 14.333333333333334 x) (copysign x x)))
float code(float x) {
float tmp;
if ((x <= -20.0f) || !(x <= 5.0f)) {
tmp = copysignf(14.333333333333334f, x);
} else {
tmp = copysignf(x, x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if ((x <= Float32(-20.0)) || !(x <= Float32(5.0))) tmp = copysign(Float32(14.333333333333334), x); else tmp = copysign(x, x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if ((x <= single(-20.0)) || ~((x <= single(5.0)))) tmp = sign(x) * abs(single(14.333333333333334)); else tmp = sign(x) * abs(x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -20 \lor \neg \left(x \leq 5\right):\\
\;\;\;\;\mathsf{copysign}\left(14.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\end{array}
\end{array}
if x < -20 or 5 < x Initial program 48.2%
Taylor expanded in x around inf 52.7%
associate-+r+49.6%
+-commutative49.6%
rem-square-sqrt49.6%
fabs-sqr49.6%
rem-square-sqrt49.6%
associate-*r/49.6%
metadata-eval49.6%
Simplified49.6%
Taylor expanded in x around 0 0.8%
Simplified26.7%
if -20 < x < 5Initial program 26.5%
Taylor expanded in x around 0 20.7%
log1p-def90.6%
rem-square-sqrt43.8%
fabs-sqr43.8%
rem-square-sqrt89.9%
Simplified89.9%
Taylor expanded in x around 0 94.7%
Final simplification62.5%
(FPCore (x) :precision binary32 (copysign -7.0 x))
float code(float x) {
return copysignf(-7.0f, x);
}
function code(x) return copysign(Float32(-7.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-7.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-7, x\right)
\end{array}
Initial program 36.7%
Taylor expanded in x around inf 28.0%
associate-+r+26.5%
+-commutative26.5%
rem-square-sqrt26.5%
fabs-sqr26.5%
rem-square-sqrt26.5%
associate-*r/26.5%
metadata-eval26.5%
Simplified26.5%
Taylor expanded in x around 0 3.6%
Simplified17.4%
Final simplification17.4%
(FPCore (x) :precision binary32 (copysign 14.333333333333334 x))
float code(float x) {
return copysignf(14.333333333333334f, x);
}
function code(x) return copysign(Float32(14.333333333333334), x) end
function tmp = code(x) tmp = sign(x) * abs(single(14.333333333333334)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(14.333333333333334, x\right)
\end{array}
Initial program 36.7%
Taylor expanded in x around inf 28.0%
associate-+r+26.5%
+-commutative26.5%
rem-square-sqrt26.5%
fabs-sqr26.5%
rem-square-sqrt26.5%
associate-*r/26.5%
metadata-eval26.5%
Simplified26.5%
Taylor expanded in x around 0 3.1%
Simplified18.3%
Final simplification18.3%
(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 2024031
(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))