
(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 10 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.075 (pow x 5.0)) (* -0.16666666666666666 (pow x 3.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.10000000149011612f) {
tmp = copysignf((x + ((0.075f * powf(x, 5.0f)) + (-0.16666666666666666f * powf(x, 3.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.10000000149011612)) tmp = copysign(Float32(x + Float32(Float32(Float32(0.075) * (x ^ Float32(5.0))) + 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) 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.075) * (x ^ single(5.0))) + (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}
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.075 \cdot {x}^{5} + -0.16666666666666666 \cdot {x}^{3}\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 58.0%
*-un-lft-identity58.0%
*-commutative58.0%
log-prod58.0%
*-un-lft-identity58.0%
*-un-lft-identity58.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.7%
+-commutative14.7%
hypot-1-def14.7%
metadata-eval14.7%
Applied egg-rr14.7%
+-rgt-identity14.7%
Simplified14.7%
flip-+13.8%
unpow213.8%
div-sub11.8%
hypot-undefine11.7%
metadata-eval11.7%
unpow211.7%
hypot-undefine11.6%
metadata-eval11.6%
unpow211.6%
add-sqr-sqrt11.7%
Applied egg-rr11.7%
+-commutative11.7%
unpow211.7%
fma-undefine12.2%
div-sub15.0%
*-lft-identity15.0%
*-lft-identity15.0%
times-frac15.0%
metadata-eval15.0%
metadata-eval15.0%
times-frac15.0%
fma-undefine14.5%
unpow214.5%
+-commutative14.5%
neg-mul-114.5%
neg-mul-114.5%
Simplified99.9%
log-div100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 17.7%
*-un-lft-identity17.7%
*-commutative17.7%
log-prod17.7%
*-un-lft-identity17.7%
*-un-lft-identity17.7%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt17.9%
+-commutative17.9%
hypot-1-def17.9%
metadata-eval17.9%
Applied egg-rr17.9%
+-rgt-identity17.9%
Simplified17.9%
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 52.4%
*-un-lft-identity52.4%
*-commutative52.4%
log-prod52.4%
*-un-lft-identity52.4%
*-un-lft-identity52.4%
add-sqr-sqrt52.3%
fabs-sqr52.3%
add-sqr-sqrt52.4%
+-commutative52.4%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ 1.0 (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.05000000074505806)
(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((1.0f / ((x * -2.0f) - (0.5f / x)))), x);
} else if (x <= 0.05000000074505806f) {
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(1.0) / Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(0.05000000074505806)) 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((single(1.0) / ((x * single(-2.0)) - (single(0.5) / x))))); elseif (x <= single(0.05000000074505806)) 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(\frac{1}{x \cdot -2 - \frac{0.5}{x}}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\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 56.8%
*-un-lft-identity56.8%
*-commutative56.8%
log-prod56.8%
*-un-lft-identity56.8%
*-un-lft-identity56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
+-commutative12.2%
hypot-1-def12.2%
metadata-eval12.2%
Applied egg-rr12.2%
+-rgt-identity12.2%
Simplified12.2%
flip-+11.3%
unpow211.3%
div-sub9.1%
hypot-undefine9.1%
metadata-eval9.1%
unpow29.1%
hypot-undefine9.1%
metadata-eval9.1%
unpow29.1%
add-sqr-sqrt9.1%
Applied egg-rr9.1%
+-commutative9.1%
unpow29.1%
fma-undefine9.6%
div-sub12.5%
*-lft-identity12.5%
*-lft-identity12.5%
times-frac12.5%
metadata-eval12.5%
metadata-eval12.5%
times-frac12.5%
fma-undefine12.0%
unpow212.0%
+-commutative12.0%
neg-mul-112.0%
neg-mul-112.0%
Simplified99.9%
Taylor expanded in x around -inf 99.2%
*-commutative99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
if -1 < x < 0.0500000007Initial program 18.3%
*-un-lft-identity18.3%
*-commutative18.3%
log-prod18.3%
*-un-lft-identity18.3%
*-un-lft-identity18.3%
add-sqr-sqrt8.7%
fabs-sqr8.7%
add-sqr-sqrt18.5%
+-commutative18.5%
hypot-1-def18.6%
metadata-eval18.6%
Applied egg-rr18.6%
+-rgt-identity18.6%
Simplified18.6%
Taylor expanded in x around 0 99.2%
*-commutative99.2%
Simplified99.2%
if 0.0500000007 < x Initial program 53.1%
*-un-lft-identity53.1%
*-commutative53.1%
log-prod53.1%
*-un-lft-identity53.1%
*-un-lft-identity53.1%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt53.1%
+-commutative53.1%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.4%
(FPCore (x)
:precision binary32
(if (<= x -0.20000000298023224)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.05000000074505806)
(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.20000000298023224f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.05000000074505806f) {
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.20000000298023224)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.05000000074505806)) 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.20000000298023224)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.05000000074505806)) 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.20000000298023224:\\
\;\;\;\;\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 + -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.200000003Initial program 58.0%
*-un-lft-identity58.0%
*-commutative58.0%
log-prod58.0%
*-un-lft-identity58.0%
*-un-lft-identity58.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.7%
+-commutative14.7%
hypot-1-def14.7%
metadata-eval14.7%
Applied egg-rr14.7%
+-rgt-identity14.7%
Simplified14.7%
flip-+13.8%
unpow213.8%
div-sub11.8%
hypot-undefine11.7%
metadata-eval11.7%
unpow211.7%
hypot-undefine11.6%
metadata-eval11.6%
unpow211.6%
add-sqr-sqrt11.7%
Applied egg-rr11.7%
+-commutative11.7%
unpow211.7%
fma-undefine12.2%
div-sub15.0%
*-lft-identity15.0%
*-lft-identity15.0%
times-frac15.0%
metadata-eval15.0%
metadata-eval15.0%
times-frac15.0%
fma-undefine14.5%
unpow214.5%
+-commutative14.5%
neg-mul-114.5%
neg-mul-114.5%
Simplified99.9%
log-div100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-lft-identity100.0%
Simplified100.0%
if -0.200000003 < x < 0.0500000007Initial program 17.0%
*-un-lft-identity17.0%
*-commutative17.0%
log-prod17.0%
*-un-lft-identity17.0%
*-un-lft-identity17.0%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt17.3%
+-commutative17.3%
hypot-1-def17.3%
metadata-eval17.3%
Applied egg-rr17.3%
+-rgt-identity17.3%
Simplified17.3%
Taylor expanded in x around 0 99.9%
*-commutative99.9%
Simplified99.9%
if 0.0500000007 < x Initial program 53.1%
*-un-lft-identity53.1%
*-commutative53.1%
log-prod53.1%
*-un-lft-identity53.1%
*-un-lft-identity53.1%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt53.1%
+-commutative53.1%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(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(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((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(((x * single(2.0)) + (single(0.5) * (single(1.0) / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\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(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 56.8%
*-un-lft-identity56.8%
*-commutative56.8%
log-prod56.8%
*-un-lft-identity56.8%
*-un-lft-identity56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
+-commutative12.2%
hypot-1-def12.2%
metadata-eval12.2%
Applied egg-rr12.2%
+-rgt-identity12.2%
Simplified12.2%
Taylor expanded in x around -inf 98.3%
if -1 < x < 0.5Initial program 19.5%
*-un-lft-identity19.5%
*-commutative19.5%
log-prod19.5%
*-un-lft-identity19.5%
*-un-lft-identity19.5%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.8%
metadata-eval19.8%
Applied egg-rr19.8%
+-rgt-identity19.8%
Simplified19.8%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
Simplified98.8%
if 0.5 < x Initial program 51.8%
*-un-lft-identity51.8%
*-commutative51.8%
log-prod51.8%
*-un-lft-identity51.8%
*-un-lft-identity51.8%
add-sqr-sqrt51.7%
fabs-sqr51.7%
add-sqr-sqrt51.8%
+-commutative51.8%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.9%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ 1.0 (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((1.0f / ((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(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(1.0) / 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(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((single(1.0) / ((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(((x * single(2.0)) + (single(0.5) * (single(1.0) / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{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(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 56.8%
*-un-lft-identity56.8%
*-commutative56.8%
log-prod56.8%
*-un-lft-identity56.8%
*-un-lft-identity56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
+-commutative12.2%
hypot-1-def12.2%
metadata-eval12.2%
Applied egg-rr12.2%
+-rgt-identity12.2%
Simplified12.2%
flip-+11.3%
unpow211.3%
div-sub9.1%
hypot-undefine9.1%
metadata-eval9.1%
unpow29.1%
hypot-undefine9.1%
metadata-eval9.1%
unpow29.1%
add-sqr-sqrt9.1%
Applied egg-rr9.1%
+-commutative9.1%
unpow29.1%
fma-undefine9.6%
div-sub12.5%
*-lft-identity12.5%
*-lft-identity12.5%
times-frac12.5%
metadata-eval12.5%
metadata-eval12.5%
times-frac12.5%
fma-undefine12.0%
unpow212.0%
+-commutative12.0%
neg-mul-112.0%
neg-mul-112.0%
Simplified99.9%
Taylor expanded in x around -inf 99.2%
*-commutative99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
if -1 < x < 0.5Initial program 19.5%
*-un-lft-identity19.5%
*-commutative19.5%
log-prod19.5%
*-un-lft-identity19.5%
*-un-lft-identity19.5%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.8%
metadata-eval19.8%
Applied egg-rr19.8%
+-rgt-identity19.8%
Simplified19.8%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
Simplified98.8%
if 0.5 < x Initial program 51.8%
*-un-lft-identity51.8%
*-commutative51.8%
log-prod51.8%
*-un-lft-identity51.8%
*-un-lft-identity51.8%
add-sqr-sqrt51.7%
fabs-sqr51.7%
add-sqr-sqrt51.8%
+-commutative51.8%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.9%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) 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 + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), 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(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x * Float32(2.0))), 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 + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x * single(2.0)))); 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 + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 56.8%
*-un-lft-identity56.8%
*-commutative56.8%
log-prod56.8%
*-un-lft-identity56.8%
*-un-lft-identity56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
+-commutative12.2%
hypot-1-def12.2%
metadata-eval12.2%
Applied egg-rr12.2%
+-rgt-identity12.2%
Simplified12.2%
Taylor expanded in x around -inf 98.3%
if -1 < x < 0.5Initial program 19.5%
*-un-lft-identity19.5%
*-commutative19.5%
log-prod19.5%
*-un-lft-identity19.5%
*-un-lft-identity19.5%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.8%
metadata-eval19.8%
Applied egg-rr19.8%
+-rgt-identity19.8%
Simplified19.8%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
Simplified98.8%
if 0.5 < x Initial program 51.8%
*-un-lft-identity51.8%
*-commutative51.8%
log-prod51.8%
*-un-lft-identity51.8%
*-un-lft-identity51.8%
add-sqr-sqrt51.7%
fabs-sqr51.7%
add-sqr-sqrt51.8%
+-commutative51.8%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 96.8%
*-commutative96.8%
Simplified96.8%
Final simplification98.2%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) 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 * 2.0f)), 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 * Float32(2.0))), 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 * single(2.0)))); 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 \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 56.8%
*-un-lft-identity56.8%
*-commutative56.8%
log-prod56.8%
*-un-lft-identity56.8%
*-un-lft-identity56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
+-commutative12.2%
hypot-1-def12.2%
metadata-eval12.2%
Applied egg-rr12.2%
+-rgt-identity12.2%
Simplified12.2%
Taylor expanded in x around -inf 98.3%
if -1 < x < 0.5Initial program 19.5%
*-un-lft-identity19.5%
*-commutative19.5%
log-prod19.5%
*-un-lft-identity19.5%
*-un-lft-identity19.5%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt19.8%
+-commutative19.8%
hypot-1-def19.8%
metadata-eval19.8%
Applied egg-rr19.8%
+-rgt-identity19.8%
Simplified19.8%
Taylor expanded in x around 0 97.9%
if 0.5 < x Initial program 51.8%
*-un-lft-identity51.8%
*-commutative51.8%
log-prod51.8%
*-un-lft-identity51.8%
*-un-lft-identity51.8%
add-sqr-sqrt51.7%
fabs-sqr51.7%
add-sqr-sqrt51.8%
+-commutative51.8%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 96.8%
*-commutative96.8%
Simplified96.8%
Final simplification97.7%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.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(2.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(2.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 \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 32.2%
*-un-lft-identity32.2%
*-commutative32.2%
log-prod32.2%
*-un-lft-identity32.2%
*-un-lft-identity32.2%
add-sqr-sqrt6.6%
fabs-sqr6.6%
add-sqr-sqrt17.2%
+-commutative17.2%
hypot-1-def17.2%
metadata-eval17.2%
Applied egg-rr17.2%
+-rgt-identity17.2%
Simplified17.2%
Taylor expanded in x around 0 68.6%
if 0.5 < x Initial program 51.8%
*-un-lft-identity51.8%
*-commutative51.8%
log-prod51.8%
*-un-lft-identity51.8%
*-un-lft-identity51.8%
add-sqr-sqrt51.7%
fabs-sqr51.7%
add-sqr-sqrt51.8%
+-commutative51.8%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 96.8%
*-commutative96.8%
Simplified96.8%
Final simplification75.6%
(FPCore (x) :precision binary32 (if (<= x 4.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 4.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(4.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(4.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 4:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 4Initial program 32.5%
*-un-lft-identity32.5%
*-commutative32.5%
log-prod32.5%
*-un-lft-identity32.5%
*-un-lft-identity32.5%
add-sqr-sqrt7.1%
fabs-sqr7.1%
add-sqr-sqrt17.6%
+-commutative17.6%
hypot-1-def17.6%
metadata-eval17.6%
Applied egg-rr17.6%
+-rgt-identity17.6%
Simplified17.6%
Taylor expanded in x around 0 68.4%
if 4 < x Initial program 51.0%
Taylor expanded in x around inf 43.8%
mul-1-neg43.8%
log-rec43.8%
remove-double-neg43.8%
Simplified43.8%
Final simplification62.3%
(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 37.1%
*-un-lft-identity37.1%
*-commutative37.1%
log-prod37.1%
*-un-lft-identity37.1%
*-un-lft-identity37.1%
add-sqr-sqrt17.9%
fabs-sqr17.9%
add-sqr-sqrt25.8%
+-commutative25.8%
hypot-1-def37.9%
metadata-eval37.9%
Applied egg-rr37.9%
+-rgt-identity37.9%
Simplified37.9%
Taylor expanded in x around 0 54.4%
Final simplification54.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 2024053
(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))