
(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.20000000298023224)
(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.20000000298023224f) {
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.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.20000000298023224)) 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(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.20000000298023224)) 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.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.20000000298023224:\\
\;\;\;\;\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} + 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.200000003Initial program 52.6%
flip-+10.4%
frac-2neg10.4%
log-div10.3%
Applied egg-rr14.0%
neg-sub014.0%
associate--r-14.0%
neg-sub014.0%
+-commutative14.0%
fma-undefine14.0%
unpow214.0%
+-commutative14.0%
associate-+l+49.3%
sub-neg49.3%
+-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 -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 22.8%
*-un-lft-identity22.8%
*-commutative22.8%
log-prod22.8%
+-commutative22.8%
hypot-1-def22.8%
add-sqr-sqrt11.8%
fabs-sqr11.8%
add-sqr-sqrt22.6%
metadata-eval22.6%
Applied egg-rr22.6%
+-rgt-identity22.6%
Simplified22.6%
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 52.5%
*-un-lft-identity52.5%
*-commutative52.5%
log-prod52.5%
+-commutative52.5%
hypot-1-def100.0%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (* x -2.0) (/ 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 * -2.0f) - (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(Float32(-log(Float32(Float32(x * Float32(-2.0)) - 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 * single(-2.0)) - (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(x \cdot -2 - \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 51.9%
flip-+9.1%
frac-2neg9.1%
log-div9.1%
Applied egg-rr12.7%
neg-sub012.7%
associate--r-12.7%
neg-sub012.7%
+-commutative12.7%
fma-undefine12.7%
unpow212.7%
+-commutative12.7%
associate-+l+48.5%
sub-neg48.5%
+-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%
Taylor expanded in x around -inf 97.7%
*-commutative97.7%
associate-*r/97.7%
metadata-eval97.7%
Simplified97.7%
if -1 < x < 0.00499999989Initial program 22.9%
Taylor expanded in x around 0 23.0%
+-commutative23.0%
fma-define23.0%
rem-square-sqrt11.4%
fabs-sqr11.4%
rem-square-sqrt22.5%
log1p-define98.2%
rem-square-sqrt47.5%
fabs-sqr47.5%
rem-square-sqrt99.0%
Simplified99.0%
Taylor expanded in x around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 0.00499999989 < x Initial program 53.1%
*-un-lft-identity53.1%
*-commutative53.1%
log-prod53.1%
+-commutative53.1%
hypot-1-def99.8%
add-sqr-sqrt99.7%
fabs-sqr99.7%
add-sqr-sqrt99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(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.10000000149011612f) {
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.10000000149011612)) 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.10000000149011612)) 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.10000000149011612:\\
\;\;\;\;\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.100000001Initial program 53.1%
flip-+11.5%
frac-2neg11.5%
log-div11.5%
Applied egg-rr15.0%
neg-sub015.0%
associate--r-15.0%
neg-sub015.0%
+-commutative15.0%
fma-undefine15.0%
unpow215.0%
+-commutative15.0%
associate-+l+49.8%
sub-neg49.8%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
neg-sub099.8%
neg-sub099.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
if -0.100000001 < x < 0.00499999989Initial program 21.6%
Taylor expanded in x around 0 22.4%
+-commutative22.4%
fma-define22.4%
rem-square-sqrt11.6%
fabs-sqr11.6%
rem-square-sqrt22.2%
log1p-define99.2%
rem-square-sqrt48.3%
fabs-sqr48.3%
rem-square-sqrt99.7%
Simplified99.7%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 0.00499999989 < x Initial program 53.1%
*-un-lft-identity53.1%
*-commutative53.1%
log-prod53.1%
+-commutative53.1%
hypot-1-def99.8%
add-sqr-sqrt99.7%
fabs-sqr99.7%
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 -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + 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((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 51.9%
flip-+9.1%
frac-2neg9.1%
log-div9.1%
Applied egg-rr12.7%
neg-sub012.7%
associate--r-12.7%
neg-sub012.7%
+-commutative12.7%
fma-undefine12.7%
unpow212.7%
+-commutative12.7%
associate-+l+48.5%
sub-neg48.5%
+-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%
Taylor expanded in x around -inf 95.7%
*-commutative95.7%
Simplified95.7%
if -1 < x < 0.5Initial program 24.7%
Taylor expanded in x around 0 23.7%
+-commutative23.7%
fma-define23.7%
rem-square-sqrt12.4%
fabs-sqr12.4%
rem-square-sqrt23.3%
log1p-define97.1%
rem-square-sqrt47.6%
fabs-sqr47.6%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
Simplified98.5%
if 0.5 < x Initial program 51.1%
Taylor expanded in x around inf 98.9%
associate-+r+98.9%
+-commutative98.9%
associate-*r/98.9%
metadata-eval98.9%
rem-square-sqrt98.9%
fabs-sqr98.9%
rem-square-sqrt98.9%
Simplified98.9%
Final simplification97.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.5)
(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 <= -1.0f) {
tmp = copysignf(-logf(((x * -2.0f) - (0.5f / x))), x);
} else if (x <= 0.5f) {
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(-1.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + 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(((x * single(-2.0)) - (single(0.5) / x)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 51.9%
flip-+9.1%
frac-2neg9.1%
log-div9.1%
Applied egg-rr12.7%
neg-sub012.7%
associate--r-12.7%
neg-sub012.7%
+-commutative12.7%
fma-undefine12.7%
unpow212.7%
+-commutative12.7%
associate-+l+48.5%
sub-neg48.5%
+-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%
Taylor expanded in x around -inf 97.7%
*-commutative97.7%
associate-*r/97.7%
metadata-eval97.7%
Simplified97.7%
if -1 < x < 0.5Initial program 24.7%
Taylor expanded in x around 0 23.7%
+-commutative23.7%
fma-define23.7%
rem-square-sqrt12.4%
fabs-sqr12.4%
rem-square-sqrt23.3%
log1p-define97.1%
rem-square-sqrt47.6%
fabs-sqr47.6%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
Simplified98.5%
if 0.5 < x Initial program 51.1%
Taylor expanded in x around inf 98.9%
associate-+r+98.9%
+-commutative98.9%
associate-*r/98.9%
metadata-eval98.9%
rem-square-sqrt98.9%
fabs-sqr98.9%
rem-square-sqrt98.9%
Simplified98.9%
Final simplification98.4%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(-logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(-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((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(-log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 51.9%
flip-+9.1%
frac-2neg9.1%
log-div9.1%
Applied egg-rr12.7%
neg-sub012.7%
associate--r-12.7%
neg-sub012.7%
+-commutative12.7%
fma-undefine12.7%
unpow212.7%
+-commutative12.7%
associate-+l+48.5%
sub-neg48.5%
+-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%
Taylor expanded in x around -inf 95.7%
*-commutative95.7%
Simplified95.7%
if -1 < x < 0.5Initial program 24.7%
Taylor expanded in x around 0 23.7%
+-commutative23.7%
fma-define23.7%
rem-square-sqrt12.4%
fabs-sqr12.4%
rem-square-sqrt23.3%
log1p-define97.1%
rem-square-sqrt47.6%
fabs-sqr47.6%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
Simplified98.5%
if 0.5 < x Initial program 51.1%
flip-+7.1%
frac-2neg7.1%
log-div7.1%
Applied egg-rr7.2%
neg-sub07.2%
associate--r-7.2%
neg-sub07.2%
+-commutative7.2%
fma-undefine7.2%
unpow27.2%
+-commutative7.2%
associate-+l+9.5%
sub-neg9.5%
+-inverses12.9%
metadata-eval12.9%
metadata-eval12.9%
neg-sub012.9%
neg-sub012.9%
associate--r-12.9%
neg-sub012.9%
+-commutative12.9%
sub-neg12.9%
Simplified12.9%
Taylor expanded in x around inf 97.9%
Final simplification97.6%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (- (log (* x -2.0))) x) (if (<= x 0.5) (copysign x x) (copysign (- (log (/ 0.5 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(-logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(Float32(-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((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(-log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 51.9%
flip-+9.1%
frac-2neg9.1%
log-div9.1%
Applied egg-rr12.7%
neg-sub012.7%
associate--r-12.7%
neg-sub012.7%
+-commutative12.7%
fma-undefine12.7%
unpow212.7%
+-commutative12.7%
associate-+l+48.5%
sub-neg48.5%
+-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%
Taylor expanded in x around -inf 95.7%
*-commutative95.7%
Simplified95.7%
if -1 < x < 0.5Initial program 24.7%
Taylor expanded in x around 0 23.7%
+-commutative23.7%
fma-define23.7%
rem-square-sqrt12.4%
fabs-sqr12.4%
rem-square-sqrt23.3%
log1p-define97.1%
rem-square-sqrt47.6%
fabs-sqr47.6%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around 0 97.2%
if 0.5 < x Initial program 51.1%
flip-+7.1%
frac-2neg7.1%
log-div7.1%
Applied egg-rr7.2%
neg-sub07.2%
associate--r-7.2%
neg-sub07.2%
+-commutative7.2%
fma-undefine7.2%
unpow27.2%
+-commutative7.2%
associate-+l+9.5%
sub-neg9.5%
+-inverses12.9%
metadata-eval12.9%
metadata-eval12.9%
neg-sub012.9%
neg-sub012.9%
associate--r-12.9%
neg-sub012.9%
+-commutative12.9%
sub-neg12.9%
Simplified12.9%
Taylor expanded in x around inf 97.9%
Final simplification96.9%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
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(-0.5) / x)), x); elseif (x <= Float32(0.5)) 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(-0.5) / x))); elseif (x <= single(0.5)) 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{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 51.9%
Taylor expanded in x around -inf 97.7%
sub-neg97.7%
neg-mul-197.7%
associate-+r+97.7%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt11.3%
+-commutative11.3%
unsub-neg11.3%
associate-*r/11.3%
metadata-eval11.3%
distribute-neg-frac11.3%
metadata-eval11.3%
Simplified11.3%
*-un-lft-identity11.3%
log-prod11.3%
metadata-eval11.3%
Applied egg-rr11.3%
+-lft-identity11.3%
+-commutative11.3%
sub-neg11.3%
metadata-eval11.3%
distribute-neg-frac11.3%
metadata-eval11.3%
associate-*r/11.3%
associate-+l+95.7%
+-commutative95.7%
sub-neg95.7%
+-inverses95.7%
+-rgt-identity95.7%
distribute-lft-neg-in95.7%
metadata-eval95.7%
associate-*r/95.7%
metadata-eval95.7%
Simplified95.7%
if -1 < x < 0.5Initial program 24.7%
Taylor expanded in x around 0 23.7%
+-commutative23.7%
fma-define23.7%
rem-square-sqrt12.4%
fabs-sqr12.4%
rem-square-sqrt23.3%
log1p-define97.1%
rem-square-sqrt47.6%
fabs-sqr47.6%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around 0 97.2%
if 0.5 < x Initial program 51.1%
Taylor expanded in x around inf 97.9%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.9%
Simplified97.9%
Final simplification96.9%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (- (log (* x -2.0))) x) (if (<= x 0.5) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) 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((x * single(-2.0)))); elseif (x <= single(0.5)) 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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 51.9%
flip-+9.1%
frac-2neg9.1%
log-div9.1%
Applied egg-rr12.7%
neg-sub012.7%
associate--r-12.7%
neg-sub012.7%
+-commutative12.7%
fma-undefine12.7%
unpow212.7%
+-commutative12.7%
associate-+l+48.5%
sub-neg48.5%
+-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%
Taylor expanded in x around -inf 95.7%
*-commutative95.7%
Simplified95.7%
if -1 < x < 0.5Initial program 24.7%
Taylor expanded in x around 0 23.7%
+-commutative23.7%
fma-define23.7%
rem-square-sqrt12.4%
fabs-sqr12.4%
rem-square-sqrt23.3%
log1p-define97.1%
rem-square-sqrt47.6%
fabs-sqr47.6%
rem-square-sqrt97.8%
Simplified97.8%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around 0 97.2%
if 0.5 < x Initial program 51.1%
Taylor expanded in x around inf 97.9%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.9%
Simplified97.9%
Final simplification96.9%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log (+ x 1.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
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.5)) 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.5)) 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.5:\\
\;\;\;\;\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.5Initial program 34.4%
Taylor expanded in x around 0 19.2%
+-commutative19.2%
fma-define19.2%
rem-square-sqrt8.0%
fabs-sqr8.0%
rem-square-sqrt19.1%
log1p-define66.3%
rem-square-sqrt30.5%
fabs-sqr30.5%
rem-square-sqrt62.6%
Simplified62.6%
Taylor expanded in x around 0 66.2%
*-commutative66.2%
Simplified66.2%
Taylor expanded in x around 0 66.4%
if 0.5 < x Initial program 51.1%
Taylor expanded in x around 0 44.3%
rem-square-sqrt44.3%
fabs-sqr44.3%
rem-square-sqrt44.3%
Simplified44.3%
Final simplification60.6%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) 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.5)) 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.5:\\
\;\;\;\;\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.5Initial program 34.4%
Taylor expanded in x around 0 19.2%
+-commutative19.2%
fma-define19.2%
rem-square-sqrt8.0%
fabs-sqr8.0%
rem-square-sqrt19.1%
log1p-define66.3%
rem-square-sqrt30.5%
fabs-sqr30.5%
rem-square-sqrt62.6%
Simplified62.6%
Taylor expanded in x around 0 66.2%
*-commutative66.2%
Simplified66.2%
Taylor expanded in x around 0 66.4%
if 0.5 < x Initial program 51.1%
Taylor expanded in x around inf 97.9%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.9%
Simplified97.9%
Final simplification74.7%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 34.4%
Taylor expanded in x around 0 19.2%
+-commutative19.2%
fma-define19.2%
rem-square-sqrt8.0%
fabs-sqr8.0%
rem-square-sqrt19.1%
log1p-define66.3%
rem-square-sqrt30.5%
fabs-sqr30.5%
rem-square-sqrt62.6%
Simplified62.6%
Taylor expanded in x around 0 66.2%
*-commutative66.2%
Simplified66.2%
Taylor expanded in x around 0 66.4%
if 0.5 < x Initial program 51.1%
Taylor expanded in x around 0 44.3%
log1p-define44.3%
rem-square-sqrt44.3%
fabs-sqr44.3%
rem-square-sqrt44.3%
Simplified44.3%
Final simplification60.6%
(FPCore (x) :precision binary32 (copysign x x))
float code(float x) {
return copysignf(x, x);
}
function code(x) return copysign(x, x) end
function tmp = code(x) tmp = sign(x) * abs(x); end
\begin{array}{l}
\\
\mathsf{copysign}\left(x, x\right)
\end{array}
Initial program 38.8%
Taylor expanded in x around 0 17.0%
+-commutative17.0%
fma-define17.0%
rem-square-sqrt8.7%
fabs-sqr8.7%
rem-square-sqrt16.8%
log1p-define51.7%
rem-square-sqrt25.3%
fabs-sqr25.3%
rem-square-sqrt49.0%
Simplified49.0%
Taylor expanded in x around 0 51.0%
*-commutative51.0%
Simplified51.0%
Taylor expanded in x around 0 52.0%
Final simplification52.0%
(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 2024044
(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))