
(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
(if (<= x -0.05999999865889549)
(copysign (log (- (hypot 1.0 x) x)) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.05999999865889549f) {
tmp = copysignf(logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.05999999865889549)) tmp = copysign(log(Float32(hypot(Float32(1.0), x) - x)), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.05999999865889549)) tmp = sign(x) * abs(log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05999999865889549:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.0599999987Initial program 53.1%
+-commutative53.1%
hypot-1-def99.9%
Simplified99.9%
flip-+9.8%
div-sub10.1%
pow210.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt3.6%
Applied egg-rr13.3%
div-sub14.6%
remove-double-neg14.6%
distribute-frac-neg214.6%
neg-mul-114.6%
associate-/r*14.6%
distribute-neg-frac214.6%
fma-undefine14.2%
unpow214.2%
associate--r+49.9%
sub-neg49.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
flip--9.9%
+-commutative9.9%
div-inv9.9%
hypot-1-def9.8%
hypot-1-def9.6%
add-sqr-sqrt9.9%
pow29.9%
pow29.9%
Applied egg-rr9.9%
associate-*r/9.9%
*-rgt-identity9.9%
associate--l+12.3%
+-inverses15.6%
metadata-eval15.6%
Simplified15.6%
remove-double-div15.6%
+-commutative15.6%
Applied egg-rr15.6%
add-sqr-sqrt-0.0%
sqrt-unprod53.1%
sqr-neg53.1%
sqrt-unprod99.9%
add-sqr-sqrt99.9%
sub-neg99.9%
Applied egg-rr99.9%
if -0.0599999987 < x < 0.0500000007Initial program 20.5%
+-commutative20.5%
hypot-1-def20.6%
Simplified20.6%
flip-+20.5%
div-sub20.5%
pow220.5%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt20.5%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt19.7%
Applied egg-rr20.5%
div-sub20.5%
remove-double-neg20.5%
distribute-frac-neg220.5%
neg-mul-120.5%
associate-/r*20.5%
distribute-neg-frac220.5%
fma-undefine20.5%
unpow220.5%
associate--r+20.7%
sub-neg20.7%
+-inverses20.7%
metadata-eval20.7%
metadata-eval20.7%
metadata-eval20.7%
neg-sub020.7%
associate--r-20.7%
neg-sub020.7%
+-commutative20.7%
sub-neg20.7%
Simplified20.7%
Taylor expanded in x around 0 99.8%
distribute-rgt-in99.9%
*-lft-identity99.9%
associate-*l*99.9%
unpow299.9%
unpow399.9%
Simplified99.9%
if 0.0500000007 < x Initial program 57.1%
+-commutative57.1%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 57.1%
rem-square-sqrt57.1%
fabs-sqr57.1%
metadata-eval57.1%
unpow257.1%
hypot-undefine99.9%
rem-square-sqrt99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<=
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)
-9.999999747378752e-5)
(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) <= -9.999999747378752e-5f) {
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(-9.999999747378752e-5)) 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 -9.999999747378752 \cdot 10^{-5}:\\
\;\;\;\;\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) #s(literal 1 binary32))))) x) < -9.99999975e-5Initial program 55.1%
+-commutative55.1%
hypot-1-def97.7%
Simplified97.7%
flip-+16.0%
div-sub16.2%
pow216.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt16.2%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt9.3%
Applied egg-rr19.2%
div-sub20.5%
remove-double-neg20.5%
distribute-frac-neg220.5%
neg-mul-120.5%
associate-/r*20.5%
distribute-neg-frac220.5%
fma-undefine20.1%
unpow220.1%
associate--r+52.5%
sub-neg52.5%
+-inverses97.8%
metadata-eval97.8%
metadata-eval97.8%
metadata-eval97.8%
neg-sub097.8%
associate--r-97.8%
neg-sub097.8%
+-commutative97.8%
sub-neg97.8%
Simplified97.8%
if -9.99999975e-5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 30.6%
+-commutative30.6%
hypot-1-def45.5%
Simplified45.5%
flip-+13.5%
div-sub13.6%
pow213.6%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt13.6%
add-sqr-sqrt9.2%
fabs-sqr9.2%
add-sqr-sqrt13.6%
Applied egg-rr13.4%
div-sub13.4%
remove-double-neg13.4%
distribute-frac-neg213.4%
neg-mul-113.4%
associate-/r*13.4%
distribute-neg-frac213.4%
fma-undefine13.4%
unpow213.4%
associate--r+13.5%
sub-neg13.5%
+-inverses13.5%
metadata-eval13.5%
metadata-eval13.5%
metadata-eval13.5%
neg-sub015.5%
associate--r-15.5%
neg-sub015.5%
+-commutative15.5%
sub-neg15.5%
Simplified15.5%
flip--14.3%
+-commutative14.3%
div-inv14.3%
hypot-1-def14.7%
hypot-1-def14.1%
add-sqr-sqrt15.2%
pow215.2%
pow215.2%
Applied egg-rr15.2%
associate-*r/15.2%
*-rgt-identity15.2%
associate--l+29.6%
+-inverses45.5%
metadata-eval45.5%
Simplified45.5%
log1p-expm1-u45.5%
expm1-undefine45.5%
add-exp-log45.5%
remove-double-div45.5%
Applied egg-rr45.5%
associate--l+99.2%
Simplified99.2%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(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 <= -2.0f) {
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(-2.0)) 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(-2.0)) 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 -2:\\
\;\;\;\;\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 < -2Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
flip-+6.5%
div-sub6.7%
pow26.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.1%
Applied egg-rr10.0%
div-sub11.3%
remove-double-neg11.3%
distribute-frac-neg211.3%
neg-mul-111.3%
associate-/r*11.3%
distribute-neg-frac211.3%
fma-undefine11.0%
unpow211.0%
associate--r+47.9%
sub-neg47.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.4%
clear-num97.4%
log-rec97.4%
div-inv97.4%
metadata-eval97.4%
Applied egg-rr97.4%
if -2 < x < 0.0500000007Initial program 22.3%
+-commutative22.3%
hypot-1-def22.5%
Simplified22.5%
flip-+22.3%
div-sub22.3%
pow222.3%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt22.3%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt20.2%
Applied egg-rr22.3%
div-sub22.4%
remove-double-neg22.4%
distribute-frac-neg222.4%
neg-mul-122.4%
associate-/r*22.4%
distribute-neg-frac222.4%
fma-undefine22.4%
unpow222.4%
associate--r+22.6%
sub-neg22.6%
+-inverses22.6%
metadata-eval22.6%
metadata-eval22.6%
metadata-eval22.6%
neg-sub022.6%
associate--r-22.6%
neg-sub022.6%
+-commutative22.6%
sub-neg22.6%
Simplified22.6%
Taylor expanded in x around 0 99.0%
distribute-rgt-in99.1%
*-lft-identity99.1%
associate-*l*99.1%
unpow299.1%
unpow399.1%
Simplified99.1%
if 0.0500000007 < x Initial program 57.1%
+-commutative57.1%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 57.1%
rem-square-sqrt57.1%
fabs-sqr57.1%
metadata-eval57.1%
unpow257.1%
hypot-undefine99.9%
rem-square-sqrt99.9%
Simplified99.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) 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 <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
flip-+6.5%
div-sub6.7%
pow26.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.1%
Applied egg-rr10.0%
div-sub11.3%
remove-double-neg11.3%
distribute-frac-neg211.3%
neg-mul-111.3%
associate-/r*11.3%
distribute-neg-frac211.3%
fma-undefine11.0%
unpow211.0%
associate--r+47.9%
sub-neg47.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.4%
clear-num97.4%
log-rec97.4%
div-inv97.4%
metadata-eval97.4%
Applied egg-rr97.4%
if -2 < x < 0.5Initial program 23.0%
+-commutative23.0%
hypot-1-def23.1%
Simplified23.1%
flip-+22.9%
div-sub22.9%
pow222.9%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt22.9%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt20.8%
Applied egg-rr22.9%
div-sub23.0%
remove-double-neg23.0%
distribute-frac-neg223.0%
neg-mul-123.0%
associate-/r*23.0%
distribute-neg-frac223.0%
fma-undefine23.0%
unpow223.0%
associate--r+23.1%
sub-neg23.1%
+-inverses23.1%
metadata-eval23.1%
metadata-eval23.1%
metadata-eval23.1%
neg-sub023.1%
associate--r-23.1%
neg-sub023.1%
+-commutative23.1%
sub-neg23.1%
Simplified23.1%
Taylor expanded in x around 0 98.7%
distribute-rgt-in98.7%
*-lft-identity98.7%
associate-*l*98.7%
unpow298.7%
unpow398.7%
Simplified98.7%
if 0.5 < x Initial program 56.4%
+-commutative56.4%
hypot-1-def99.9%
Simplified99.9%
flip-+6.5%
div-sub6.6%
pow26.6%
add-sqr-sqrt5.8%
fabs-sqr5.8%
add-sqr-sqrt6.6%
add-sqr-sqrt5.4%
fabs-sqr5.4%
add-sqr-sqrt6.6%
Applied egg-rr6.1%
div-sub6.2%
remove-double-neg6.2%
distribute-frac-neg26.2%
neg-mul-16.2%
associate-/r*6.2%
distribute-neg-frac26.2%
fma-undefine6.2%
unpow26.2%
associate--r+6.2%
sub-neg6.2%
+-inverses6.2%
metadata-eval6.2%
metadata-eval6.2%
metadata-eval6.2%
neg-sub012.1%
associate--r-12.1%
neg-sub012.1%
+-commutative12.1%
sub-neg12.1%
Simplified12.1%
Taylor expanded in x around -inf -0.0%
frac-2neg-0.0%
div-inv-0.0%
metadata-eval-0.0%
add-sqr-sqrt-0.0%
sqrt-unprod54.2%
sqr-neg54.2%
sqrt-unprod97.7%
add-sqr-sqrt97.7%
Applied egg-rr97.7%
associate-*r/97.7%
metadata-eval97.7%
Simplified97.7%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (- (log (* x -2.0))) x) (if (<= x 0.5) (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 <= 0.5f) {
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(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.5)) 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 0.5:\\
\;\;\;\;\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 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
flip-+6.5%
div-sub6.7%
pow26.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.1%
Applied egg-rr10.0%
div-sub11.3%
remove-double-neg11.3%
distribute-frac-neg211.3%
neg-mul-111.3%
associate-/r*11.3%
distribute-neg-frac211.3%
fma-undefine11.0%
unpow211.0%
associate--r+47.9%
sub-neg47.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.4%
clear-num97.4%
log-rec97.4%
div-inv97.4%
metadata-eval97.4%
Applied egg-rr97.4%
if -2 < x < 0.5Initial program 23.0%
+-commutative23.0%
hypot-1-def23.1%
Simplified23.1%
flip-+22.9%
div-sub22.9%
pow222.9%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt22.9%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt20.8%
Applied egg-rr22.9%
div-sub23.0%
remove-double-neg23.0%
distribute-frac-neg223.0%
neg-mul-123.0%
associate-/r*23.0%
distribute-neg-frac223.0%
fma-undefine23.0%
unpow223.0%
associate--r+23.1%
sub-neg23.1%
+-inverses23.1%
metadata-eval23.1%
metadata-eval23.1%
metadata-eval23.1%
neg-sub023.1%
associate--r-23.1%
neg-sub023.1%
+-commutative23.1%
sub-neg23.1%
Simplified23.1%
Taylor expanded in x around 0 97.0%
if 0.5 < x Initial program 56.4%
+-commutative56.4%
hypot-1-def99.9%
Simplified99.9%
flip-+6.5%
div-sub6.6%
pow26.6%
add-sqr-sqrt5.8%
fabs-sqr5.8%
add-sqr-sqrt6.6%
add-sqr-sqrt5.4%
fabs-sqr5.4%
add-sqr-sqrt6.6%
Applied egg-rr6.1%
div-sub6.2%
remove-double-neg6.2%
distribute-frac-neg26.2%
neg-mul-16.2%
associate-/r*6.2%
distribute-neg-frac26.2%
fma-undefine6.2%
unpow26.2%
associate--r+6.2%
sub-neg6.2%
+-inverses6.2%
metadata-eval6.2%
metadata-eval6.2%
metadata-eval6.2%
neg-sub012.1%
associate--r-12.1%
neg-sub012.1%
+-commutative12.1%
sub-neg12.1%
Simplified12.1%
Taylor expanded in x around -inf -0.0%
frac-2neg-0.0%
div-inv-0.0%
metadata-eval-0.0%
add-sqr-sqrt-0.0%
sqrt-unprod54.2%
sqr-neg54.2%
sqrt-unprod97.7%
add-sqr-sqrt97.7%
Applied egg-rr97.7%
associate-*r/97.7%
metadata-eval97.7%
Simplified97.7%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
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(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.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((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(\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
flip-+6.5%
div-sub6.7%
pow26.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.1%
Applied egg-rr10.0%
div-sub11.3%
remove-double-neg11.3%
distribute-frac-neg211.3%
neg-mul-111.3%
associate-/r*11.3%
distribute-neg-frac211.3%
fma-undefine11.0%
unpow211.0%
associate--r+47.9%
sub-neg47.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.4%
if -2 < x < 0.5Initial program 23.0%
+-commutative23.0%
hypot-1-def23.1%
Simplified23.1%
flip-+22.9%
div-sub22.9%
pow222.9%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt22.9%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt20.8%
Applied egg-rr22.9%
div-sub23.0%
remove-double-neg23.0%
distribute-frac-neg223.0%
neg-mul-123.0%
associate-/r*23.0%
distribute-neg-frac223.0%
fma-undefine23.0%
unpow223.0%
associate--r+23.1%
sub-neg23.1%
+-inverses23.1%
metadata-eval23.1%
metadata-eval23.1%
metadata-eval23.1%
neg-sub023.1%
associate--r-23.1%
neg-sub023.1%
+-commutative23.1%
sub-neg23.1%
Simplified23.1%
Taylor expanded in x around 0 97.0%
if 0.5 < x Initial program 56.4%
+-commutative56.4%
hypot-1-def99.9%
Simplified99.9%
flip-+6.5%
div-sub6.6%
pow26.6%
add-sqr-sqrt5.8%
fabs-sqr5.8%
add-sqr-sqrt6.6%
add-sqr-sqrt5.4%
fabs-sqr5.4%
add-sqr-sqrt6.6%
Applied egg-rr6.1%
div-sub6.2%
remove-double-neg6.2%
distribute-frac-neg26.2%
neg-mul-16.2%
associate-/r*6.2%
distribute-neg-frac26.2%
fma-undefine6.2%
unpow26.2%
associate--r+6.2%
sub-neg6.2%
+-inverses6.2%
metadata-eval6.2%
metadata-eval6.2%
metadata-eval6.2%
neg-sub012.1%
associate--r-12.1%
neg-sub012.1%
+-commutative12.1%
sub-neg12.1%
Simplified12.1%
Taylor expanded in x around -inf -0.0%
frac-2neg-0.0%
div-inv-0.0%
metadata-eval-0.0%
add-sqr-sqrt-0.0%
sqrt-unprod54.2%
sqr-neg54.2%
sqrt-unprod97.7%
add-sqr-sqrt97.7%
Applied egg-rr97.7%
associate-*r/97.7%
metadata-eval97.7%
Simplified97.7%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (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 <= 0.5f) {
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(0.5)) 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(0.5)) 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 0.5:\\
\;\;\;\;\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 51.4%
+-commutative51.4%
hypot-1-def100.0%
Simplified100.0%
flip-+6.5%
div-sub6.7%
pow26.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.1%
Applied egg-rr10.0%
div-sub11.3%
remove-double-neg11.3%
distribute-frac-neg211.3%
neg-mul-111.3%
associate-/r*11.3%
distribute-neg-frac211.3%
fma-undefine11.0%
unpow211.0%
associate--r+47.9%
sub-neg47.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around -inf 97.4%
if -2 < x < 0.5Initial program 23.0%
+-commutative23.0%
hypot-1-def23.1%
Simplified23.1%
flip-+22.9%
div-sub22.9%
pow222.9%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt22.9%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt20.8%
Applied egg-rr22.9%
div-sub23.0%
remove-double-neg23.0%
distribute-frac-neg223.0%
neg-mul-123.0%
associate-/r*23.0%
distribute-neg-frac223.0%
fma-undefine23.0%
unpow223.0%
associate--r+23.1%
sub-neg23.1%
+-inverses23.1%
metadata-eval23.1%
metadata-eval23.1%
metadata-eval23.1%
neg-sub023.1%
associate--r-23.1%
neg-sub023.1%
+-commutative23.1%
sub-neg23.1%
Simplified23.1%
Taylor expanded in x around 0 97.0%
if 0.5 < x Initial program 56.4%
+-commutative56.4%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 97.7%
+-commutative97.7%
rem-square-sqrt97.7%
fabs-sqr97.7%
rem-square-sqrt97.7%
*-inverses97.7%
metadata-eval97.7%
Simplified97.7%
(FPCore (x) :precision binary32 (if (<= x -3.0) (copysign (log (- x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -3.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-3.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.5)) 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(-3.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(0.5)) 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 -3:\\
\;\;\;\;\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 \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -3Initial program 50.7%
+-commutative50.7%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.3%
mul-1-neg44.3%
Simplified44.3%
if -3 < x < 0.5Initial program 23.6%
+-commutative23.6%
hypot-1-def23.7%
Simplified23.7%
flip-+23.5%
div-sub23.5%
pow223.5%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt23.5%
add-sqr-sqrt10.1%
fabs-sqr10.1%
add-sqr-sqrt20.9%
Applied egg-rr23.5%
div-sub23.6%
remove-double-neg23.6%
distribute-frac-neg223.6%
neg-mul-123.6%
associate-/r*23.6%
distribute-neg-frac223.6%
fma-undefine23.6%
unpow223.6%
associate--r+23.7%
sub-neg23.7%
+-inverses23.7%
metadata-eval23.7%
metadata-eval23.7%
metadata-eval23.7%
neg-sub023.7%
associate--r-23.7%
neg-sub023.7%
+-commutative23.7%
sub-neg23.7%
Simplified23.7%
Taylor expanded in x around 0 96.4%
if 0.5 < x Initial program 56.4%
+-commutative56.4%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 97.7%
+-commutative97.7%
rem-square-sqrt97.7%
fabs-sqr97.7%
rem-square-sqrt97.7%
*-inverses97.7%
metadata-eval97.7%
Simplified97.7%
(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 52.0%
+-commutative52.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 43.9%
mul-1-neg43.9%
Simplified43.9%
if -1 < x Initial program 33.3%
+-commutative33.3%
hypot-1-def47.4%
Simplified47.4%
Taylor expanded in x around 0 27.2%
log1p-define77.9%
rem-square-sqrt46.6%
fabs-sqr46.6%
rem-square-sqrt77.9%
Simplified77.9%
(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 33.7%
+-commutative33.7%
hypot-1-def52.2%
Simplified52.2%
flip-+16.7%
div-sub16.8%
pow216.8%
add-sqr-sqrt6.4%
fabs-sqr6.4%
add-sqr-sqrt16.8%
add-sqr-sqrt6.3%
fabs-sqr6.3%
add-sqr-sqrt13.8%
Applied egg-rr18.0%
div-sub18.6%
remove-double-neg18.6%
distribute-frac-neg218.6%
neg-mul-118.6%
associate-/r*18.6%
distribute-neg-frac218.6%
fma-undefine18.4%
unpow218.4%
associate--r+32.5%
sub-neg32.5%
+-inverses52.2%
metadata-eval52.2%
metadata-eval52.2%
metadata-eval52.2%
neg-sub052.2%
associate--r-52.2%
neg-sub052.2%
+-commutative52.2%
sub-neg52.2%
Simplified52.2%
Taylor expanded in x around 0 64.6%
if 0.5 < x Initial program 56.4%
+-commutative56.4%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 44.3%
log1p-define44.3%
rem-square-sqrt44.3%
fabs-sqr44.3%
rem-square-sqrt44.3%
Simplified44.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 38.9%
+-commutative38.9%
hypot-1-def63.0%
Simplified63.0%
flip-+14.4%
div-sub14.5%
pow214.5%
add-sqr-sqrt6.2%
fabs-sqr6.2%
add-sqr-sqrt14.5%
add-sqr-sqrt6.1%
fabs-sqr6.1%
add-sqr-sqrt12.1%
Applied egg-rr15.3%
div-sub15.8%
remove-double-neg15.8%
distribute-frac-neg215.8%
neg-mul-115.8%
associate-/r*15.8%
distribute-neg-frac215.8%
fma-undefine15.7%
unpow215.7%
associate--r+26.6%
sub-neg26.6%
+-inverses41.8%
metadata-eval41.8%
metadata-eval41.8%
metadata-eval41.8%
neg-sub043.1%
associate--r-43.1%
neg-sub043.1%
+-commutative43.1%
sub-neg43.1%
Simplified43.1%
Taylor expanded in x around 0 52.5%
(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 2024180
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(! :herbie-platform default (let* ((ax (fabs x)) (ix (/ 1 ax))) (copysign (log1p (+ ax (/ ax (+ (hypot 1 ix) ix)))) x)))
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))