
(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 -1.0)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.05000000074505806)
(copysign
(fma
(fma -0.16666666666666666 (pow x 3.0) (* 0.075 (pow x 5.0)))
1.0
x)
x)
(copysign (log1p (+ -1.0 (+ 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(fmaf(fmaf(-0.16666666666666666f, powf(x, 3.0f), (0.075f * powf(x, 5.0f))), 1.0f, x), x);
} else {
tmp = copysignf(log1pf((-1.0f + (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(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.05000000074505806)) tmp = copysign(fma(fma(Float32(-0.16666666666666666), (x ^ Float32(3.0)), Float32(Float32(0.075) * (x ^ Float32(5.0)))), Float32(1.0), x), x); else tmp = copysign(log1p(Float32(Float32(-1.0) + Float32(x + hypot(Float32(1.0), x)))), x); end return 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(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, {x}^{3}, 0.075 \cdot {x}^{5}\right), 1, x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-1 + \left(x + \mathsf{hypot}\left(1, x\right)\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 56.9%
flip-+8.8%
clear-num8.8%
log-rec8.8%
+-commutative8.8%
hypot-1-def8.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.9%
sqr-abs9.9%
add-sqr-sqrt11.1%
+-commutative11.1%
Applied egg-rr11.1%
div-inv11.1%
log-prod-0.0%
Applied egg-rr-0.0%
fma-udef-0.0%
associate-+r--0.0%
+-commutative-0.0%
associate-+l--0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
associate-+l--0.0%
+-commutative-0.0%
associate-+r--0.0%
fma-udef-0.0%
+-commutative-0.0%
Simplified100.0%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0500000007Initial program 24.3%
*-un-lft-identity24.3%
*-commutative24.3%
log-prod24.3%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt24.5%
+-commutative24.5%
hypot-1-def24.5%
metadata-eval24.5%
Applied egg-rr24.5%
Taylor expanded in x around 0 100.0%
*-un-lft-identity100.0%
associate-+r+100.0%
distribute-rgt-in100.0%
*-commutative100.0%
*-un-lft-identity100.0%
fma-def100.0%
fma-def100.0%
Applied egg-rr100.0%
if 0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 57.7%
log1p-expm1-u57.7%
expm1-udef57.7%
add-exp-log57.7%
add-sqr-sqrt57.7%
fabs-sqr57.7%
add-sqr-sqrt57.7%
+-commutative57.7%
hypot-1-def99.9%
Applied egg-rr99.9%
Final simplification100.0%
(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
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log1p (+ -1.0 (+ 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(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(log1pf((-1.0f + (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(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.05000000074505806)) 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(log1p(Float32(Float32(-1.0) + Float32(x + hypot(Float32(1.0), x)))), x); end return 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(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-1 + \left(x + \mathsf{hypot}\left(1, x\right)\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 56.9%
flip-+8.8%
clear-num8.8%
log-rec8.8%
+-commutative8.8%
hypot-1-def8.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.9%
sqr-abs9.9%
add-sqr-sqrt11.1%
+-commutative11.1%
Applied egg-rr11.1%
div-inv11.1%
log-prod-0.0%
Applied egg-rr-0.0%
fma-udef-0.0%
associate-+r--0.0%
+-commutative-0.0%
associate-+l--0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
associate-+l--0.0%
+-commutative-0.0%
associate-+r--0.0%
fma-udef-0.0%
+-commutative-0.0%
Simplified100.0%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0500000007Initial program 24.3%
*-un-lft-identity24.3%
*-commutative24.3%
log-prod24.3%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt24.5%
+-commutative24.5%
hypot-1-def24.5%
metadata-eval24.5%
Applied egg-rr24.5%
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 57.7%
log1p-expm1-u57.7%
expm1-udef57.7%
add-exp-log57.7%
add-sqr-sqrt57.7%
fabs-sqr57.7%
add-sqr-sqrt57.7%
+-commutative57.7%
hypot-1-def99.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log1p (+ -1.0 (+ x (hypot 1.0 x)))) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x - (powf(x, 3.0f) * 0.16666666666666666f)), x);
} else {
tmp = copysignf(log1pf((-1.0f + (x + hypotf(1.0f, x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x - Float32((x ^ Float32(3.0)) * Float32(0.16666666666666666))), x); else tmp = copysign(log1p(Float32(Float32(-1.0) + Float32(x + hypot(Float32(1.0), x)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05000000074505806:\\
\;\;\;\;\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 - {x}^{3} \cdot 0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-1 + \left(x + \mathsf{hypot}\left(1, x\right)\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 58.0%
flip-+11.3%
clear-num11.3%
log-rec11.3%
+-commutative11.3%
hypot-1-def11.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.5%
sqr-abs12.5%
add-sqr-sqrt13.6%
+-commutative13.6%
Applied egg-rr13.6%
div-inv13.6%
log-prod-0.0%
Applied egg-rr-0.0%
fma-udef-0.0%
associate-+r--0.0%
+-commutative-0.0%
associate-+l--0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
associate-+l--0.0%
+-commutative-0.0%
associate-+r--0.0%
fma-udef-0.0%
+-commutative-0.0%
Simplified99.8%
if -0.0500000007 < x < 0.0500000007Initial program 23.3%
flip-+23.1%
clear-num23.1%
log-rec23.2%
+-commutative23.2%
hypot-1-def23.1%
add-sqr-sqrt8.2%
fabs-sqr8.2%
add-sqr-sqrt22.9%
sqr-abs22.9%
add-sqr-sqrt23.2%
+-commutative23.2%
Applied egg-rr23.4%
Taylor expanded in x around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
*-commutative100.0%
Simplified100.0%
if 0.0500000007 < x Initial program 57.7%
log1p-expm1-u57.7%
expm1-udef57.7%
add-exp-log57.7%
add-sqr-sqrt57.7%
fabs-sqr57.7%
add-sqr-sqrt57.7%
+-commutative57.7%
hypot-1-def99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.800000011920929)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.800000011920929f) {
tmp = copysignf((x - (powf(x, 3.0f) * 0.16666666666666666f)), x);
} else {
tmp = copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.800000011920929)) tmp = copysign(Float32(x - Float32((x ^ Float32(3.0)) * Float32(0.16666666666666666))), x); else tmp = copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.800000011920929)) tmp = sign(x) * abs((x - ((x ^ single(3.0)) * single(0.16666666666666666)))); else tmp = sign(x) * abs(log(((x * single(2.0)) + (single(0.5) * (single(1.0) / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.800000011920929:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 58.0%
flip-+11.3%
clear-num11.3%
log-rec11.3%
+-commutative11.3%
hypot-1-def11.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.5%
sqr-abs12.5%
add-sqr-sqrt13.6%
+-commutative13.6%
Applied egg-rr13.6%
div-inv13.6%
log-prod-0.0%
Applied egg-rr-0.0%
fma-udef-0.0%
associate-+r--0.0%
+-commutative-0.0%
associate-+l--0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
associate-+l--0.0%
+-commutative-0.0%
associate-+r--0.0%
fma-udef-0.0%
+-commutative-0.0%
Simplified99.8%
if -0.0500000007 < x < 0.800000012Initial program 23.8%
flip-+23.6%
clear-num23.6%
log-rec23.8%
+-commutative23.8%
hypot-1-def23.7%
add-sqr-sqrt8.9%
fabs-sqr8.9%
add-sqr-sqrt23.5%
sqr-abs23.5%
add-sqr-sqrt23.8%
+-commutative23.8%
Applied egg-rr24.0%
Taylor expanded in x around 0 99.5%
neg-mul-199.5%
unsub-neg99.5%
*-commutative99.5%
Simplified99.5%
if 0.800000012 < x Initial program 57.1%
*-un-lft-identity57.1%
*-commutative57.1%
log-prod57.1%
add-sqr-sqrt57.0%
fabs-sqr57.0%
add-sqr-sqrt57.1%
+-commutative57.1%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.0%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.800000011920929)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / x))), x);
} else if (x <= 0.800000011920929f) {
tmp = copysignf((x - (powf(x, 3.0f) * 0.16666666666666666f)), x);
} else {
tmp = copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(0.800000011920929)) tmp = copysign(Float32(x - Float32((x ^ Float32(3.0)) * Float32(0.16666666666666666))), x); else tmp = copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) - (single(0.5) / x)))); elseif (x <= single(0.800000011920929)) tmp = sign(x) * abs((x - ((x ^ single(3.0)) * single(0.16666666666666666)))); else tmp = sign(x) * abs(log(((x * single(2.0)) + (single(0.5) * (single(1.0) / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.800000011920929:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 56.9%
flip-+8.8%
clear-num8.8%
log-rec8.8%
+-commutative8.8%
hypot-1-def8.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.9%
sqr-abs9.9%
add-sqr-sqrt11.1%
+-commutative11.1%
Applied egg-rr11.1%
div-inv11.1%
log-prod-0.0%
Applied egg-rr-0.0%
fma-udef-0.0%
associate-+r--0.0%
+-commutative-0.0%
associate-+l--0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
associate-+l--0.0%
+-commutative-0.0%
associate-+r--0.0%
fma-udef-0.0%
+-commutative-0.0%
Simplified100.0%
Taylor expanded in x around -inf 98.7%
*-commutative98.7%
associate-*r/98.7%
metadata-eval98.7%
Simplified98.7%
if -2 < x < 0.800000012Initial program 24.9%
flip-+24.7%
clear-num24.7%
log-rec24.8%
+-commutative24.8%
hypot-1-def24.7%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt24.6%
sqr-abs24.6%
add-sqr-sqrt24.8%
+-commutative24.8%
Applied egg-rr25.0%
Taylor expanded in x around 0 99.3%
neg-mul-199.3%
unsub-neg99.3%
*-commutative99.3%
Simplified99.3%
if 0.800000012 < x Initial program 57.1%
*-un-lft-identity57.1%
*-commutative57.1%
log-prod57.1%
add-sqr-sqrt57.0%
fabs-sqr57.0%
add-sqr-sqrt57.1%
+-commutative57.1%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.0%
Final simplification99.1%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x - (powf(x, 3.0f) * 0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x - Float32((x ^ Float32(3.0)) * Float32(0.16666666666666666))), x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x - ((x ^ single(3.0)) * single(0.16666666666666666)))); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 56.9%
*-un-lft-identity56.9%
*-commutative56.9%
log-prod56.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.3%
+-commutative14.3%
hypot-1-def14.3%
metadata-eval14.3%
Applied egg-rr14.3%
Taylor expanded in x around -inf 96.7%
if -2 < x < 1Initial program 25.4%
flip-+25.2%
clear-num25.2%
log-rec25.3%
+-commutative25.3%
hypot-1-def25.2%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt25.1%
sqr-abs25.1%
add-sqr-sqrt25.3%
+-commutative25.3%
Applied egg-rr25.5%
Taylor expanded in x around 0 98.9%
neg-mul-198.9%
unsub-neg98.9%
*-commutative98.9%
Simplified98.9%
if 1 < x Initial program 56.4%
*-un-lft-identity56.4%
*-commutative56.4%
log-prod56.4%
add-sqr-sqrt56.3%
fabs-sqr56.3%
add-sqr-sqrt56.4%
+-commutative56.4%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.5%
*-commutative98.5%
Simplified98.5%
Final simplification98.2%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 1.0)
(copysign (- x (* (pow x 3.0) 0.16666666666666666)) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / x))), x);
} else if (x <= 1.0f) {
tmp = copysignf((x - (powf(x, 3.0f) * 0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.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((x ^ Float32(3.0)) * Float32(0.16666666666666666))), x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(-log(((x * single(-2.0)) - (single(0.5) / x)))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x - ((x ^ single(3.0)) * single(0.16666666666666666)))); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x - {x}^{3} \cdot 0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 56.9%
flip-+8.8%
clear-num8.8%
log-rec8.8%
+-commutative8.8%
hypot-1-def8.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.9%
sqr-abs9.9%
add-sqr-sqrt11.1%
+-commutative11.1%
Applied egg-rr11.1%
div-inv11.1%
log-prod-0.0%
Applied egg-rr-0.0%
fma-udef-0.0%
associate-+r--0.0%
+-commutative-0.0%
associate-+l--0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
associate-+l--0.0%
+-commutative-0.0%
associate-+r--0.0%
fma-udef-0.0%
+-commutative-0.0%
Simplified100.0%
Taylor expanded in x around -inf 98.7%
*-commutative98.7%
associate-*r/98.7%
metadata-eval98.7%
Simplified98.7%
if -2 < x < 1Initial program 25.4%
flip-+25.2%
clear-num25.2%
log-rec25.3%
+-commutative25.3%
hypot-1-def25.2%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt25.1%
sqr-abs25.1%
add-sqr-sqrt25.3%
+-commutative25.3%
Applied egg-rr25.5%
Taylor expanded in x around 0 98.9%
neg-mul-198.9%
unsub-neg98.9%
*-commutative98.9%
Simplified98.9%
if 1 < x Initial program 56.4%
*-un-lft-identity56.4%
*-commutative56.4%
log-prod56.4%
add-sqr-sqrt56.3%
fabs-sqr56.3%
add-sqr-sqrt56.4%
+-commutative56.4%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.5%
*-commutative98.5%
Simplified98.5%
Final simplification98.7%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (- (log (* x -2.0))) x) (if (<= x 1.0) (copysign x x) (copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf((x * -2.0f)), 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(-2.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(Float32(-log(Float32(Float32(0.5) / x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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 < -2Initial program 56.9%
flip-+8.8%
clear-num8.8%
log-rec8.8%
+-commutative8.8%
hypot-1-def8.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.9%
sqr-abs9.9%
add-sqr-sqrt11.1%
+-commutative11.1%
Applied egg-rr11.1%
div-inv11.1%
log-prod-0.0%
Applied egg-rr-0.0%
fma-udef-0.0%
associate-+r--0.0%
+-commutative-0.0%
associate-+l--0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
associate-+l--0.0%
+-commutative-0.0%
associate-+r--0.0%
fma-udef-0.0%
+-commutative-0.0%
Simplified100.0%
Taylor expanded in x around -inf 96.7%
*-commutative96.7%
Simplified96.7%
if -2 < x < 1Initial program 25.4%
*-un-lft-identity25.4%
*-commutative25.4%
log-prod25.4%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt25.6%
+-commutative25.6%
hypot-1-def25.6%
metadata-eval25.6%
Applied egg-rr25.6%
Taylor expanded in x around 0 96.6%
if 1 < x Initial program 56.4%
flip-+7.9%
clear-num7.9%
log-rec7.9%
+-commutative7.9%
hypot-1-def7.5%
add-sqr-sqrt8.0%
fabs-sqr8.0%
add-sqr-sqrt7.5%
sqr-abs7.5%
add-sqr-sqrt7.3%
+-commutative7.3%
Applied egg-rr7.3%
div-inv7.3%
log-prod-0.0%
Applied egg-rr-0.0%
fma-udef-0.0%
associate-+r--0.0%
+-commutative-0.0%
associate-+l--0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
associate-+l-2.7%
+-commutative2.7%
associate-+r-2.7%
fma-udef2.7%
+-commutative2.7%
Simplified13.0%
Taylor expanded in x around inf 98.4%
Final simplification97.1%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (- (log (* x -2.0))) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 56.9%
flip-+8.8%
clear-num8.8%
log-rec8.8%
+-commutative8.8%
hypot-1-def8.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.9%
sqr-abs9.9%
add-sqr-sqrt11.1%
+-commutative11.1%
Applied egg-rr11.1%
div-inv11.1%
log-prod-0.0%
Applied egg-rr-0.0%
fma-udef-0.0%
associate-+r--0.0%
+-commutative-0.0%
associate-+l--0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
associate-+l--0.0%
+-commutative-0.0%
associate-+r--0.0%
fma-udef-0.0%
+-commutative-0.0%
Simplified100.0%
Taylor expanded in x around -inf 96.7%
*-commutative96.7%
Simplified96.7%
if -2 < x < 1Initial program 25.4%
*-un-lft-identity25.4%
*-commutative25.4%
log-prod25.4%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt25.6%
+-commutative25.6%
hypot-1-def25.6%
metadata-eval25.6%
Applied egg-rr25.6%
Taylor expanded in x around 0 96.6%
if 1 < x Initial program 56.4%
*-un-lft-identity56.4%
*-commutative56.4%
log-prod56.4%
add-sqr-sqrt56.3%
fabs-sqr56.3%
add-sqr-sqrt56.4%
+-commutative56.4%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.5%
*-commutative98.5%
Simplified98.5%
Final simplification97.1%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.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 * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.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 * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\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 \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 56.9%
*-un-lft-identity56.9%
*-commutative56.9%
log-prod56.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.3%
+-commutative14.3%
hypot-1-def14.3%
metadata-eval14.3%
Applied egg-rr14.3%
Taylor expanded in x around -inf 96.7%
if -2 < x < 1Initial program 25.4%
*-un-lft-identity25.4%
*-commutative25.4%
log-prod25.4%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt25.6%
+-commutative25.6%
hypot-1-def25.6%
metadata-eval25.6%
Applied egg-rr25.6%
Taylor expanded in x around 0 96.6%
if 1 < x Initial program 56.4%
*-un-lft-identity56.4%
*-commutative56.4%
log-prod56.4%
add-sqr-sqrt56.3%
fabs-sqr56.3%
add-sqr-sqrt56.4%
+-commutative56.4%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.5%
*-commutative98.5%
Simplified98.5%
Final simplification97.1%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (- (log (* x -2.0))) x) (copysign x x)))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else {
tmp = copysignf(x, x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); else tmp = copysign(x, x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); else tmp = sign(x) * abs(x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\end{array}
\end{array}
if x < -2Initial program 56.9%
flip-+8.8%
clear-num8.8%
log-rec8.8%
+-commutative8.8%
hypot-1-def8.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.9%
sqr-abs9.9%
add-sqr-sqrt11.1%
+-commutative11.1%
Applied egg-rr11.1%
div-inv11.1%
log-prod-0.0%
Applied egg-rr-0.0%
fma-udef-0.0%
associate-+r--0.0%
+-commutative-0.0%
associate-+l--0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
associate-+l--0.0%
+-commutative-0.0%
associate-+r--0.0%
fma-udef-0.0%
+-commutative-0.0%
Simplified100.0%
Taylor expanded in x around -inf 96.7%
*-commutative96.7%
Simplified96.7%
if -2 < x Initial program 35.0%
*-un-lft-identity35.0%
*-commutative35.0%
log-prod35.0%
add-sqr-sqrt24.0%
fabs-sqr24.0%
add-sqr-sqrt35.2%
+-commutative35.2%
hypot-1-def48.8%
metadata-eval48.8%
Applied egg-rr48.8%
Taylor expanded in x around 0 70.2%
Final simplification76.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 40.4%
*-un-lft-identity40.4%
*-commutative40.4%
log-prod40.4%
add-sqr-sqrt18.1%
fabs-sqr18.1%
add-sqr-sqrt30.1%
+-commutative30.1%
hypot-1-def40.3%
metadata-eval40.3%
Applied egg-rr40.3%
Taylor expanded in x around 0 55.9%
Final simplification55.9%
(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 2023279
(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))