
(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 11 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.05000000074505806)
(copysign (log (/ 1.0 (- (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 (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.05000000074505806f) {
tmp = copysignf(logf((1.0f / (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(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.05000000074505806)) tmp = copysign(log(Float32(Float32(1.0) / 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(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.05000000074505806)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (t_0 <= single(0.05000000074505806)) 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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\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(\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.0500000007Initial program 53.9%
+-commutative53.9%
hypot-1-def99.8%
Simplified99.8%
flip-+15.0%
div-sub14.8%
pow214.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.8%
pow214.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.3%
hypot-udef5.3%
hypot-udef5.3%
add-sqr-sqrt5.3%
metadata-eval5.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt17.2%
Applied egg-rr17.2%
unpow217.2%
div-sub19.1%
unpow219.1%
unpow219.1%
unpow219.1%
+-commutative19.1%
associate--r+50.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-/r*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
if -0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0500000007Initial program 19.6%
+-commutative19.6%
hypot-1-def19.6%
Simplified19.6%
flip-+19.5%
clear-num19.5%
add-sqr-sqrt11.4%
fabs-sqr11.4%
add-sqr-sqrt19.7%
pow219.7%
add-sqr-sqrt11.4%
fabs-sqr11.4%
add-sqr-sqrt19.7%
pow219.7%
hypot-udef19.7%
hypot-udef19.6%
add-sqr-sqrt19.7%
metadata-eval19.7%
Applied egg-rr19.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 50.8%
+-commutative50.8%
hypot-1-def98.8%
Simplified98.8%
*-un-lft-identity98.8%
log-prod98.8%
metadata-eval98.8%
*-un-lft-identity98.8%
*-un-lft-identity98.8%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.8%
Applied egg-rr98.8%
+-lft-identity98.8%
Simplified98.8%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -1.5)
(copysign (- (log (* x -2.0))) 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.5f) {
tmp = copysignf(-logf((x * -2.0f)), 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.5)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), 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.5)) tmp = sign(x) * abs(-log((x * single(-2.0)))); 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.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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 < -1.5Initial program 49.3%
+-commutative49.3%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.9%
associate--l+98.8%
unpow198.8%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow10.8%
unpow110.8%
associate-+r-97.5%
mul-1-neg97.5%
sub-neg97.5%
+-inverses97.5%
neg-sub097.5%
associate-*r/97.5%
metadata-eval97.5%
distribute-neg-frac97.5%
metadata-eval97.5%
Simplified97.5%
clear-num97.5%
log-div97.5%
metadata-eval97.5%
div-inv97.5%
metadata-eval97.5%
Applied egg-rr97.5%
neg-sub097.5%
Simplified97.5%
if -1.5 < x < 0.0500000007Initial program 22.5%
+-commutative22.5%
hypot-1-def22.6%
Simplified22.6%
flip-+22.4%
clear-num22.4%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt22.7%
pow222.7%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt22.7%
pow222.7%
hypot-udef22.7%
hypot-udef22.6%
add-sqr-sqrt22.8%
metadata-eval22.8%
Applied egg-rr22.8%
Taylor expanded in x around 0 98.2%
if 0.0500000007 < x Initial program 50.8%
+-commutative50.8%
hypot-1-def98.8%
Simplified98.8%
*-un-lft-identity98.8%
log-prod98.8%
metadata-eval98.8%
*-un-lft-identity98.8%
*-un-lft-identity98.8%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.8%
Applied egg-rr98.8%
+-lft-identity98.8%
Simplified98.8%
Final simplification98.3%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (log (/ 1.0 (- (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.05000000074505806f) {
tmp = copysignf(logf((1.0f / (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.05000000074505806)) tmp = copysign(log(Float32(Float32(1.0) / 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.05000000074505806)) tmp = sign(x) * abs(log((single(1.0) / (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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\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.0500000007Initial program 53.9%
+-commutative53.9%
hypot-1-def99.8%
Simplified99.8%
flip-+15.0%
div-sub14.8%
pow214.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.8%
pow214.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt5.3%
hypot-udef5.3%
hypot-udef5.3%
add-sqr-sqrt5.3%
metadata-eval5.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt17.2%
Applied egg-rr17.2%
unpow217.2%
div-sub19.1%
unpow219.1%
unpow219.1%
unpow219.1%
+-commutative19.1%
associate--r+50.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-/r*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
if -0.0500000007 < x < 0.0500000007Initial program 19.6%
+-commutative19.6%
hypot-1-def19.6%
Simplified19.6%
flip-+19.5%
clear-num19.5%
add-sqr-sqrt11.4%
fabs-sqr11.4%
add-sqr-sqrt19.7%
pow219.7%
add-sqr-sqrt11.4%
fabs-sqr11.4%
add-sqr-sqrt19.7%
pow219.7%
hypot-udef19.7%
hypot-udef19.6%
add-sqr-sqrt19.7%
metadata-eval19.7%
Applied egg-rr19.7%
Taylor expanded in x around 0 100.0%
if 0.0500000007 < x Initial program 50.8%
+-commutative50.8%
hypot-1-def98.8%
Simplified98.8%
*-un-lft-identity98.8%
log-prod98.8%
metadata-eval98.8%
*-un-lft-identity98.8%
*-un-lft-identity98.8%
add-sqr-sqrt98.7%
fabs-sqr98.7%
add-sqr-sqrt98.8%
Applied egg-rr98.8%
+-lft-identity98.8%
Simplified98.8%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -1.5)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (+ x (/ 0.5 x)))) x))))
float code(float x) {
float tmp;
if (x <= -1.5f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + (x + (0.5f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.5)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + Float32(x + Float32(Float32(0.5) / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.5)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + (x + (single(0.5) / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1.5Initial program 49.3%
+-commutative49.3%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.9%
associate--l+98.8%
unpow198.8%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow10.8%
unpow110.8%
associate-+r-97.5%
mul-1-neg97.5%
sub-neg97.5%
+-inverses97.5%
neg-sub097.5%
associate-*r/97.5%
metadata-eval97.5%
distribute-neg-frac97.5%
metadata-eval97.5%
Simplified97.5%
clear-num97.5%
log-div97.5%
metadata-eval97.5%
div-inv97.5%
metadata-eval97.5%
Applied egg-rr97.5%
neg-sub097.5%
Simplified97.5%
if -1.5 < x < 0.200000003Initial program 23.1%
+-commutative23.1%
hypot-1-def23.2%
Simplified23.2%
flip-+22.9%
clear-num22.9%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt23.2%
pow223.2%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt23.2%
pow223.2%
hypot-udef23.2%
hypot-udef23.1%
add-sqr-sqrt23.4%
metadata-eval23.4%
Applied egg-rr23.4%
Taylor expanded in x around 0 98.1%
if 0.200000003 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def98.8%
Simplified98.8%
Taylor expanded in x around inf 98.8%
associate-+r+98.8%
+-commutative98.8%
+-commutative98.8%
unpow198.8%
sqr-pow98.7%
fabs-sqr98.7%
sqr-pow98.8%
unpow198.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
Final simplification98.2%
(FPCore (x)
:precision binary32
(if (<= x -1.5)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.5f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.20000000298023224f) {
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(-1.5)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.20000000298023224)) 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(-1.5)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.20000000298023224)) 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 -1.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\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 < -1.5Initial program 49.3%
+-commutative49.3%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.9%
associate--l+98.8%
unpow198.8%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow10.8%
unpow110.8%
associate-+r-97.5%
mul-1-neg97.5%
sub-neg97.5%
+-inverses97.5%
neg-sub097.5%
associate-*r/97.5%
metadata-eval97.5%
distribute-neg-frac97.5%
metadata-eval97.5%
Simplified97.5%
clear-num97.5%
log-div97.5%
metadata-eval97.5%
div-inv97.5%
metadata-eval97.5%
Applied egg-rr97.5%
neg-sub097.5%
Simplified97.5%
if -1.5 < x < 0.200000003Initial program 23.1%
+-commutative23.1%
hypot-1-def23.2%
Simplified23.2%
flip-+22.9%
clear-num22.9%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt23.2%
pow223.2%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt23.2%
pow223.2%
hypot-udef23.2%
hypot-udef23.1%
add-sqr-sqrt23.4%
metadata-eval23.4%
Applied egg-rr23.4%
Taylor expanded in x around 0 98.1%
if 0.200000003 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def98.8%
Simplified98.8%
Taylor expanded in x around inf 97.1%
unpow197.1%
sqr-pow97.1%
fabs-sqr97.1%
sqr-pow97.1%
unpow197.1%
Simplified97.1%
Final simplification97.7%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (- x)) x) (if (<= x 0.20000000298023224) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.20000000298023224)) 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(-10.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(0.20000000298023224)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 48.3%
+-commutative48.3%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.6%
mul-1-neg44.6%
Simplified44.6%
if -10 < x < 0.200000003Initial program 23.7%
+-commutative23.7%
hypot-1-def23.7%
Simplified23.7%
flip-+23.4%
clear-num23.4%
add-sqr-sqrt11.5%
fabs-sqr11.5%
add-sqr-sqrt23.7%
pow223.7%
add-sqr-sqrt11.5%
fabs-sqr11.5%
add-sqr-sqrt23.7%
pow223.7%
hypot-udef23.8%
hypot-udef23.7%
add-sqr-sqrt23.9%
metadata-eval23.9%
Applied egg-rr23.9%
Taylor expanded in x around 0 95.9%
if 0.200000003 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def98.8%
Simplified98.8%
Taylor expanded in x around inf 97.1%
unpow197.1%
sqr-pow97.1%
fabs-sqr97.1%
sqr-pow97.1%
unpow197.1%
Simplified97.1%
Final simplification86.8%
(FPCore (x) :precision binary32 (if (<= x -1.5) (copysign (log (/ -0.5 x)) x) (if (<= x 0.20000000298023224) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.5f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.5)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) 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.5)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) 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.5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1.5Initial program 49.3%
+-commutative49.3%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.9%
associate--l+98.8%
unpow198.8%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow10.8%
unpow110.8%
associate-+r-97.5%
mul-1-neg97.5%
sub-neg97.5%
+-inverses97.5%
neg-sub097.5%
associate-*r/97.5%
metadata-eval97.5%
distribute-neg-frac97.5%
metadata-eval97.5%
Simplified97.5%
if -1.5 < x < 0.200000003Initial program 23.1%
+-commutative23.1%
hypot-1-def23.2%
Simplified23.2%
flip-+22.9%
clear-num22.9%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt23.2%
pow223.2%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt23.2%
pow223.2%
hypot-udef23.2%
hypot-udef23.1%
add-sqr-sqrt23.4%
metadata-eval23.4%
Applied egg-rr23.4%
Taylor expanded in x around 0 96.4%
if 0.200000003 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def98.8%
Simplified98.8%
Taylor expanded in x around inf 97.1%
unpow197.1%
sqr-pow97.1%
fabs-sqr97.1%
sqr-pow97.1%
unpow197.1%
Simplified97.1%
Final simplification96.8%
(FPCore (x) :precision binary32 (if (<= x -1.5) (copysign (- (log (* x -2.0))) x) (if (<= x 0.20000000298023224) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.5f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.5)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.20000000298023224)) 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.5)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.20000000298023224)) 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.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1.5Initial program 49.3%
+-commutative49.3%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 98.9%
associate--l+98.8%
unpow198.8%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow10.8%
unpow110.8%
associate-+r-97.5%
mul-1-neg97.5%
sub-neg97.5%
+-inverses97.5%
neg-sub097.5%
associate-*r/97.5%
metadata-eval97.5%
distribute-neg-frac97.5%
metadata-eval97.5%
Simplified97.5%
clear-num97.5%
log-div97.5%
metadata-eval97.5%
div-inv97.5%
metadata-eval97.5%
Applied egg-rr97.5%
neg-sub097.5%
Simplified97.5%
if -1.5 < x < 0.200000003Initial program 23.1%
+-commutative23.1%
hypot-1-def23.2%
Simplified23.2%
flip-+22.9%
clear-num22.9%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt23.2%
pow223.2%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt23.2%
pow223.2%
hypot-udef23.2%
hypot-udef23.1%
add-sqr-sqrt23.4%
metadata-eval23.4%
Applied egg-rr23.4%
Taylor expanded in x around 0 96.4%
if 0.200000003 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def98.8%
Simplified98.8%
Taylor expanded in x around inf 97.1%
unpow197.1%
sqr-pow97.1%
fabs-sqr97.1%
sqr-pow97.1%
unpow197.1%
Simplified97.1%
Final simplification96.8%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(-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(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 51.3%
+-commutative51.3%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around -inf 43.3%
mul-1-neg43.3%
Simplified43.3%
if -1 < x Initial program 32.2%
+-commutative32.2%
hypot-1-def50.0%
Simplified50.0%
Taylor expanded in x around 0 28.1%
log1p-def76.2%
unpow176.2%
sqr-pow50.4%
fabs-sqr50.4%
sqr-pow76.1%
unpow176.1%
Simplified76.1%
Final simplification69.7%
(FPCore (x) :precision binary32 (if (<= x 0.20000000298023224) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.20000000298023224)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 0.200000003Initial program 30.1%
+-commutative30.1%
hypot-1-def43.5%
Simplified43.5%
flip-+18.5%
clear-num18.5%
add-sqr-sqrt8.5%
fabs-sqr8.5%
add-sqr-sqrt19.9%
pow219.9%
add-sqr-sqrt8.5%
fabs-sqr8.5%
add-sqr-sqrt19.9%
pow219.9%
hypot-udef19.9%
hypot-udef19.8%
add-sqr-sqrt20.0%
metadata-eval20.0%
Applied egg-rr20.0%
Taylor expanded in x around 0 73.8%
if 0.200000003 < x Initial program 50.1%
+-commutative50.1%
hypot-1-def98.8%
Simplified98.8%
Taylor expanded in x around 0 44.7%
log1p-def44.7%
unpow144.7%
sqr-pow44.7%
fabs-sqr44.7%
sqr-pow44.7%
unpow144.7%
Simplified44.7%
Final simplification65.3%
(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 35.9%
+-commutative35.9%
hypot-1-def59.7%
Simplified59.7%
flip-+15.0%
clear-num15.0%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt15.9%
pow215.9%
add-sqr-sqrt8.0%
fabs-sqr8.0%
add-sqr-sqrt15.9%
pow215.9%
hypot-udef15.9%
hypot-udef15.8%
add-sqr-sqrt15.9%
metadata-eval15.9%
Applied egg-rr15.9%
Taylor expanded in x around 0 55.4%
Final simplification55.4%
(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 2023187
(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))