
(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 9 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 -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= t_0 0.10000000149011612)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 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 <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (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(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (t_0 <= Float32(0.10000000149011612)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(x + 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(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (t_0 <= single(0.10000000149011612)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + (x + (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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 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) < -1Initial program 40.6%
+-commutative40.6%
hypot-1-def97.0%
Simplified97.0%
Taylor expanded in x around -inf 95.9%
associate--l+95.9%
unpow195.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.5%
unpow19.5%
associate-+r-98.0%
mul-1-neg98.0%
sub-neg98.0%
+-inverses98.0%
neg-sub098.0%
associate-*r/98.0%
metadata-eval98.0%
distribute-neg-frac98.0%
metadata-eval98.0%
Simplified98.0%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 18.4%
+-commutative18.4%
hypot-1-def18.4%
Simplified18.4%
*-un-lft-identity18.4%
log-prod18.4%
metadata-eval18.4%
*-un-lft-identity18.4%
*-un-lft-identity18.4%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt18.4%
Applied egg-rr18.4%
+-lft-identity18.4%
Simplified18.4%
Taylor expanded in x around 0 99.8%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 50.9%
+-commutative50.9%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
log-prod99.9%
metadata-eval99.9%
*-un-lft-identity99.9%
*-un-lft-identity99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
Simplified99.9%
Final simplification99.4%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -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((-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(-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(-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{-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 40.6%
+-commutative40.6%
hypot-1-def97.0%
Simplified97.0%
Taylor expanded in x around -inf 95.9%
associate--l+95.9%
unpow195.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.5%
unpow19.5%
associate-+r-98.0%
mul-1-neg98.0%
sub-neg98.0%
+-inverses98.0%
neg-sub098.0%
associate-*r/98.0%
metadata-eval98.0%
distribute-neg-frac98.0%
metadata-eval98.0%
Simplified98.0%
if -1 < x < 0.0500000007Initial program 17.8%
+-commutative17.8%
hypot-1-def17.8%
Simplified17.8%
*-un-lft-identity17.8%
log-prod17.8%
metadata-eval17.8%
*-un-lft-identity17.8%
*-un-lft-identity17.8%
add-sqr-sqrt9.0%
fabs-sqr9.0%
add-sqr-sqrt17.7%
Applied egg-rr17.7%
+-lft-identity17.7%
Simplified17.7%
Taylor expanded in x around 0 99.7%
if 0.0500000007 < x Initial program 51.6%
+-commutative51.6%
hypot-1-def99.9%
Simplified99.9%
*-un-lft-identity99.9%
log-prod99.9%
metadata-eval99.9%
*-un-lft-identity99.9%
*-un-lft-identity99.9%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
+-lft-identity99.9%
Simplified99.9%
Final simplification99.3%
(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 (+ x (/ 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.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + (x + (0.5f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-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(x + Float32(Float32(0.5) / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((single(-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 + (x + (single(0.5) / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-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 + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 40.6%
+-commutative40.6%
hypot-1-def97.0%
Simplified97.0%
Taylor expanded in x around -inf 95.9%
associate--l+95.9%
unpow195.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.5%
unpow19.5%
associate-+r-98.0%
mul-1-neg98.0%
sub-neg98.0%
+-inverses98.0%
neg-sub098.0%
associate-*r/98.0%
metadata-eval98.0%
distribute-neg-frac98.0%
metadata-eval98.0%
Simplified98.0%
if -1 < x < 0.5Initial program 19.0%
+-commutative19.0%
hypot-1-def19.0%
Simplified19.0%
*-un-lft-identity19.0%
log-prod19.0%
metadata-eval19.0%
*-un-lft-identity19.0%
*-un-lft-identity19.0%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt18.9%
Applied egg-rr18.9%
+-lft-identity18.9%
Simplified18.9%
Taylor expanded in x around 0 99.3%
if 0.5 < x Initial program 50.2%
+-commutative50.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 97.6%
associate-+r+97.6%
+-commutative97.6%
+-commutative97.6%
unpow197.6%
sqr-pow97.6%
fabs-sqr97.6%
sqr-pow97.6%
unpow197.6%
associate-*r/97.6%
metadata-eval97.6%
Simplified97.6%
Final simplification98.6%
(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 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 + 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(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 + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-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 + x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 40.6%
+-commutative40.6%
hypot-1-def97.0%
Simplified97.0%
Taylor expanded in x around -inf 95.9%
associate--l+95.9%
unpow195.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.5%
unpow19.5%
associate-+r-98.0%
mul-1-neg98.0%
sub-neg98.0%
+-inverses98.0%
neg-sub098.0%
associate-*r/98.0%
metadata-eval98.0%
distribute-neg-frac98.0%
metadata-eval98.0%
Simplified98.0%
if -1 < x < 0.5Initial program 19.0%
+-commutative19.0%
hypot-1-def19.0%
Simplified19.0%
*-un-lft-identity19.0%
log-prod19.0%
metadata-eval19.0%
*-un-lft-identity19.0%
*-un-lft-identity19.0%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt18.9%
Applied egg-rr18.9%
+-lft-identity18.9%
Simplified18.9%
Taylor expanded in x around 0 99.3%
if 0.5 < x Initial program 50.2%
+-commutative50.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 95.3%
unpow195.3%
sqr-pow95.3%
fabs-sqr95.3%
sqr-pow95.3%
unpow195.3%
Simplified95.3%
Final simplification98.0%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (- x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 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(-5.0)) tmp = copysign(log(Float32(-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(-5.0)) tmp = sign(x) * abs(log(-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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-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 < -5Initial program 39.7%
+-commutative39.7%
hypot-1-def97.0%
Simplified97.0%
Taylor expanded in x around -inf 45.6%
mul-1-neg45.6%
Simplified45.6%
if -5 < x < 0.5Initial program 19.6%
+-commutative19.6%
hypot-1-def19.6%
Simplified19.6%
*-un-lft-identity19.6%
log-prod19.6%
metadata-eval19.6%
*-un-lft-identity19.6%
*-un-lft-identity19.6%
add-sqr-sqrt10.2%
fabs-sqr10.2%
add-sqr-sqrt19.5%
Applied egg-rr19.5%
+-lft-identity19.5%
Simplified19.5%
Taylor expanded in x around 0 98.1%
if 0.5 < x Initial program 50.2%
+-commutative50.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 95.3%
unpow195.3%
sqr-pow95.3%
fabs-sqr95.3%
sqr-pow95.3%
unpow195.3%
Simplified95.3%
Final simplification84.7%
(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 40.6%
+-commutative40.6%
hypot-1-def97.0%
Simplified97.0%
Taylor expanded in x around -inf 95.9%
associate--l+95.9%
unpow195.9%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.5%
unpow19.5%
associate-+r-98.0%
mul-1-neg98.0%
sub-neg98.0%
+-inverses98.0%
neg-sub098.0%
associate-*r/98.0%
metadata-eval98.0%
distribute-neg-frac98.0%
metadata-eval98.0%
Simplified98.0%
if -1 < x < 0.5Initial program 19.0%
+-commutative19.0%
hypot-1-def19.0%
Simplified19.0%
*-un-lft-identity19.0%
log-prod19.0%
metadata-eval19.0%
*-un-lft-identity19.0%
*-un-lft-identity19.0%
add-sqr-sqrt10.3%
fabs-sqr10.3%
add-sqr-sqrt18.9%
Applied egg-rr18.9%
+-lft-identity18.9%
Simplified18.9%
Taylor expanded in x around 0 98.6%
if 0.5 < x Initial program 50.2%
+-commutative50.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 95.3%
unpow195.3%
sqr-pow95.3%
fabs-sqr95.3%
sqr-pow95.3%
unpow195.3%
Simplified95.3%
Final simplification97.7%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(-x), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(-x)), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 40.6%
+-commutative40.6%
hypot-1-def97.0%
Simplified97.0%
Taylor expanded in x around -inf 45.3%
mul-1-neg45.3%
Simplified45.3%
if -1 < x Initial program 29.0%
+-commutative29.0%
hypot-1-def45.0%
Simplified45.0%
Taylor expanded in x around 0 25.7%
log1p-def79.8%
unpow179.8%
sqr-pow49.4%
fabs-sqr49.4%
sqr-pow79.8%
unpow179.8%
Simplified79.8%
Final simplification71.3%
(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 26.0%
+-commutative26.0%
hypot-1-def44.3%
Simplified44.3%
*-un-lft-identity44.3%
log-prod44.3%
metadata-eval44.3%
*-un-lft-identity44.3%
*-un-lft-identity44.3%
add-sqr-sqrt6.9%
fabs-sqr6.9%
add-sqr-sqrt16.4%
Applied egg-rr16.4%
+-lft-identity16.4%
Simplified16.4%
Taylor expanded in x around 0 69.9%
if 0.5 < x Initial program 50.2%
+-commutative50.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 43.6%
log1p-def43.6%
unpow143.6%
sqr-pow43.6%
fabs-sqr43.6%
sqr-pow43.6%
unpow143.6%
Simplified43.6%
Final simplification63.5%
(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 31.9%
+-commutative31.9%
hypot-1-def57.8%
Simplified57.8%
*-un-lft-identity57.8%
log-prod57.8%
metadata-eval57.8%
*-un-lft-identity57.8%
*-un-lft-identity57.8%
add-sqr-sqrt29.5%
fabs-sqr29.5%
add-sqr-sqrt36.6%
Applied egg-rr36.6%
+-lft-identity36.6%
Simplified36.6%
Taylor expanded in x around 0 55.9%
Final simplification55.9%
(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 2023230
(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))