
(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 14 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.5)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.20000000298023224)
(copysign
(+
x
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* -0.044642857142857144 (pow x 7.0)) (* 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.5f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.20000000298023224f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + ((-0.044642857142857144f * powf(x, 7.0f)) + (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.5)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(Float32(-0.044642857142857144) * (x ^ Float32(7.0))) + 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.5)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.20000000298023224)) tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + ((single(-0.044642857142857144) * (x ^ single(7.0))) + (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.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + \left(-0.044642857142857144 \cdot {x}^{7} + 0.075 \cdot {x}^{5}\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) < -0.5Initial program 54.5%
+-commutative54.5%
hypot-1-def97.4%
Simplified97.4%
flip-+7.3%
frac-2neg7.3%
log-div7.3%
Applied egg-rr12.4%
neg-sub012.4%
associate--r-12.4%
neg-sub012.4%
+-commutative12.4%
sub-neg12.4%
sub-neg12.4%
+-commutative12.4%
distribute-neg-in12.4%
remove-double-neg12.4%
sub-neg12.4%
Simplified97.4%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 22.1%
+-commutative22.1%
hypot-1-def22.1%
Simplified22.1%
flip-+22.1%
div-sub22.1%
pow222.1%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt22.1%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt20.8%
Applied egg-rr22.0%
div-sub21.9%
fma-undefine21.9%
unpow221.9%
associate--r+22.0%
+-inverses22.0%
metadata-eval22.0%
Simplified22.0%
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 55.6%
+-commutative55.6%
hypot-1-def100.0%
Simplified100.0%
log1p-expm1-u99.9%
add099.9%
log1p-expm1-u100.0%
add-sqr-sqrt100.0%
fabs-sqr100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
add0100.0%
Simplified100.0%
Final simplification99.2%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.004999999888241291)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 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.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.004999999888241291f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (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.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.004999999888241291)) tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + 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.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.004999999888241291)) tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + (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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 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.100000001Initial program 55.1%
+-commutative55.1%
hypot-1-def97.4%
Simplified97.4%
flip-+8.5%
frac-2neg8.5%
log-div8.5%
Applied egg-rr13.4%
neg-sub013.4%
associate--r-13.4%
neg-sub013.4%
+-commutative13.4%
sub-neg13.4%
sub-neg13.4%
+-commutative13.4%
distribute-neg-in13.4%
remove-double-neg13.4%
sub-neg13.4%
Simplified97.4%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.00499999989Initial program 20.7%
+-commutative20.7%
hypot-1-def20.7%
Simplified20.7%
flip-+20.7%
div-sub20.7%
pow220.7%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt20.7%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt19.9%
Applied egg-rr20.6%
div-sub20.6%
fma-undefine20.6%
unpow220.6%
associate--r+20.6%
+-inverses20.6%
metadata-eval20.6%
Simplified20.6%
Taylor expanded in x around 0 100.0%
if 0.00499999989 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 56.1%
+-commutative56.1%
hypot-1-def99.9%
Simplified99.9%
log1p-expm1-u99.9%
add099.9%
log1p-expm1-u99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
add099.9%
Simplified99.9%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (+ (- x x) (/ -0.5 x))) x)
(if (<= x 0.004999999888241291)
(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(((x - x) + (-0.5f / x))), x);
} else if (x <= 0.004999999888241291f) {
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(x - x) + Float32(Float32(-0.5) / x))), x); elseif (x <= Float32(0.004999999888241291)) 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(((x - x) + (single(-0.5) / x)))); elseif (x <= single(0.004999999888241291)) 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(\left(x - x\right) + \frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\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 53.9%
+-commutative53.9%
hypot-1-def97.4%
Simplified97.4%
Taylor expanded in x around -inf 95.7%
sub-neg95.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt97.6%
mul-1-neg97.6%
sub-neg97.6%
associate-*r/97.6%
metadata-eval97.6%
distribute-neg-frac97.6%
metadata-eval97.6%
Simplified97.6%
if -1 < x < 0.00499999989Initial program 22.2%
+-commutative22.2%
hypot-1-def22.2%
Simplified22.2%
flip-+22.1%
div-sub22.1%
pow222.1%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt22.1%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt20.2%
Applied egg-rr22.0%
div-sub22.0%
fma-undefine22.0%
unpow222.0%
associate--r+22.0%
+-inverses22.0%
metadata-eval22.0%
Simplified22.0%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
Simplified99.0%
if 0.00499999989 < x Initial program 56.1%
+-commutative56.1%
hypot-1-def99.9%
Simplified99.9%
log1p-expm1-u99.9%
add099.9%
log1p-expm1-u99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
add099.9%
Simplified99.9%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.004999999888241291)
(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((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.004999999888241291f) {
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(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.004999999888241291)) 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((hypot(single(1.0), x) - x))); elseif (x <= single(0.004999999888241291)) 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(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\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 55.6%
+-commutative55.6%
hypot-1-def97.3%
Simplified97.3%
flip-+9.7%
frac-2neg9.7%
log-div9.7%
Applied egg-rr14.6%
neg-sub014.6%
associate--r-14.6%
neg-sub014.6%
+-commutative14.6%
sub-neg14.6%
sub-neg14.6%
+-commutative14.6%
distribute-neg-in14.6%
remove-double-neg14.6%
sub-neg14.6%
Simplified97.3%
if -0.0500000007 < x < 0.00499999989Initial program 20.0%
+-commutative20.0%
hypot-1-def20.0%
Simplified20.0%
flip-+20.0%
div-sub20.0%
pow220.0%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt20.0%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt19.6%
Applied egg-rr19.9%
div-sub19.8%
fma-undefine19.8%
unpow219.8%
associate--r+19.9%
+-inverses19.9%
metadata-eval19.9%
Simplified19.9%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 0.00499999989 < x Initial program 56.1%
+-commutative56.1%
hypot-1-def99.9%
Simplified99.9%
log1p-expm1-u99.9%
add099.9%
log1p-expm1-u99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
add099.9%
Simplified99.9%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -1.0 (* x 2.0))) x)
(if (<= x 0.9599999785423279)
(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))), x);
} else if (x <= 0.9599999785423279f) {
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(x * Float32(2.0)))), x); elseif (x <= Float32(0.9599999785423279)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(x + 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))))); elseif (x <= single(0.9599999785423279)) 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}\right), x\right)\\
\mathbf{elif}\;x \leq 0.9599999785423279:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 53.9%
+-commutative53.9%
hypot-1-def97.4%
Simplified97.4%
flip-+6.1%
div-sub6.1%
pow26.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.3%
Applied egg-rr8.9%
div-sub11.0%
fma-undefine11.0%
unpow211.0%
associate--r+50.5%
+-inverses97.2%
metadata-eval97.2%
Simplified97.2%
Taylor expanded in x around -inf 94.9%
*-commutative94.9%
Simplified94.9%
if -1 < x < 0.959999979Initial program 23.6%
+-commutative23.6%
hypot-1-def23.6%
Simplified23.6%
flip-+23.5%
div-sub23.5%
pow223.5%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt23.5%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt21.6%
Applied egg-rr23.4%
div-sub23.4%
fma-undefine23.3%
unpow223.3%
associate--r+23.4%
+-inverses23.4%
metadata-eval23.4%
Simplified23.4%
Taylor expanded in x around 0 98.3%
*-commutative98.3%
Simplified98.3%
if 0.959999979 < x Initial program 55.0%
+-commutative55.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.0%
associate-+r+99.0%
rem-square-sqrt99.0%
fabs-sqr99.0%
rem-square-sqrt99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
Final simplification97.6%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (+ (- x x) (/ -0.5 x))) x)
(if (<= x 0.9599999785423279)
(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(((x - x) + (-0.5f / x))), x);
} else if (x <= 0.9599999785423279f) {
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(x - x) + Float32(Float32(-0.5) / x))), x); elseif (x <= Float32(0.9599999785423279)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(x + 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(((x - x) + (single(-0.5) / x)))); elseif (x <= single(0.9599999785423279)) 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(\left(x - x\right) + \frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.9599999785423279:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 53.9%
+-commutative53.9%
hypot-1-def97.4%
Simplified97.4%
Taylor expanded in x around -inf 95.7%
sub-neg95.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt97.6%
mul-1-neg97.6%
sub-neg97.6%
associate-*r/97.6%
metadata-eval97.6%
distribute-neg-frac97.6%
metadata-eval97.6%
Simplified97.6%
if -1 < x < 0.959999979Initial program 23.6%
+-commutative23.6%
hypot-1-def23.6%
Simplified23.6%
flip-+23.5%
div-sub23.5%
pow223.5%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt23.5%
add-sqr-sqrt10.7%
fabs-sqr10.7%
add-sqr-sqrt21.6%
Applied egg-rr23.4%
div-sub23.4%
fma-undefine23.3%
unpow223.3%
associate--r+23.4%
+-inverses23.4%
metadata-eval23.4%
Simplified23.4%
Taylor expanded in x around 0 98.3%
*-commutative98.3%
Simplified98.3%
if 0.959999979 < x Initial program 55.0%
+-commutative55.0%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 99.0%
associate-+r+99.0%
rem-square-sqrt99.0%
fabs-sqr99.0%
rem-square-sqrt99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
Final simplification98.3%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -1.0 (* x 2.0))) x)
(if (<= x 1.0)
(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((-1.0f / (x * 2.0f))), x);
} else if (x <= 1.0f) {
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(-1.0) / Float32(x * Float32(2.0)))), x); elseif (x <= Float32(1.0)) 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(-1.0) / (x * single(2.0))))); elseif (x <= single(1.0)) 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{-1}{x \cdot 2}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 53.9%
+-commutative53.9%
hypot-1-def97.4%
Simplified97.4%
flip-+6.1%
div-sub6.1%
pow26.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.3%
Applied egg-rr8.9%
div-sub11.0%
fma-undefine11.0%
unpow211.0%
associate--r+50.5%
+-inverses97.2%
metadata-eval97.2%
Simplified97.2%
Taylor expanded in x around -inf 94.9%
*-commutative94.9%
Simplified94.9%
if -1 < x < 1Initial program 24.3%
+-commutative24.3%
hypot-1-def24.3%
Simplified24.3%
flip-+24.2%
div-sub24.2%
pow224.2%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt24.2%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt22.3%
Applied egg-rr24.1%
div-sub24.1%
fma-undefine24.0%
unpow224.0%
associate--r+24.1%
+-inverses24.1%
metadata-eval24.1%
Simplified24.1%
Taylor expanded in x around 0 97.7%
*-commutative97.7%
Simplified97.7%
if 1 < x Initial program 54.4%
+-commutative54.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.9%
rem-square-sqrt98.9%
fabs-sqr98.9%
rem-square-sqrt98.9%
Simplified98.9%
Final simplification97.3%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (- x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(1.0)) 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(-5.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(1.0)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 52.6%
+-commutative52.6%
hypot-1-def97.3%
Simplified97.3%
Taylor expanded in x around -inf 44.8%
mul-1-neg44.8%
Simplified44.8%
if -5 < x < 1Initial program 25.6%
+-commutative25.6%
hypot-1-def25.6%
Simplified25.6%
Taylor expanded in x around 0 20.0%
rem-square-sqrt9.2%
fabs-sqr9.2%
rem-square-sqrt19.3%
Simplified19.3%
Taylor expanded in x around 0 95.1%
if 1 < x Initial program 54.4%
+-commutative54.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.9%
rem-square-sqrt98.9%
fabs-sqr98.9%
rem-square-sqrt98.9%
Simplified98.9%
Final simplification82.7%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (- (log (/ -1.0 x))) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((-1.0f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x); elseif (x <= Float32(1.0)) 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(-5.0)) tmp = sign(x) * abs(-log((single(-1.0) / x))); elseif (x <= single(1.0)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 52.6%
+-commutative52.6%
hypot-1-def97.3%
Simplified97.3%
Taylor expanded in x around -inf 44.8%
mul-1-neg44.8%
Simplified44.8%
if -5 < x < 1Initial program 25.6%
+-commutative25.6%
hypot-1-def25.6%
Simplified25.6%
Taylor expanded in x around 0 20.0%
rem-square-sqrt9.2%
fabs-sqr9.2%
rem-square-sqrt19.3%
Simplified19.3%
Taylor expanded in x around 0 95.1%
if 1 < x Initial program 54.4%
+-commutative54.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.9%
rem-square-sqrt98.9%
fabs-sqr98.9%
rem-square-sqrt98.9%
Simplified98.9%
Final simplification82.7%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -1.0 (* x 2.0))) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-1.0f / (x * 2.0f))), x);
} else if (x <= 1.0f) {
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(-1.0) / Float32(x * Float32(2.0)))), x); elseif (x <= Float32(1.0)) 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(-1.0) / (x * single(2.0))))); elseif (x <= single(1.0)) 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{-1}{x \cdot 2}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 53.9%
+-commutative53.9%
hypot-1-def97.4%
Simplified97.4%
flip-+6.1%
div-sub6.1%
pow26.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt6.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt2.3%
Applied egg-rr8.9%
div-sub11.0%
fma-undefine11.0%
unpow211.0%
associate--r+50.5%
+-inverses97.2%
metadata-eval97.2%
Simplified97.2%
Taylor expanded in x around -inf 94.9%
*-commutative94.9%
Simplified94.9%
if -1 < x < 1Initial program 24.3%
+-commutative24.3%
hypot-1-def24.3%
Simplified24.3%
Taylor expanded in x around 0 19.8%
rem-square-sqrt9.4%
fabs-sqr9.4%
rem-square-sqrt19.7%
Simplified19.7%
Taylor expanded in x around 0 96.2%
if 1 < x Initial program 54.4%
+-commutative54.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 98.9%
rem-square-sqrt98.9%
fabs-sqr98.9%
rem-square-sqrt98.9%
Simplified98.9%
Final simplification96.6%
(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 53.9%
+-commutative53.9%
hypot-1-def97.4%
Simplified97.4%
Taylor expanded in x around -inf 44.3%
mul-1-neg44.3%
Simplified44.3%
if -1 < x Initial program 36.6%
+-commutative36.6%
hypot-1-def55.4%
Simplified55.4%
Taylor expanded in x around 0 29.9%
log1p-define72.6%
rem-square-sqrt43.3%
fabs-sqr43.3%
rem-square-sqrt72.5%
Simplified72.5%
Final simplification64.7%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(x), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log(x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 1Initial program 35.9%
+-commutative35.9%
hypot-1-def53.1%
Simplified53.1%
Taylor expanded in x around 0 29.5%
rem-square-sqrt5.7%
fabs-sqr5.7%
rem-square-sqrt11.9%
Simplified11.9%
Taylor expanded in x around 0 62.7%
if 1 < x Initial program 54.4%
+-commutative54.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 44.4%
mul-1-neg44.4%
log-rec44.4%
remove-double-neg44.4%
Simplified44.4%
Final simplification57.2%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.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 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 35.9%
+-commutative35.9%
hypot-1-def53.1%
Simplified53.1%
Taylor expanded in x around 0 29.5%
rem-square-sqrt5.7%
fabs-sqr5.7%
rem-square-sqrt11.9%
Simplified11.9%
Taylor expanded in x around 0 62.7%
if 1 < x Initial program 54.4%
+-commutative54.4%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 44.4%
log1p-define44.4%
rem-square-sqrt44.4%
fabs-sqr44.4%
rem-square-sqrt44.4%
Simplified44.4%
Final simplification57.2%
(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.4%
+-commutative41.4%
hypot-1-def67.0%
Simplified67.0%
Taylor expanded in x around 0 33.9%
rem-square-sqrt17.2%
fabs-sqr17.2%
rem-square-sqrt21.6%
Simplified21.6%
Taylor expanded in x around 0 47.4%
Final simplification47.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 2024046
(FPCore (x)
:name "Rust f32::asinh"
:precision binary32
:alt
(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))