
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.100000001Initial program 55.7%
flip-+11.3%
frac-2neg11.3%
log-div11.4%
Applied egg-rr15.9%
neg-sub015.9%
associate--r-15.9%
neg-sub015.9%
+-commutative15.9%
fma-undefine16.4%
unpow216.4%
+-commutative16.4%
associate-+l+52.7%
sub-neg52.7%
+-inverses99.7%
metadata-eval99.7%
metadata-eval99.7%
neg-sub099.7%
neg-sub099.7%
associate--r-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
Simplified99.7%
if -0.100000001 < x < 0.0500000007Initial program 20.8%
log1p-expm1-u20.8%
expm1-undefine20.8%
add-exp-log20.8%
add-sqr-sqrt8.7%
fabs-sqr8.7%
add-sqr-sqrt20.8%
+-commutative20.8%
hypot-1-def20.7%
Applied egg-rr20.7%
Taylor expanded in x around 0 99.9%
distribute-lft-in99.9%
*-rgt-identity99.9%
*-commutative99.9%
associate-*r*99.9%
unpow299.9%
cube-mult99.9%
Simplified99.9%
if 0.0500000007 < x Initial program 60.9%
*-un-lft-identity60.9%
*-commutative60.9%
log-prod60.9%
*-un-lft-identity60.9%
*-un-lft-identity60.9%
add-sqr-sqrt60.8%
fabs-sqr60.8%
add-sqr-sqrt60.9%
+-commutative60.9%
hypot-1-def99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x) :precision binary32 (if (<= (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x) -1.0) (copysign (- (log (- (hypot 1.0 x) x))) x) (copysign (log1p (+ x (+ -1.0 (hypot 1.0 x)))) x)))
float code(float x) {
float tmp;
if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= -1.0f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else {
tmp = copysignf(log1pf((x + (-1.0f + hypotf(1.0f, x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); else tmp = copysign(log1p(Float32(x + Float32(Float32(-1.0) + hypot(Float32(1.0), x)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right) \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x + \left(-1 + \mathsf{hypot}\left(1, x\right)\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) < -1Initial program 54.0%
flip-+7.3%
frac-2neg7.3%
log-div7.4%
Applied egg-rr12.1%
neg-sub012.1%
associate--r-12.1%
neg-sub012.1%
+-commutative12.1%
fma-undefine12.6%
unpow212.6%
+-commutative12.6%
associate-+l+50.8%
sub-neg50.8%
+-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
neg-sub0100.0%
neg-sub0100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) #s(literal 1 binary32))))) x) Initial program 35.4%
log1p-expm1-u35.4%
expm1-undefine35.4%
add-exp-log35.4%
add-sqr-sqrt26.1%
fabs-sqr26.1%
add-sqr-sqrt35.4%
+-commutative35.4%
hypot-1-def48.5%
Applied egg-rr48.5%
associate--l+97.8%
+-commutative97.8%
sub-neg97.8%
metadata-eval97.8%
Applied egg-rr97.8%
Final simplification98.3%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), 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(-0.5) / x)), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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 54.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
*-commutative99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
unsub-neg99.2%
sub-neg99.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.5%
associate-*r/11.5%
metadata-eval11.5%
distribute-neg-frac11.5%
metadata-eval11.5%
Simplified11.5%
Taylor expanded in x around 0 97.9%
if -1 < x < 0.0500000007Initial program 22.5%
log1p-expm1-u22.5%
expm1-undefine22.5%
add-exp-log22.5%
add-sqr-sqrt8.5%
fabs-sqr8.5%
add-sqr-sqrt22.5%
+-commutative22.5%
hypot-1-def22.5%
Applied egg-rr22.5%
Taylor expanded in x around 0 99.2%
distribute-lft-in99.2%
*-rgt-identity99.2%
*-commutative99.2%
associate-*r*99.2%
unpow299.2%
cube-mult99.2%
Simplified99.2%
if 0.0500000007 < x Initial program 60.9%
*-un-lft-identity60.9%
*-commutative60.9%
log-prod60.9%
*-un-lft-identity60.9%
*-un-lft-identity60.9%
add-sqr-sqrt60.8%
fabs-sqr60.8%
add-sqr-sqrt60.9%
+-commutative60.9%
hypot-1-def99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.0%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.05000000074505806)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else if (x <= 0.05000000074505806f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), 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(abs(x) - x)), x); elseif (x <= Float32(0.05000000074505806)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), 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((abs(x) - x))); elseif (x <= single(0.05000000074505806)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); 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\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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 54.0%
Taylor expanded in x around -inf 98.0%
neg-mul-198.0%
Simplified98.0%
if -1 < x < 0.0500000007Initial program 22.5%
log1p-expm1-u22.5%
expm1-undefine22.5%
add-exp-log22.5%
add-sqr-sqrt8.5%
fabs-sqr8.5%
add-sqr-sqrt22.5%
+-commutative22.5%
hypot-1-def22.5%
Applied egg-rr22.5%
Taylor expanded in x around 0 99.2%
distribute-lft-in99.2%
*-rgt-identity99.2%
*-commutative99.2%
associate-*r*99.2%
unpow299.2%
cube-mult99.2%
Simplified99.2%
if 0.0500000007 < x Initial program 60.9%
*-un-lft-identity60.9%
*-commutative60.9%
log-prod60.9%
*-un-lft-identity60.9%
*-un-lft-identity60.9%
add-sqr-sqrt60.8%
fabs-sqr60.8%
add-sqr-sqrt60.9%
+-commutative60.9%
hypot-1-def99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.0%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log1p (* x (+ 2.0 (/ (+ -1.0 (/ 0.5 x)) x)))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(log1pf((x * (2.0f + ((-1.0f + (0.5f / x)) / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(log1p(Float32(x * Float32(Float32(2.0) + Float32(Float32(Float32(-1.0) + Float32(Float32(0.5) / x)) / x)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x \cdot \left(2 + \frac{-1 + \frac{0.5}{x}}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 54.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
*-commutative99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
unsub-neg99.2%
sub-neg99.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.5%
associate-*r/11.5%
metadata-eval11.5%
distribute-neg-frac11.5%
metadata-eval11.5%
Simplified11.5%
Taylor expanded in x around 0 97.9%
if -1 < x < 0.100000001Initial program 23.6%
log1p-expm1-u23.6%
expm1-undefine23.6%
add-exp-log23.6%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt23.6%
+-commutative23.6%
hypot-1-def23.6%
Applied egg-rr23.6%
Taylor expanded in x around 0 99.0%
distribute-lft-in99.0%
*-rgt-identity99.0%
*-commutative99.0%
associate-*r*99.0%
unpow299.0%
cube-mult99.0%
Simplified99.0%
if 0.100000001 < x Initial program 59.9%
log1p-expm1-u59.9%
expm1-undefine59.9%
add-exp-log59.9%
add-sqr-sqrt59.8%
fabs-sqr59.8%
add-sqr-sqrt59.9%
+-commutative59.9%
hypot-1-def100.0%
Applied egg-rr100.0%
+-commutative100.0%
associate--l+100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 98.7%
associate--l+98.7%
unpow298.7%
associate-/l/98.7%
metadata-eval98.7%
associate-*r/98.7%
div-sub98.7%
sub-neg98.7%
associate-*r/98.7%
metadata-eval98.7%
metadata-eval98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (* x (+ 1.0 (/ x x)))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x * (1.0f + (x / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(log(Float32(x * Float32(Float32(1.0) + Float32(x / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(log((x * (single(1.0) + (x / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot \left(1 + \frac{x}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 54.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
*-commutative99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
unsub-neg99.2%
sub-neg99.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.5%
associate-*r/11.5%
metadata-eval11.5%
distribute-neg-frac11.5%
metadata-eval11.5%
Simplified11.5%
Taylor expanded in x around 0 97.9%
if -1 < x < 0.100000001Initial program 23.6%
log1p-expm1-u23.6%
expm1-undefine23.6%
add-exp-log23.6%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt23.6%
+-commutative23.6%
hypot-1-def23.6%
Applied egg-rr23.6%
Taylor expanded in x around 0 99.0%
distribute-lft-in99.0%
*-rgt-identity99.0%
*-commutative99.0%
associate-*r*99.0%
unpow299.0%
cube-mult99.0%
Simplified99.0%
if 0.100000001 < x Initial program 59.9%
Taylor expanded in x around inf 96.3%
rem-square-sqrt96.3%
fabs-sqr96.3%
rem-square-sqrt96.3%
Simplified96.3%
Final simplification98.1%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), 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(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 54.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
*-commutative99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
unsub-neg99.2%
sub-neg99.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.5%
associate-*r/11.5%
metadata-eval11.5%
distribute-neg-frac11.5%
metadata-eval11.5%
Simplified11.5%
Taylor expanded in x around 0 97.9%
if -1 < x < 0.100000001Initial program 23.6%
log1p-expm1-u23.6%
expm1-undefine23.6%
add-exp-log23.6%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt23.6%
+-commutative23.6%
hypot-1-def23.6%
Applied egg-rr23.6%
Taylor expanded in x around 0 99.0%
distribute-lft-in99.0%
*-rgt-identity99.0%
*-commutative99.0%
associate-*r*99.0%
unpow299.0%
cube-mult99.0%
Simplified99.0%
if 0.100000001 < x Initial program 59.9%
Taylor expanded in x around -inf 5.5%
mul-1-neg5.5%
*-commutative5.5%
distribute-rgt-neg-in5.5%
mul-1-neg5.5%
unsub-neg5.5%
sub-neg5.5%
rem-square-sqrt10.2%
fabs-sqr10.2%
rem-square-sqrt5.5%
associate-*r/5.5%
metadata-eval5.5%
distribute-neg-frac5.5%
metadata-eval5.5%
Simplified5.5%
frac-2neg5.5%
div-inv5.5%
add-sqr-sqrt-0.0%
sqrt-unprod13.7%
sqr-neg13.7%
sqrt-prod13.7%
add-sqr-sqrt13.7%
cancel-sign-sub-inv13.7%
div-inv13.7%
Applied egg-rr13.7%
Taylor expanded in x around 0 96.2%
Final simplification98.1%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign x x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.10000000149011612)) 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(-1.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((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\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 < -1Initial program 54.0%
Taylor expanded in x around -inf 99.2%
mul-1-neg99.2%
*-commutative99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
unsub-neg99.2%
sub-neg99.2%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.5%
associate-*r/11.5%
metadata-eval11.5%
distribute-neg-frac11.5%
metadata-eval11.5%
Simplified11.5%
Taylor expanded in x around 0 97.9%
if -1 < x < 0.100000001Initial program 23.6%
log1p-expm1-u23.6%
expm1-undefine23.6%
add-exp-log23.6%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt23.6%
+-commutative23.6%
hypot-1-def23.6%
Applied egg-rr23.6%
Taylor expanded in x around 0 99.6%
Taylor expanded in x around 0 97.2%
if 0.100000001 < x Initial program 59.9%
Taylor expanded in x around -inf 5.5%
mul-1-neg5.5%
*-commutative5.5%
distribute-rgt-neg-in5.5%
mul-1-neg5.5%
unsub-neg5.5%
sub-neg5.5%
rem-square-sqrt10.2%
fabs-sqr10.2%
rem-square-sqrt5.5%
associate-*r/5.5%
metadata-eval5.5%
distribute-neg-frac5.5%
metadata-eval5.5%
Simplified5.5%
frac-2neg5.5%
div-inv5.5%
add-sqr-sqrt-0.0%
sqrt-unprod13.7%
sqr-neg13.7%
sqrt-prod13.7%
add-sqr-sqrt13.7%
cancel-sign-sub-inv13.7%
div-inv13.7%
Applied egg-rr13.7%
Taylor expanded in x around 0 96.2%
Final simplification97.1%
(FPCore (x) :precision binary32 (if (<= x -0.20000000298023224) (copysign (log (/ -0.5 x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -0.20000000298023224f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.20000000298023224)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -0.200000003Initial program 54.6%
Taylor expanded in x around -inf 98.0%
mul-1-neg98.0%
*-commutative98.0%
distribute-rgt-neg-in98.0%
mul-1-neg98.0%
unsub-neg98.0%
sub-neg98.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.9%
associate-*r/11.9%
metadata-eval11.9%
distribute-neg-frac11.9%
metadata-eval11.9%
Simplified11.9%
Taylor expanded in x around 0 97.0%
if -0.200000003 < x Initial program 35.1%
Taylor expanded in x around 0 27.7%
log1p-define77.2%
rem-square-sqrt41.1%
fabs-sqr41.1%
rem-square-sqrt77.2%
Simplified77.2%
Final simplification82.1%
(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 33.5%
log1p-expm1-u33.5%
expm1-undefine33.5%
add-exp-log33.5%
add-sqr-sqrt6.6%
fabs-sqr6.6%
add-sqr-sqrt20.1%
+-commutative20.1%
hypot-1-def19.9%
Applied egg-rr19.9%
Taylor expanded in x around 0 70.2%
Taylor expanded in x around 0 69.2%
if 0.100000001 < x Initial program 59.9%
Taylor expanded in x around 0 43.9%
log1p-define43.9%
rem-square-sqrt43.9%
fabs-sqr43.9%
rem-square-sqrt43.9%
Simplified43.9%
Final simplification63.0%
(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 40.0%
log1p-expm1-u40.0%
expm1-undefine40.0%
add-exp-log40.0%
add-sqr-sqrt19.7%
fabs-sqr19.7%
add-sqr-sqrt29.9%
+-commutative29.9%
hypot-1-def39.6%
Applied egg-rr39.6%
Taylor expanded in x around 0 55.5%
Taylor expanded in x around 0 55.1%
Final simplification55.1%
(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 2024080
(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))