
(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
(if (<= x -0.10000000149011612)
(copysign (log (/ 1.0 (- (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((1.0f / (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(log(Float32(Float32(1.0) / 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((single(1.0) / (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(\frac{1}{\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 56.9%
+-commutative56.9%
hypot-1-def99.8%
Simplified99.8%
flip-+11.1%
div-sub10.6%
pow210.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.6%
pow210.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt4.4%
hypot-udef4.4%
hypot-udef4.4%
add-sqr-sqrt4.4%
metadata-eval4.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.5%
Applied egg-rr13.5%
unpow213.5%
div-sub16.9%
unpow216.9%
unpow216.9%
unpow216.9%
+-commutative16.9%
associate--r+53.9%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
associate-/r*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
sub-neg99.8%
Simplified99.8%
if -0.100000001 < x < 0.0199999996Initial program 21.0%
+-commutative21.0%
hypot-1-def21.2%
Simplified21.2%
*-un-lft-identity21.2%
log-prod21.2%
metadata-eval21.2%
*-un-lft-identity21.2%
*-un-lft-identity21.2%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt21.6%
Applied egg-rr21.6%
+-lft-identity21.6%
Simplified21.6%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < x Initial program 57.6%
+-commutative57.6%
hypot-1-def99.7%
Simplified99.7%
*-un-lft-identity99.7%
log-prod99.7%
metadata-eval99.7%
*-un-lft-identity99.7%
*-un-lft-identity99.7%
add-sqr-sqrt99.6%
fabs-sqr99.6%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
+-lft-identity99.7%
Simplified99.7%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<=
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)
-0.009999999776482582)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
float tmp;
if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= -0.009999999776482582f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else {
tmp = copysignf(log1pf((x + (hypotf(1.0f, x) + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) <= Float32(-0.009999999776482582)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); else tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -0.009999999776482582:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(\mathsf{hypot}\left(1, x\right) + -1\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.00999999978Initial program 57.7%
+-commutative57.7%
hypot-1-def99.4%
Simplified99.4%
flip-+13.4%
div-sub12.9%
pow212.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.9%
pow212.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.2%
hypot-udef6.2%
hypot-udef6.2%
add-sqr-sqrt6.2%
metadata-eval6.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.7%
Applied egg-rr15.7%
unpow215.7%
div-sub19.2%
unpow219.2%
unpow219.2%
unpow219.2%
+-commutative19.2%
associate--r+55.0%
+-inverses99.5%
metadata-eval99.5%
metadata-eval99.5%
associate-/r*99.5%
neg-mul-199.5%
sub-neg99.5%
+-commutative99.5%
distribute-neg-in99.5%
remove-double-neg99.5%
sub-neg99.5%
Simplified99.5%
if -0.00999999978 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 35.5%
+-commutative35.5%
hypot-1-def53.1%
Simplified53.1%
expm1-log1p-u51.9%
expm1-udef52.0%
log1p-udef52.0%
add-exp-log53.1%
*-un-lft-identity53.1%
*-un-lft-identity53.1%
add-sqr-sqrt46.9%
fabs-sqr46.9%
add-sqr-sqrt53.2%
Applied egg-rr53.2%
log1p-expm1-u53.2%
log1p-udef53.2%
add-exp-log52.2%
log1p-udef52.2%
expm1-udef52.2%
expm1-log1p-u53.3%
expm1-udef53.3%
add-exp-log53.3%
Applied egg-rr53.3%
log1p-def53.3%
associate--l+98.2%
Simplified98.2%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ 1.0 (- (* x -2.0) (/ 0.5 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 <= -1.0f) {
tmp = copysignf(logf((1.0f / ((x * -2.0f) - (0.5f / 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(-1.0)) tmp = copysign(log(Float32(Float32(1.0) / Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / 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(-1.0)) tmp = sign(x) * abs(log((single(1.0) / ((x * single(-2.0)) - (single(0.5) / 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{x \cdot -2 - \frac{0.5}{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 < -1Initial program 55.6%
+-commutative55.6%
hypot-1-def100.0%
Simplified100.0%
flip-+8.3%
div-sub7.8%
pow27.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.8%
pow27.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt3.2%
hypot-udef3.2%
hypot-udef3.2%
add-sqr-sqrt3.2%
metadata-eval3.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
Applied egg-rr10.9%
unpow210.9%
div-sub14.4%
unpow214.4%
unpow214.4%
unpow214.4%
+-commutative14.4%
associate--r+52.5%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/r*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.0%
*-commutative99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
if -1 < x < 0.0199999996Initial program 22.3%
+-commutative22.3%
hypot-1-def22.4%
Simplified22.4%
*-un-lft-identity22.4%
log-prod22.4%
metadata-eval22.4%
*-un-lft-identity22.4%
*-un-lft-identity22.4%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt22.8%
Applied egg-rr22.8%
+-lft-identity22.8%
Simplified22.8%
Taylor expanded in x around 0 99.5%
if 0.0199999996 < x Initial program 57.6%
+-commutative57.6%
hypot-1-def99.7%
Simplified99.7%
*-un-lft-identity99.7%
log-prod99.7%
metadata-eval99.7%
*-un-lft-identity99.7%
*-un-lft-identity99.7%
add-sqr-sqrt99.6%
fabs-sqr99.6%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
+-lft-identity99.7%
Simplified99.7%
Final simplification99.5%
(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 56.9%
+-commutative56.9%
hypot-1-def99.8%
Simplified99.8%
flip-+11.1%
div-sub10.6%
pow210.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.6%
pow210.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt4.4%
hypot-udef4.4%
hypot-udef4.4%
add-sqr-sqrt4.4%
metadata-eval4.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.5%
Applied egg-rr13.5%
unpow213.5%
div-sub16.9%
unpow216.9%
unpow216.9%
unpow216.9%
+-commutative16.9%
associate--r+53.9%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
associate-/r*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
sub-neg99.8%
Simplified99.8%
log-div99.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-lft-identity99.8%
Simplified99.8%
if -0.100000001 < x < 0.0199999996Initial program 21.0%
+-commutative21.0%
hypot-1-def21.2%
Simplified21.2%
*-un-lft-identity21.2%
log-prod21.2%
metadata-eval21.2%
*-un-lft-identity21.2%
*-un-lft-identity21.2%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt21.6%
Applied egg-rr21.6%
+-lft-identity21.6%
Simplified21.6%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < x Initial program 57.6%
+-commutative57.6%
hypot-1-def99.7%
Simplified99.7%
*-un-lft-identity99.7%
log-prod99.7%
metadata-eval99.7%
*-un-lft-identity99.7%
*-un-lft-identity99.7%
add-sqr-sqrt99.6%
fabs-sqr99.6%
add-sqr-sqrt99.7%
Applied egg-rr99.7%
+-lft-identity99.7%
Simplified99.7%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(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.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
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.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) 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.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) 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:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\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 < -1Initial program 55.6%
+-commutative55.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.0%
associate--l+99.0%
unpow199.0%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow12.4%
unpow112.4%
associate-+r-97.8%
mul-1-neg97.8%
sub-neg97.8%
+-inverses97.8%
neg-sub097.8%
associate-*r/97.8%
metadata-eval97.8%
distribute-neg-frac97.8%
metadata-eval97.8%
Simplified97.8%
if -1 < x < 0.5Initial program 24.7%
+-commutative24.7%
hypot-1-def24.8%
Simplified24.8%
*-un-lft-identity24.8%
log-prod24.8%
metadata-eval24.8%
*-un-lft-identity24.8%
*-un-lft-identity24.8%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt25.2%
Applied egg-rr25.2%
+-lft-identity25.2%
Simplified25.2%
Taylor expanded in x around 0 98.4%
if 0.5 < x Initial program 55.7%
+-commutative55.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.3%
associate-+r+99.3%
+-commutative99.3%
+-commutative99.3%
unpow199.3%
sqr-pow99.2%
fabs-sqr99.2%
sqr-pow99.3%
unpow199.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ 1.0 (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.5)
(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.0f) {
tmp = copysignf(logf((1.0f / ((x * -2.0f) - (0.5f / x)))), x);
} else if (x <= 0.5f) {
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.0)) tmp = copysign(log(Float32(Float32(1.0) / Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(0.5)) 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.0)) tmp = sign(x) * abs(log((single(1.0) / ((x * single(-2.0)) - (single(0.5) / x))))); elseif (x <= single(0.5)) 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:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{x \cdot -2 - \frac{0.5}{x}}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\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 < -1Initial program 55.6%
+-commutative55.6%
hypot-1-def100.0%
Simplified100.0%
flip-+8.3%
div-sub7.8%
pow27.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt7.8%
pow27.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt3.2%
hypot-udef3.2%
hypot-udef3.2%
add-sqr-sqrt3.2%
metadata-eval3.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.9%
Applied egg-rr10.9%
unpow210.9%
div-sub14.4%
unpow214.4%
unpow214.4%
unpow214.4%
+-commutative14.4%
associate--r+52.5%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-/r*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.0%
*-commutative99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
if -1 < x < 0.5Initial program 24.7%
+-commutative24.7%
hypot-1-def24.8%
Simplified24.8%
*-un-lft-identity24.8%
log-prod24.8%
metadata-eval24.8%
*-un-lft-identity24.8%
*-un-lft-identity24.8%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt25.2%
Applied egg-rr25.2%
+-lft-identity25.2%
Simplified25.2%
Taylor expanded in x around 0 98.4%
if 0.5 < x Initial program 55.7%
+-commutative55.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.3%
associate-+r+99.3%
+-commutative99.3%
+-commutative99.3%
unpow199.3%
sqr-pow99.2%
fabs-sqr99.2%
sqr-pow99.3%
unpow199.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
Final simplification98.8%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) 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 <= 0.5f) {
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.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) 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.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) 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:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\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 < -1Initial program 55.6%
+-commutative55.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.0%
associate--l+99.0%
unpow199.0%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow12.4%
unpow112.4%
associate-+r-97.8%
mul-1-neg97.8%
sub-neg97.8%
+-inverses97.8%
neg-sub097.8%
associate-*r/97.8%
metadata-eval97.8%
distribute-neg-frac97.8%
metadata-eval97.8%
Simplified97.8%
if -1 < x < 0.5Initial program 24.7%
+-commutative24.7%
hypot-1-def24.8%
Simplified24.8%
*-un-lft-identity24.8%
log-prod24.8%
metadata-eval24.8%
*-un-lft-identity24.8%
*-un-lft-identity24.8%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt25.2%
Applied egg-rr25.2%
+-lft-identity25.2%
Simplified25.2%
Taylor expanded in x around 0 98.4%
if 0.5 < x Initial program 55.7%
+-commutative55.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.2%
unpow198.2%
sqr-pow98.1%
fabs-sqr98.1%
sqr-pow98.2%
unpow198.2%
Simplified98.2%
Final simplification98.2%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (- x)) x) (if (<= x 0.5) (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.5f) {
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.5)) 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.5)) 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.5:\\
\;\;\;\;\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 54.8%
+-commutative54.8%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 43.8%
mul-1-neg43.8%
Simplified43.8%
if -10 < x < 0.5Initial program 25.3%
+-commutative25.3%
hypot-1-def25.4%
Simplified25.4%
*-un-lft-identity25.4%
log-prod25.4%
metadata-eval25.4%
*-un-lft-identity25.4%
*-un-lft-identity25.4%
add-sqr-sqrt12.1%
fabs-sqr12.1%
add-sqr-sqrt25.8%
Applied egg-rr25.8%
+-lft-identity25.8%
Simplified25.8%
Taylor expanded in x around 0 95.5%
if 0.5 < x Initial program 55.7%
+-commutative55.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.2%
unpow198.2%
sqr-pow98.1%
fabs-sqr98.1%
sqr-pow98.2%
unpow198.2%
Simplified98.2%
Final simplification84.6%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (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 <= 0.5f) {
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(0.5)) 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(0.5)) 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 0.5:\\
\;\;\;\;\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 55.6%
+-commutative55.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.0%
associate--l+99.0%
unpow199.0%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow12.4%
unpow112.4%
associate-+r-97.8%
mul-1-neg97.8%
sub-neg97.8%
+-inverses97.8%
neg-sub097.8%
associate-*r/97.8%
metadata-eval97.8%
distribute-neg-frac97.8%
metadata-eval97.8%
Simplified97.8%
if -1 < x < 0.5Initial program 24.7%
+-commutative24.7%
hypot-1-def24.8%
Simplified24.8%
*-un-lft-identity24.8%
log-prod24.8%
metadata-eval24.8%
*-un-lft-identity24.8%
*-un-lft-identity24.8%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt25.2%
Applied egg-rr25.2%
+-lft-identity25.2%
Simplified25.2%
Taylor expanded in x around 0 96.0%
if 0.5 < x Initial program 55.7%
+-commutative55.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.2%
unpow198.2%
sqr-pow98.1%
fabs-sqr98.1%
sqr-pow98.2%
unpow198.2%
Simplified98.2%
Final simplification97.1%
(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 55.6%
+-commutative55.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 43.6%
mul-1-neg43.6%
Simplified43.6%
if -1 < x Initial program 36.6%
+-commutative36.6%
hypot-1-def53.8%
Simplified53.8%
Taylor expanded in x around 0 29.3%
log1p-def73.3%
unpow173.3%
sqr-pow46.6%
fabs-sqr46.6%
sqr-pow73.2%
unpow173.2%
Simplified73.2%
Final simplification66.4%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) 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.5:\\
\;\;\;\;\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.5Initial program 34.8%
+-commutative34.8%
hypot-1-def49.5%
Simplified49.5%
*-un-lft-identity49.5%
log-prod49.5%
metadata-eval49.5%
*-un-lft-identity49.5%
*-un-lft-identity49.5%
add-sqr-sqrt8.2%
fabs-sqr8.2%
add-sqr-sqrt21.4%
Applied egg-rr21.4%
+-lft-identity21.4%
Simplified21.4%
Taylor expanded in x around 0 68.5%
if 0.5 < x Initial program 55.7%
+-commutative55.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 44.3%
log1p-def44.3%
unpow144.3%
sqr-pow44.3%
fabs-sqr44.3%
sqr-pow44.3%
unpow144.3%
Simplified44.3%
Final simplification61.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 41.0%
+-commutative41.0%
hypot-1-def64.5%
Simplified64.5%
*-un-lft-identity64.5%
log-prod64.5%
metadata-eval64.5%
*-un-lft-identity64.5%
*-un-lft-identity64.5%
add-sqr-sqrt35.4%
fabs-sqr35.4%
add-sqr-sqrt44.8%
Applied egg-rr44.8%
+-lft-identity44.8%
Simplified44.8%
Taylor expanded in x around 0 51.4%
Final simplification51.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 2023194
(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))