
(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 -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(+
x
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* -0.044642857142857144 (pow x 7.0)) (* 0.075 (pow x 5.0)))))
x)
(copysign (log (+ (/ 0.5 x) (+ x 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.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
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(((0.5f / x) + (x + 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.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) 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(Float32(Float32(0.5) / x) + Float32(x + 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.20000000298023224)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.10000000149011612)) 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(((single(0.5) / x) + (x + 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.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.10000000149011612:\\
\;\;\;\;\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(\frac{0.5}{x} + \left(x + 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.200000003Initial program 63.9%
expm1-log1p-u63.9%
expm1-udef63.9%
+-commutative63.9%
hypot-1-def99.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.3%
Applied egg-rr12.3%
expm1-def12.2%
expm1-log1p-u12.2%
+-commutative12.2%
Applied egg-rr12.2%
flip-+10.1%
log-div10.1%
hypot-udef10.5%
hypot-udef10.1%
metadata-eval10.1%
metadata-eval10.1%
add-sqr-sqrt11.1%
pow211.4%
pow211.1%
Applied egg-rr11.1%
associate--l+61.4%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 21.3%
log1p-expm1-u21.3%
expm1-udef21.3%
add-exp-log21.3%
add-sqr-sqrt10.1%
fabs-sqr10.1%
add-sqr-sqrt21.5%
+-commutative21.5%
hypot-1-def21.6%
Applied egg-rr21.6%
Taylor expanded in x around 0 100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 57.6%
Taylor expanded in x around inf 100.0%
associate-+r+100.0%
+-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ (/ 0.5 x) (+ x 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.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + 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.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) 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(Float32(Float32(0.5) / x) + Float32(x + 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.20000000298023224)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.10000000149011612)) 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(((single(0.5) / x) + (x + 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.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.10000000149011612:\\
\;\;\;\;\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(\frac{0.5}{x} + \left(x + 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.200000003Initial program 63.9%
expm1-log1p-u63.9%
expm1-udef63.9%
+-commutative63.9%
hypot-1-def99.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.3%
Applied egg-rr12.3%
expm1-def12.2%
expm1-log1p-u12.2%
+-commutative12.2%
Applied egg-rr12.2%
flip-+10.1%
log-div10.1%
hypot-udef10.5%
hypot-udef10.1%
metadata-eval10.1%
metadata-eval10.1%
add-sqr-sqrt11.1%
pow211.4%
pow211.1%
Applied egg-rr11.1%
associate--l+61.4%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 21.3%
log1p-expm1-u21.3%
expm1-udef21.3%
add-exp-log21.3%
add-sqr-sqrt10.1%
fabs-sqr10.1%
add-sqr-sqrt21.5%
+-commutative21.5%
hypot-1-def21.6%
Applied egg-rr21.6%
Taylor expanded in x around 0 100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 57.6%
Taylor expanded in x around inf 100.0%
associate-+r+100.0%
+-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.019999999552965164)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log1p (+ (hypot 1.0 x) (+ x -1.0))) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(log1pf((hypotf(1.0f, x) + (x + -1.0f))), 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.019999999552965164)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log1p(Float32(hypot(Float32(1.0), x) + Float32(x + Float32(-1.0)))), x); end return 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.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, x\right) + \left(x + -1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 64.8%
expm1-log1p-u64.8%
expm1-udef64.7%
+-commutative64.7%
hypot-1-def99.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.8%
Applied egg-rr14.8%
expm1-def14.7%
expm1-log1p-u14.7%
+-commutative14.7%
Applied egg-rr14.7%
flip-+12.7%
log-div12.6%
hypot-udef12.9%
hypot-udef12.4%
metadata-eval12.4%
metadata-eval12.4%
add-sqr-sqrt13.4%
pow213.7%
pow213.4%
Applied egg-rr13.4%
associate--l+62.3%
+-inverses99.6%
metadata-eval99.6%
metadata-eval99.6%
neg-sub099.6%
Simplified99.6%
if -0.0500000007 < x < 0.0199999996Initial program 19.6%
log1p-expm1-u19.6%
expm1-udef19.6%
add-exp-log19.6%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.8%
Applied egg-rr19.8%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 0.0199999996 < x Initial program 58.1%
log1p-expm1-u58.1%
expm1-udef58.1%
add-exp-log58.0%
add-sqr-sqrt58.0%
fabs-sqr58.0%
add-sqr-sqrt58.0%
+-commutative58.0%
hypot-1-def99.8%
Applied egg-rr99.8%
+-commutative99.8%
associate--l+99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -50.0)
(copysign (- (log (* x -2.0))) 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 <= -50.0f) {
tmp = copysignf(-logf((x * -2.0f)), 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(-50.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), 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(-50.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); 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 -50:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\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 < -50Initial program 62.9%
Taylor expanded in x around -inf 100.0%
sub-neg100.0%
neg-mul-1100.0%
unsub-neg100.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt98.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
+-inverses98.9%
+-lft-identity98.9%
clear-num98.9%
log-div99.0%
1-exp99.0%
+-inverses99.0%
add-log-exp99.0%
+-inverses99.0%
div-inv99.0%
metadata-eval99.0%
Applied egg-rr99.0%
neg-sub099.0%
Simplified99.0%
if -50 < x < 0.0199999996Initial program 22.0%
log1p-expm1-u22.0%
expm1-udef22.0%
add-exp-log22.0%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt22.1%
+-commutative22.1%
hypot-1-def22.2%
Applied egg-rr22.2%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
Simplified99.0%
if 0.0199999996 < x Initial program 58.1%
*-un-lft-identity58.1%
*-commutative58.1%
log-prod58.1%
+-commutative58.1%
hypot-1-def99.8%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.019999999552965164)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.019999999552965164)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 64.8%
expm1-log1p-u64.8%
expm1-udef64.7%
+-commutative64.7%
hypot-1-def99.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.8%
Applied egg-rr14.8%
expm1-def14.7%
expm1-log1p-u14.7%
+-commutative14.7%
Applied egg-rr14.7%
flip-+12.7%
log-div12.6%
hypot-udef12.9%
hypot-udef12.4%
metadata-eval12.4%
metadata-eval12.4%
add-sqr-sqrt13.4%
pow213.7%
pow213.4%
Applied egg-rr13.4%
associate--l+62.3%
+-inverses99.6%
metadata-eval99.6%
metadata-eval99.6%
neg-sub099.6%
Simplified99.6%
if -0.0500000007 < x < 0.0199999996Initial program 19.6%
log1p-expm1-u19.6%
expm1-udef19.6%
add-exp-log19.6%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.8%
Applied egg-rr19.8%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 0.0199999996 < x Initial program 58.1%
*-un-lft-identity58.1%
*-commutative58.1%
log-prod58.1%
+-commutative58.1%
hypot-1-def99.8%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -50.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -50.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-50.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + Float32(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-50.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -50:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -50Initial program 62.9%
Taylor expanded in x around -inf 100.0%
sub-neg100.0%
neg-mul-1100.0%
unsub-neg100.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt98.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
+-inverses98.9%
+-lft-identity98.9%
clear-num98.9%
log-div99.0%
1-exp99.0%
+-inverses99.0%
add-log-exp99.0%
+-inverses99.0%
div-inv99.0%
metadata-eval99.0%
Applied egg-rr99.0%
neg-sub099.0%
Simplified99.0%
if -50 < x < 0.100000001Initial program 22.5%
log1p-expm1-u22.5%
expm1-udef22.5%
add-exp-log22.5%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt22.6%
+-commutative22.6%
hypot-1-def22.7%
Applied egg-rr22.7%
Taylor expanded in x around 0 98.9%
*-commutative98.9%
Simplified98.9%
if 0.100000001 < x Initial program 57.6%
Taylor expanded in x around inf 100.0%
associate-+r+100.0%
+-commutative100.0%
associate-*r/100.0%
metadata-eval100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
Simplified100.0%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -50.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -50.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.10000000149011612f) {
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(-50.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.10000000149011612)) 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(-50.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.10000000149011612)) 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 -50:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\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 < -50Initial program 62.9%
Taylor expanded in x around -inf 100.0%
sub-neg100.0%
neg-mul-1100.0%
unsub-neg100.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt98.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
+-inverses98.9%
+-lft-identity98.9%
clear-num98.9%
log-div99.0%
1-exp99.0%
+-inverses99.0%
add-log-exp99.0%
+-inverses99.0%
div-inv99.0%
metadata-eval99.0%
Applied egg-rr99.0%
neg-sub099.0%
Simplified99.0%
if -50 < x < 0.100000001Initial program 22.5%
log1p-expm1-u22.5%
expm1-udef22.5%
add-exp-log22.5%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt22.6%
+-commutative22.6%
hypot-1-def22.7%
Applied egg-rr22.7%
Taylor expanded in x around 0 98.9%
*-commutative98.9%
Simplified98.9%
if 0.100000001 < x Initial program 57.6%
Taylor expanded in x around inf 97.9%
rem-square-sqrt97.9%
fabs-sqr97.9%
rem-square-sqrt97.9%
Simplified97.9%
Final simplification98.7%
(FPCore (x) :precision binary32 (if (<= x -50.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.10000000149011612) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -50.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-50.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.10000000149011612)) 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(-50.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.10000000149011612)) 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 -50:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -50Initial program 62.9%
Taylor expanded in x around -inf 100.0%
sub-neg100.0%
neg-mul-1100.0%
unsub-neg100.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt98.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in x around 0 -0.0%
mul-1-neg-0.0%
sub-neg-0.0%
log-div98.9%
Simplified98.9%
if -50 < x < 0.100000001Initial program 22.5%
Taylor expanded in x around 0 19.1%
rem-square-sqrt9.0%
fabs-sqr9.0%
rem-square-sqrt19.2%
Simplified19.2%
Taylor expanded in x around 0 97.3%
if 0.100000001 < x Initial program 57.6%
Taylor expanded in x around inf 97.9%
rem-square-sqrt97.9%
fabs-sqr97.9%
rem-square-sqrt97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x) :precision binary32 (if (<= x -50.0) (copysign (- (log (* x -2.0))) x) (if (<= x 0.10000000149011612) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -50.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-50.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.10000000149011612)) 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(-50.0)) tmp = sign(x) * abs(-log((x * single(-2.0)))); elseif (x <= single(0.10000000149011612)) 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 -50:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -50Initial program 62.9%
Taylor expanded in x around -inf 100.0%
sub-neg100.0%
neg-mul-1100.0%
unsub-neg100.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt98.9%
associate-*r/98.9%
metadata-eval98.9%
distribute-neg-frac98.9%
metadata-eval98.9%
Simplified98.9%
+-inverses98.9%
+-lft-identity98.9%
clear-num98.9%
log-div99.0%
1-exp99.0%
+-inverses99.0%
add-log-exp99.0%
+-inverses99.0%
div-inv99.0%
metadata-eval99.0%
Applied egg-rr99.0%
neg-sub099.0%
Simplified99.0%
if -50 < x < 0.100000001Initial program 22.5%
Taylor expanded in x around 0 19.1%
rem-square-sqrt9.0%
fabs-sqr9.0%
rem-square-sqrt19.2%
Simplified19.2%
Taylor expanded in x around 0 97.3%
if 0.100000001 < x Initial program 57.6%
Taylor expanded in x around inf 97.9%
rem-square-sqrt97.9%
fabs-sqr97.9%
rem-square-sqrt97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x) :precision binary32 (if (<= x 0.10000000149011612) (copysign x x) (copysign (log (+ x 1.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.10000000149011612f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + 1.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.10000000149011612)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + Float32(1.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(0.10000000149011612)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + single(1.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + 1\right), x\right)\\
\end{array}
\end{array}
if x < 0.100000001Initial program 35.7%
Taylor expanded in x around 0 27.4%
rem-square-sqrt6.0%
fabs-sqr6.0%
rem-square-sqrt12.9%
Simplified12.9%
Taylor expanded in x around 0 69.1%
if 0.100000001 < x Initial program 57.6%
Taylor expanded in x around 0 43.6%
rem-square-sqrt43.6%
fabs-sqr43.6%
rem-square-sqrt43.6%
Simplified43.6%
Final simplification62.7%
(FPCore (x) :precision binary32 (if (<= x 0.10000000149011612) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
if (x <= 0.10000000149011612f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.10000000149011612)) 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(0.10000000149011612)) 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 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < 0.100000001Initial program 35.7%
Taylor expanded in x around 0 27.4%
rem-square-sqrt6.0%
fabs-sqr6.0%
rem-square-sqrt12.9%
Simplified12.9%
Taylor expanded in x around 0 69.1%
if 0.100000001 < x Initial program 57.6%
Taylor expanded in x around inf 97.9%
rem-square-sqrt97.9%
fabs-sqr97.9%
rem-square-sqrt97.9%
Simplified97.9%
Final simplification76.3%
(FPCore (x) :precision binary32 (if (<= x 0.10000000149011612) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.10000000149011612f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.10000000149011612)) 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.10000000149011612:\\
\;\;\;\;\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.100000001Initial program 35.7%
Taylor expanded in x around 0 27.4%
rem-square-sqrt6.0%
fabs-sqr6.0%
rem-square-sqrt12.9%
Simplified12.9%
Taylor expanded in x around 0 69.1%
if 0.100000001 < x Initial program 57.6%
Taylor expanded in x around 0 43.6%
log1p-def43.6%
rem-square-sqrt43.6%
fabs-sqr43.6%
rem-square-sqrt43.6%
Simplified43.6%
Final simplification62.7%
(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.2%
Taylor expanded in x around 0 31.4%
rem-square-sqrt15.4%
fabs-sqr15.4%
rem-square-sqrt20.6%
Simplified20.6%
Taylor expanded in x around 0 54.8%
Final simplification54.8%
(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 2023322
(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))