
(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 13 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 -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= t_0 0.20000000298023224)
(copysign
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* 0.075 (pow x 5.0)) (+ x (* -0.044642857142857144 (pow x 7.0)))))
x)
(copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (t_0 <= 0.20000000298023224f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + ((0.075f * powf(x, 5.0f)) + (x + (-0.044642857142857144f * powf(x, 7.0f))))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (t_0 <= Float32(0.20000000298023224)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(Float32(0.075) * (x ^ Float32(5.0))) + Float32(x + Float32(Float32(-0.044642857142857144) * (x ^ Float32(7.0)))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (t_0 <= single(0.20000000298023224)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + ((single(0.075) * (x ^ single(5.0))) + (x + (single(-0.044642857142857144) * (x ^ single(7.0))))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(0.075 \cdot {x}^{5} + \left(x + -0.044642857142857144 \cdot {x}^{7}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -2Initial program 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 97.9%
associate--l+97.9%
unpow197.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.0%
unpow19.0%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -2 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 17.8%
+-commutative17.8%
hypot-1-def17.8%
Simplified17.8%
*-un-lft-identity17.8%
log-prod17.8%
metadata-eval17.8%
*-un-lft-identity17.8%
*-un-lft-identity17.8%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt18.1%
Applied egg-rr18.1%
+-lft-identity18.1%
Simplified18.1%
Taylor expanded in x around 0 100.0%
if 0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 49.6%
+-commutative49.6%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
log-prod98.6%
metadata-eval98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
Simplified98.6%
Final simplification99.4%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= t_0 0.20000000298023224)
(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 <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (t_0 <= 0.20000000298023224f) {
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(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (t_0 <= Float32(0.20000000298023224)) 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (t_0 <= single(0.20000000298023224)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.20000000298023224:\\
\;\;\;\;\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) < -2Initial program 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 97.9%
associate--l+97.9%
unpow197.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.0%
unpow19.0%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -2 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 17.8%
+-commutative17.8%
hypot-1-def17.8%
Simplified17.8%
*-un-lft-identity17.8%
log-prod17.8%
metadata-eval17.8%
*-un-lft-identity17.8%
*-un-lft-identity17.8%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt18.1%
Applied egg-rr18.1%
+-lft-identity18.1%
Simplified18.1%
Taylor expanded in x around 0 100.0%
if 0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 49.6%
+-commutative49.6%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
log-prod98.6%
metadata-eval98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
Simplified98.6%
Final simplification99.4%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.019999999552965164)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ 1.0 (+ (log (+ x (hypot 1.0 x))) -1.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf((1.0f + (logf((x + hypotf(1.0f, x))) + -1.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.019999999552965164)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(Float32(1.0) + Float32(log(Float32(x + hypot(Float32(1.0), x))) + Float32(-1.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.019999999552965164)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs((single(1.0) + (log((x + hypot(single(1.0), x))) + single(-1.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.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(1 + \left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right) + -1\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 97.9%
associate--l+97.9%
unpow197.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.0%
unpow19.0%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -2 < x < 0.0199999996Initial program 14.8%
+-commutative14.8%
hypot-1-def14.8%
Simplified14.8%
*-un-lft-identity14.8%
log-prod14.8%
metadata-eval14.8%
*-un-lft-identity14.8%
*-un-lft-identity14.8%
add-sqr-sqrt7.4%
fabs-sqr7.4%
add-sqr-sqrt15.1%
Applied egg-rr15.1%
+-lft-identity15.1%
Simplified15.1%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < x Initial program 52.8%
+-commutative52.8%
hypot-1-def98.2%
Simplified98.2%
*-un-lft-identity98.2%
log-prod98.2%
metadata-eval98.2%
*-un-lft-identity98.2%
*-un-lft-identity98.2%
add-sqr-sqrt98.2%
fabs-sqr98.2%
add-sqr-sqrt98.2%
Applied egg-rr98.2%
+-lft-identity98.2%
Simplified98.2%
expm1-log1p-u96.0%
expm1-udef95.7%
log1p-udef95.7%
add-exp-log97.9%
associate--l+98.4%
+-commutative98.4%
sub-neg98.4%
metadata-eval98.4%
Applied egg-rr98.4%
Final simplification99.3%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -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 <= -2.0f) {
tmp = copysignf(logf((-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(-2.0)) tmp = copysign(log(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(-2.0)) tmp = sign(x) * abs(log((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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\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 < -2Initial program 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 97.9%
associate--l+97.9%
unpow197.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.0%
unpow19.0%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -2 < x < 0.0199999996Initial program 14.8%
+-commutative14.8%
hypot-1-def14.8%
Simplified14.8%
*-un-lft-identity14.8%
log-prod14.8%
metadata-eval14.8%
*-un-lft-identity14.8%
*-un-lft-identity14.8%
add-sqr-sqrt7.4%
fabs-sqr7.4%
add-sqr-sqrt15.1%
Applied egg-rr15.1%
+-lft-identity15.1%
Simplified15.1%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < x Initial program 52.8%
+-commutative52.8%
hypot-1-def98.2%
Simplified98.2%
*-un-lft-identity98.2%
log-prod98.2%
metadata-eval98.2%
*-un-lft-identity98.2%
*-un-lft-identity98.2%
add-sqr-sqrt98.2%
fabs-sqr98.2%
add-sqr-sqrt98.2%
Applied egg-rr98.2%
+-lft-identity98.2%
Simplified98.2%
Final simplification99.3%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) 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((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), 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(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), 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((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); 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(\frac{-0.5}{x}\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 \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 97.9%
associate--l+97.9%
unpow197.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.0%
unpow19.0%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -2 < x < 0.200000003Initial program 17.8%
+-commutative17.8%
hypot-1-def17.8%
Simplified17.8%
*-un-lft-identity17.8%
log-prod17.8%
metadata-eval17.8%
*-un-lft-identity17.8%
*-un-lft-identity17.8%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt18.1%
Applied egg-rr18.1%
+-lft-identity18.1%
Simplified18.1%
Taylor expanded in x around 0 99.4%
if 0.200000003 < x Initial program 49.6%
+-commutative49.6%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
log-prod98.6%
metadata-eval98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
Simplified98.6%
Taylor expanded in x around inf 97.7%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) 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 <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), 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(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\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 < -2Initial program 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 97.9%
associate--l+97.9%
unpow197.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.0%
unpow19.0%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -2 < x < 0.200000003Initial program 17.8%
+-commutative17.8%
hypot-1-def17.8%
Simplified17.8%
*-un-lft-identity17.8%
log-prod17.8%
metadata-eval17.8%
*-un-lft-identity17.8%
*-un-lft-identity17.8%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt18.1%
Applied egg-rr18.1%
+-lft-identity18.1%
Simplified18.1%
Taylor expanded in x around 0 99.4%
if 0.200000003 < x Initial program 49.6%
+-commutative49.6%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 97.7%
associate-+r+97.7%
+-commutative97.7%
+-commutative97.7%
unpow197.7%
sqr-pow97.7%
fabs-sqr97.7%
sqr-pow97.7%
unpow197.7%
associate-*r/97.7%
metadata-eval97.7%
Simplified97.7%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(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((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
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(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) 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((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) 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(\frac{-0.5}{x}\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 97.9%
associate--l+97.9%
unpow197.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.0%
unpow19.0%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -2 < x < 0.200000003Initial program 17.8%
+-commutative17.8%
hypot-1-def17.8%
Simplified17.8%
*-un-lft-identity17.8%
log-prod17.8%
metadata-eval17.8%
*-un-lft-identity17.8%
*-un-lft-identity17.8%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt18.1%
Applied egg-rr18.1%
+-lft-identity18.1%
Simplified18.1%
Taylor expanded in x around 0 99.4%
if 0.200000003 < x Initial program 49.6%
+-commutative49.6%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
log-prod98.6%
metadata-eval98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
Simplified98.6%
Taylor expanded in x around inf 97.7%
Taylor expanded in x around 0 97.2%
mul-1-neg97.2%
unsub-neg97.2%
log-div97.7%
Simplified97.7%
Final simplification98.9%
(FPCore (x) :precision binary32 (if (<= x -2.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 <= -2.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(-2.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(-2.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 -2:\\
\;\;\;\;\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 < -2Initial program 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 45.2%
mul-1-neg45.2%
Simplified45.2%
if -2 < x < 0.200000003Initial program 17.8%
+-commutative17.8%
hypot-1-def17.8%
Simplified17.8%
*-un-lft-identity17.8%
log-prod17.8%
metadata-eval17.8%
*-un-lft-identity17.8%
*-un-lft-identity17.8%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt18.1%
Applied egg-rr18.1%
+-lft-identity18.1%
Simplified18.1%
Taylor expanded in x around 0 98.2%
if 0.200000003 < x Initial program 49.6%
+-commutative49.6%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 96.3%
unpow196.3%
sqr-pow96.3%
fabs-sqr96.3%
sqr-pow96.3%
unpow196.3%
Simplified96.3%
Final simplification85.3%
(FPCore (x) :precision binary32 (if (<= x -2.0) (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 <= -2.0f) {
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(-2.0)) 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(-2.0)) 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 -2:\\
\;\;\;\;\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 < -2Initial program 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 97.9%
associate--l+97.9%
unpow197.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.0%
unpow19.0%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -2 < x < 0.200000003Initial program 17.8%
+-commutative17.8%
hypot-1-def17.8%
Simplified17.8%
*-un-lft-identity17.8%
log-prod17.8%
metadata-eval17.8%
*-un-lft-identity17.8%
*-un-lft-identity17.8%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt18.1%
Applied egg-rr18.1%
+-lft-identity18.1%
Simplified18.1%
Taylor expanded in x around 0 98.2%
if 0.200000003 < x Initial program 49.6%
+-commutative49.6%
hypot-1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 96.3%
unpow196.3%
sqr-pow96.3%
fabs-sqr96.3%
sqr-pow96.3%
unpow196.3%
Simplified96.3%
Final simplification97.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(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.20000000298023224f) {
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.20000000298023224)) 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.20000000298023224)) 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.20000000298023224:\\
\;\;\;\;\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 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 97.9%
associate--l+97.9%
unpow197.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.0%
unpow19.0%
associate-+r-98.9%
mul-1-neg98.9%
sub-neg98.9%
+-inverses98.9%
neg-sub098.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
if -2 < x < 0.200000003Initial program 17.8%
+-commutative17.8%
hypot-1-def17.8%
Simplified17.8%
*-un-lft-identity17.8%
log-prod17.8%
metadata-eval17.8%
*-un-lft-identity17.8%
*-un-lft-identity17.8%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt18.1%
Applied egg-rr18.1%
+-lft-identity18.1%
Simplified18.1%
Taylor expanded in x around 0 98.2%
if 0.200000003 < x Initial program 49.6%
+-commutative49.6%
hypot-1-def98.6%
Simplified98.6%
*-un-lft-identity98.6%
log-prod98.6%
metadata-eval98.6%
*-un-lft-identity98.6%
*-un-lft-identity98.6%
add-sqr-sqrt98.6%
fabs-sqr98.6%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
Simplified98.6%
Taylor expanded in x around inf 97.7%
Taylor expanded in x around 0 97.2%
mul-1-neg97.2%
unsub-neg97.2%
log-div97.7%
Simplified97.7%
Final simplification98.2%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.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 -2:\\
\;\;\;\;\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 < -2Initial program 42.3%
+-commutative42.3%
hypot-1-def98.4%
Simplified98.4%
Taylor expanded in x around -inf 45.2%
mul-1-neg45.2%
Simplified45.2%
if -2 < x Initial program 28.4%
+-commutative28.4%
hypot-1-def44.6%
Simplified44.6%
Taylor expanded in x around 0 25.0%
log1p-def79.1%
unpow179.1%
sqr-pow44.4%
fabs-sqr44.4%
sqr-pow79.1%
unpow179.1%
Simplified79.1%
Final simplification71.2%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(2.0)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 2Initial program 25.9%
+-commutative25.9%
hypot-1-def43.4%
Simplified43.4%
*-un-lft-identity43.4%
log-prod43.4%
metadata-eval43.4%
*-un-lft-identity43.4%
*-un-lft-identity43.4%
add-sqr-sqrt7.8%
fabs-sqr7.8%
add-sqr-sqrt15.9%
Applied egg-rr15.9%
+-lft-identity15.9%
Simplified15.9%
Taylor expanded in x around 0 70.3%
if 2 < x Initial program 48.8%
+-commutative48.8%
hypot-1-def98.5%
Simplified98.5%
Taylor expanded in x around 0 44.4%
log1p-def44.4%
unpow144.4%
sqr-pow44.4%
fabs-sqr44.4%
sqr-pow44.4%
unpow144.4%
Simplified44.4%
Final simplification63.8%
(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 31.6%
+-commutative31.6%
hypot-1-def57.2%
Simplified57.2%
*-un-lft-identity57.2%
log-prod57.2%
metadata-eval57.2%
*-un-lft-identity57.2%
*-un-lft-identity57.2%
add-sqr-sqrt30.5%
fabs-sqr30.5%
add-sqr-sqrt36.6%
Applied egg-rr36.6%
+-lft-identity36.6%
Simplified36.6%
Taylor expanded in x around 0 55.5%
Final simplification55.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 2023173
(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))