
(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 12 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 -0.4000000059604645)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.019999999552965164)
(copysign
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* 0.075 (pow x 5.0)) (+ x (* -0.044642857142857144 (pow x 7.0)))))
x)
(copysign (log (+ 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 <= -0.4000000059604645f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.019999999552965164f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + ((0.075f * powf(x, 5.0f)) + (x + (-0.044642857142857144f * powf(x, 7.0f))))), x);
} else {
tmp = copysignf(logf((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(-0.4000000059604645)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.019999999552965164)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(Float32(0.075) * (x ^ Float32(5.0))) + Float32(x + Float32(Float32(-0.044642857142857144) * (x ^ Float32(7.0)))))), x); else tmp = copysign(log(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(-0.4000000059604645)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.019999999552965164)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + ((single(0.075) * (x ^ single(5.0))) + (x + (single(-0.044642857142857144) * (x ^ single(7.0))))))); else tmp = sign(x) * abs(log((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 -0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(0.075 \cdot {x}^{5} + \left(x + -0.044642857142857144 \cdot {x}^{7}\right)\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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.400000006Initial program 43.8%
+-commutative43.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.6%
flip-+11.8%
log-div11.9%
add-sqr-sqrt13.5%
fma-def14.0%
+-commutative14.0%
hypot-1-def14.0%
Applied egg-rr14.0%
fma-udef13.5%
+-commutative13.5%
associate--l+39.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
if -0.400000006 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0199999996Initial program 21.2%
*-un-lft-identity21.2%
*-commutative21.2%
log-prod21.2%
add-sqr-sqrt8.9%
fabs-sqr8.9%
add-sqr-sqrt21.5%
+-commutative21.5%
hypot-1-def21.5%
metadata-eval21.5%
Applied egg-rr21.5%
+-rgt-identity21.5%
Simplified21.5%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 47.6%
*-un-lft-identity47.6%
*-commutative47.6%
log-prod47.6%
add-sqr-sqrt47.6%
fabs-sqr47.6%
add-sqr-sqrt47.6%
+-commutative47.6%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.4000000059604645)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.019999999552965164)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ 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 <= -0.4000000059604645f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.019999999552965164f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf((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(-0.4000000059604645)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.019999999552965164)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(x + 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) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.4000000059604645)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.019999999552965164)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + (x + (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}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.400000006Initial program 43.8%
+-commutative43.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.6%
flip-+11.8%
log-div11.9%
add-sqr-sqrt13.5%
fma-def14.0%
+-commutative14.0%
hypot-1-def14.0%
Applied egg-rr14.0%
fma-udef13.5%
+-commutative13.5%
associate--l+39.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
if -0.400000006 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0199999996Initial program 21.2%
add-cbrt-cube21.2%
pow1/321.2%
log-pow21.2%
pow321.3%
log-pow21.2%
add-sqr-sqrt8.9%
fabs-sqr8.9%
add-sqr-sqrt21.5%
+-commutative21.5%
hypot-1-def21.5%
Applied egg-rr21.5%
Taylor expanded in x around 0 98.9%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 47.6%
*-un-lft-identity47.6%
*-commutative47.6%
log-prod47.6%
add-sqr-sqrt47.6%
fabs-sqr47.6%
add-sqr-sqrt47.6%
+-commutative47.6%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.019999999552965164)
(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 <= -5.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else if (x <= 0.019999999552965164f) {
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(-5.0)) tmp = copysign(log(Float32(abs(x) - x)), x); elseif (x <= Float32(0.019999999552965164)) 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(-5.0)) tmp = sign(x) * abs(log((abs(x) - x))); elseif (x <= single(0.019999999552965164)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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 < -5Initial program 41.9%
Taylor expanded in x around -inf 98.4%
neg-mul-198.4%
unsub-neg98.4%
Simplified98.4%
if -5 < x < 0.0199999996Initial program 22.5%
add-cbrt-cube22.5%
pow1/322.5%
log-pow22.4%
pow322.5%
log-pow22.5%
add-sqr-sqrt8.7%
fabs-sqr8.7%
add-sqr-sqrt22.7%
+-commutative22.7%
hypot-1-def22.7%
Applied egg-rr22.7%
Taylor expanded in x around 0 97.9%
+-commutative97.9%
distribute-lft-in97.8%
associate-*r*98.9%
metadata-eval98.9%
*-un-lft-identity98.9%
*-commutative98.9%
*-commutative98.9%
associate-*l*98.9%
metadata-eval98.9%
Applied egg-rr98.9%
if 0.0199999996 < x Initial program 47.6%
*-un-lft-identity47.6%
*-commutative47.6%
log-prod47.6%
add-sqr-sqrt47.6%
fabs-sqr47.6%
add-sqr-sqrt47.6%
+-commutative47.6%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.1%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.019999999552965164)
(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.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.019999999552965164f) {
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.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.019999999552965164)) 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.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.019999999552965164)) 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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.100000001Initial program 44.6%
+-commutative44.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.8%
flip-+13.1%
log-div13.1%
add-sqr-sqrt14.8%
fma-def15.3%
+-commutative15.3%
hypot-1-def15.2%
Applied egg-rr15.2%
fma-udef14.7%
+-commutative14.7%
associate--l+40.8%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
neg-sub099.8%
Simplified99.8%
if -0.100000001 < x < 0.0199999996Initial program 20.6%
add-cbrt-cube20.6%
pow1/320.6%
log-pow20.6%
pow320.7%
log-pow20.6%
add-sqr-sqrt8.9%
fabs-sqr8.9%
add-sqr-sqrt20.9%
+-commutative20.9%
hypot-1-def20.9%
Applied egg-rr20.9%
Taylor expanded in x around 0 98.9%
+-commutative98.9%
distribute-lft-in98.9%
associate-*r*100.0%
metadata-eval100.0%
*-un-lft-identity100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if 0.0199999996 < x Initial program 47.6%
*-un-lft-identity47.6%
*-commutative47.6%
log-prod47.6%
add-sqr-sqrt47.6%
fabs-sqr47.6%
add-sqr-sqrt47.6%
+-commutative47.6%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((fabsf(x) - 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 + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(abs(x) - 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(Float32(0.5) / x) + Float32(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-5.0)) tmp = sign(x) * abs(log((abs(x) - 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) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - 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} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 41.9%
Taylor expanded in x around -inf 98.4%
neg-mul-198.4%
unsub-neg98.4%
Simplified98.4%
if -5 < x < 1Initial program 23.1%
add-cbrt-cube23.1%
pow1/323.1%
log-pow23.0%
pow323.1%
log-pow23.1%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt23.3%
+-commutative23.3%
hypot-1-def23.3%
Applied egg-rr23.3%
Taylor expanded in x around 0 97.5%
+-commutative97.5%
distribute-lft-in97.4%
associate-*r*98.5%
metadata-eval98.5%
*-un-lft-identity98.5%
*-commutative98.5%
*-commutative98.5%
associate-*l*98.5%
metadata-eval98.5%
Applied egg-rr98.5%
if 1 < x Initial program 46.9%
Taylor expanded in x around inf 99.9%
associate-*r/99.9%
metadata-eval99.9%
rem-square-sqrt99.9%
fabs-sqr99.9%
rem-square-sqrt99.9%
Simplified99.9%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -5.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 x))) x))))
float code(float x) {
float tmp;
if (x <= -5.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 + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.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(Float32(0.5) / x) + Float32(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-5.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) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\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} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 41.9%
*-un-lft-identity41.9%
*-commutative41.9%
log-prod41.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.8%
+-commutative11.8%
hypot-1-def11.8%
metadata-eval11.8%
Applied egg-rr11.8%
+-rgt-identity11.8%
Simplified11.8%
Taylor expanded in x around -inf 98.4%
if -5 < x < 1Initial program 23.1%
add-cbrt-cube23.1%
pow1/323.1%
log-pow23.0%
pow323.1%
log-pow23.1%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt23.3%
+-commutative23.3%
hypot-1-def23.3%
Applied egg-rr23.3%
Taylor expanded in x around 0 97.5%
+-commutative97.5%
distribute-lft-in97.4%
associate-*r*98.5%
metadata-eval98.5%
*-un-lft-identity98.5%
*-commutative98.5%
*-commutative98.5%
associate-*l*98.5%
metadata-eval98.5%
Applied egg-rr98.5%
if 1 < x Initial program 46.9%
Taylor expanded in x around inf 99.9%
associate-*r/99.9%
metadata-eval99.9%
rem-square-sqrt99.9%
fabs-sqr99.9%
rem-square-sqrt99.9%
Simplified99.9%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -5.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((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.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(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-5.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((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\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(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 41.9%
*-un-lft-identity41.9%
*-commutative41.9%
log-prod41.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.8%
+-commutative11.8%
hypot-1-def11.8%
metadata-eval11.8%
Applied egg-rr11.8%
+-rgt-identity11.8%
Simplified11.8%
Taylor expanded in x around -inf 98.4%
if -5 < x < 1Initial program 23.1%
add-cbrt-cube23.1%
pow1/323.1%
log-pow23.0%
pow323.1%
log-pow23.1%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt23.3%
+-commutative23.3%
hypot-1-def23.3%
Applied egg-rr23.3%
Taylor expanded in x around 0 97.5%
+-commutative97.5%
distribute-lft-in97.4%
associate-*r*98.5%
metadata-eval98.5%
*-un-lft-identity98.5%
*-commutative98.5%
*-commutative98.5%
associate-*l*98.5%
metadata-eval98.5%
Applied egg-rr98.5%
if 1 < x Initial program 46.9%
Taylor expanded in x around inf 99.5%
rem-square-sqrt99.5%
fabs-sqr99.5%
rem-square-sqrt99.5%
Simplified99.5%
Final simplification98.8%
(FPCore (x) :precision binary32 (if (<= x -5.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 <= -5.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(-5.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(-5.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 -5:\\
\;\;\;\;\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 < -5Initial program 41.9%
*-un-lft-identity41.9%
*-commutative41.9%
log-prod41.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.8%
+-commutative11.8%
hypot-1-def11.8%
metadata-eval11.8%
Applied egg-rr11.8%
+-rgt-identity11.8%
Simplified11.8%
Taylor expanded in x around -inf 98.4%
if -5 < x < 1Initial program 23.1%
add-cbrt-cube23.1%
pow1/323.1%
log-pow23.0%
pow323.1%
log-pow23.1%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt23.3%
+-commutative23.3%
hypot-1-def23.3%
Applied egg-rr23.3%
Taylor expanded in x around 0 96.0%
*-commutative96.0%
Simplified96.0%
Taylor expanded in x around 0 97.0%
if 1 < x Initial program 46.9%
Taylor expanded in x around inf 99.5%
rem-square-sqrt99.5%
fabs-sqr99.5%
rem-square-sqrt99.5%
Simplified99.5%
Final simplification98.0%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (+ x 1.0)) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + 1.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + Float32(1.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + single(1.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + 1\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 29.1%
add-cbrt-cube25.5%
pow1/325.4%
log-pow25.4%
pow325.4%
log-pow29.0%
add-sqr-sqrt6.4%
fabs-sqr6.4%
add-sqr-sqrt19.6%
+-commutative19.6%
hypot-1-def19.7%
Applied egg-rr19.7%
Taylor expanded in x around 0 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in x around 0 69.4%
if 1 < x Initial program 46.9%
Taylor expanded in x around 0 45.1%
rem-square-sqrt45.1%
fabs-sqr45.1%
rem-square-sqrt45.1%
Simplified45.1%
Final simplification62.4%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
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(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(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(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 29.1%
add-cbrt-cube25.5%
pow1/325.4%
log-pow25.4%
pow325.4%
log-pow29.0%
add-sqr-sqrt6.4%
fabs-sqr6.4%
add-sqr-sqrt19.6%
+-commutative19.6%
hypot-1-def19.7%
Applied egg-rr19.7%
Taylor expanded in x around 0 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in x around 0 69.4%
if 1 < x Initial program 46.9%
Taylor expanded in x around inf 99.5%
rem-square-sqrt99.5%
fabs-sqr99.5%
rem-square-sqrt99.5%
Simplified99.5%
Final simplification78.1%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) tmp = copysign(x, 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(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 29.1%
add-cbrt-cube25.5%
pow1/325.4%
log-pow25.4%
pow325.4%
log-pow29.0%
add-sqr-sqrt6.4%
fabs-sqr6.4%
add-sqr-sqrt19.6%
+-commutative19.6%
hypot-1-def19.7%
Applied egg-rr19.7%
Taylor expanded in x around 0 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in x around 0 69.4%
if 1 < x Initial program 46.9%
Taylor expanded in x around 0 45.1%
log1p-def45.1%
rem-square-sqrt45.1%
fabs-sqr45.1%
rem-square-sqrt45.1%
Simplified45.1%
Final simplification62.4%
(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 34.2%
add-cbrt-cube27.7%
pow1/327.5%
log-pow27.5%
pow327.5%
log-pow34.1%
add-sqr-sqrt18.0%
fabs-sqr18.0%
add-sqr-sqrt27.4%
+-commutative27.4%
hypot-1-def42.6%
Applied egg-rr42.6%
Taylor expanded in x around 0 51.8%
*-commutative51.8%
Simplified51.8%
Taylor expanded in x around 0 52.3%
Final simplification52.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 2023199
(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))