
(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 12 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.05000000074505806)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ (log x) (log 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf((logf(x) + logf(2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.05000000074505806)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(log(x) + log(Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.05000000074505806)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs((log(x) + log(single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x + \log 2, x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 58.6%
flip-+9.3%
sqr-abs9.3%
add-sqr-sqrt8.9%
div-sub8.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt3.3%
+-commutative3.3%
hypot-1-def3.3%
fma-def3.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
+-commutative12.2%
hypot-1-def12.3%
Applied egg-rr12.3%
div-sub13.4%
*-lft-identity13.4%
metadata-eval13.4%
times-frac13.4%
fma-udef13.4%
associate--r+55.9%
+-inverses98.4%
metadata-eval98.4%
metadata-eval98.4%
neg-mul-198.4%
neg-sub098.4%
associate--r-98.4%
neg-sub098.4%
+-commutative98.4%
sub-neg98.4%
Simplified98.4%
if -0.0500000007 < x < 1Initial program 23.2%
flip-+23.3%
sqr-abs23.3%
add-sqr-sqrt23.2%
div-sub23.3%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt22.6%
+-commutative22.6%
hypot-1-def22.6%
fma-def22.6%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt23.2%
+-commutative23.2%
hypot-1-def23.1%
Applied egg-rr23.1%
div-sub23.1%
*-lft-identity23.1%
metadata-eval23.1%
times-frac23.1%
fma-udef23.1%
associate--r+23.2%
+-inverses23.2%
metadata-eval23.2%
metadata-eval23.2%
neg-mul-123.2%
neg-sub023.2%
associate--r-23.2%
neg-sub023.2%
+-commutative23.2%
sub-neg23.2%
Simplified23.2%
Taylor expanded in x around 0 99.2%
if 1 < x Initial program 53.9%
flip-+6.3%
sqr-abs6.3%
add-sqr-sqrt6.2%
div-sub6.3%
add-sqr-sqrt5.4%
fabs-sqr5.4%
add-sqr-sqrt6.3%
+-commutative6.3%
hypot-1-def5.5%
fma-def5.5%
add-sqr-sqrt6.0%
fabs-sqr6.0%
add-sqr-sqrt5.5%
+-commutative5.5%
hypot-1-def6.3%
Applied egg-rr6.3%
div-sub6.3%
*-lft-identity6.3%
metadata-eval6.3%
times-frac6.3%
fma-udef6.3%
associate--r+6.3%
+-inverses6.3%
metadata-eval6.3%
metadata-eval6.3%
neg-mul-16.3%
neg-sub012.1%
associate--r-12.1%
neg-sub012.1%
+-commutative12.1%
sub-neg12.1%
Simplified12.1%
Taylor expanded in x around inf 97.3%
+-commutative97.3%
mul-1-neg97.3%
log-rec97.3%
remove-double-neg97.3%
Simplified97.3%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<=
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)
-0.0005000000237487257)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(copysign (log1p (+ x (+ (hypot 1.0 x) -1.0))) x)))
float code(float x) {
float tmp;
if (copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x) <= -0.0005000000237487257f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else {
tmp = copysignf(log1pf((x + (hypotf(1.0f, x) + -1.0f))), 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(-0.0005000000237487257)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); else tmp = copysign(log1p(Float32(x + Float32(hypot(Float32(1.0), x) + Float32(-1.0)))), 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 -0.0005000000237487257:\\
\;\;\;\;\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(\mathsf{hypot}\left(1, x\right) + -1\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) < -5.00000024e-4Initial program 60.2%
flip-+13.6%
frac-2neg13.6%
log-div13.5%
sqr-abs13.5%
add-sqr-sqrt13.3%
fma-def13.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt17.3%
+-commutative17.3%
Applied egg-rr17.2%
neg-mul-117.2%
fma-udef17.2%
associate--r+57.5%
+-inverses97.6%
metadata-eval97.6%
metadata-eval97.6%
metadata-eval97.6%
neg-sub097.6%
neg-sub097.6%
associate--r-97.6%
neg-sub097.6%
+-commutative97.6%
sub-neg97.6%
Simplified97.6%
if -5.00000024e-4 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 33.2%
*-un-lft-identity33.2%
*-commutative33.2%
log-prod33.2%
add-sqr-sqrt28.1%
fabs-sqr28.1%
add-sqr-sqrt33.4%
+-commutative33.4%
hypot-1-def49.0%
metadata-eval49.0%
Applied egg-rr49.0%
+-rgt-identity49.0%
Simplified49.0%
log1p-expm1-u49.0%
expm1-udef49.0%
add-exp-log49.0%
Applied egg-rr49.0%
associate--l+96.7%
Simplified96.7%
Final simplification96.9%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ 1.0 (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ (log x) (log 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((1.0f / ((x * -2.0f) - (0.5f / x)))), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf((logf(x) + logf(2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(1.0) / Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(log(x) + log(Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-10.0)) tmp = sign(x) * abs(log((single(1.0) / ((x * single(-2.0)) - (single(0.5) / x))))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs((log(x) + log(single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{x \cdot -2 - \frac{0.5}{x}}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x + \log 2, x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.8%
flip-+5.3%
sqr-abs5.3%
add-sqr-sqrt4.7%
div-sub4.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt1.7%
+-commutative1.7%
hypot-1-def1.7%
fma-def1.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.1%
+-commutative8.1%
hypot-1-def8.3%
Applied egg-rr8.3%
div-sub9.4%
*-lft-identity9.4%
metadata-eval9.4%
times-frac9.4%
fma-udef9.4%
associate--r+53.9%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-mul-198.5%
neg-sub098.5%
associate--r-98.5%
neg-sub098.5%
+-commutative98.5%
sub-neg98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.4%
*-commutative98.4%
associate-*r/98.4%
metadata-eval98.4%
Simplified98.4%
if -10 < x < 1Initial program 24.9%
flip-+25.0%
sqr-abs25.0%
add-sqr-sqrt24.9%
div-sub25.0%
add-sqr-sqrt12.4%
fabs-sqr12.4%
add-sqr-sqrt23.0%
+-commutative23.0%
hypot-1-def23.0%
fma-def22.9%
add-sqr-sqrt12.4%
fabs-sqr12.4%
add-sqr-sqrt25.0%
+-commutative25.0%
hypot-1-def24.9%
Applied egg-rr24.9%
div-sub24.9%
*-lft-identity24.9%
metadata-eval24.9%
times-frac24.9%
fma-udef24.9%
associate--r+25.0%
+-inverses25.0%
metadata-eval25.0%
metadata-eval25.0%
neg-mul-125.0%
neg-sub025.0%
associate--r-25.0%
neg-sub025.0%
+-commutative25.0%
sub-neg25.0%
Simplified25.0%
Taylor expanded in x around 0 98.3%
if 1 < x Initial program 53.9%
flip-+6.3%
sqr-abs6.3%
add-sqr-sqrt6.2%
div-sub6.3%
add-sqr-sqrt5.4%
fabs-sqr5.4%
add-sqr-sqrt6.3%
+-commutative6.3%
hypot-1-def5.5%
fma-def5.5%
add-sqr-sqrt6.0%
fabs-sqr6.0%
add-sqr-sqrt5.5%
+-commutative5.5%
hypot-1-def6.3%
Applied egg-rr6.3%
div-sub6.3%
*-lft-identity6.3%
metadata-eval6.3%
times-frac6.3%
fma-udef6.3%
associate--r+6.3%
+-inverses6.3%
metadata-eval6.3%
metadata-eval6.3%
neg-mul-16.3%
neg-sub012.1%
associate--r-12.1%
neg-sub012.1%
+-commutative12.1%
sub-neg12.1%
Simplified12.1%
Taylor expanded in x around inf 97.3%
+-commutative97.3%
mul-1-neg97.3%
log-rec97.3%
remove-double-neg97.3%
Simplified97.3%
Final simplification98.0%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ (log x) (log 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -0.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf((logf(x) + logf(2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(log(x) + log(Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs((log(x) + log(single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x + \log 2, x\right)\\
\end{array}
\end{array}
if x < -0.0500000007Initial program 58.6%
flip-+9.3%
frac-2neg9.3%
log-div9.4%
sqr-abs9.4%
add-sqr-sqrt8.9%
fma-def8.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.3%
+-commutative13.3%
Applied egg-rr13.4%
neg-mul-113.4%
fma-udef13.4%
associate--r+55.8%
+-inverses98.3%
metadata-eval98.3%
metadata-eval98.3%
metadata-eval98.3%
neg-sub098.3%
neg-sub098.3%
associate--r-98.3%
neg-sub098.3%
+-commutative98.3%
sub-neg98.3%
Simplified98.3%
if -0.0500000007 < x < 1Initial program 23.2%
flip-+23.3%
sqr-abs23.3%
add-sqr-sqrt23.2%
div-sub23.3%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt22.6%
+-commutative22.6%
hypot-1-def22.6%
fma-def22.6%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt23.2%
+-commutative23.2%
hypot-1-def23.1%
Applied egg-rr23.1%
div-sub23.1%
*-lft-identity23.1%
metadata-eval23.1%
times-frac23.1%
fma-udef23.1%
associate--r+23.2%
+-inverses23.2%
metadata-eval23.2%
metadata-eval23.2%
neg-mul-123.2%
neg-sub023.2%
associate--r-23.2%
neg-sub023.2%
+-commutative23.2%
sub-neg23.2%
Simplified23.2%
Taylor expanded in x around 0 99.2%
if 1 < x Initial program 53.9%
flip-+6.3%
sqr-abs6.3%
add-sqr-sqrt6.2%
div-sub6.3%
add-sqr-sqrt5.4%
fabs-sqr5.4%
add-sqr-sqrt6.3%
+-commutative6.3%
hypot-1-def5.5%
fma-def5.5%
add-sqr-sqrt6.0%
fabs-sqr6.0%
add-sqr-sqrt5.5%
+-commutative5.5%
hypot-1-def6.3%
Applied egg-rr6.3%
div-sub6.3%
*-lft-identity6.3%
metadata-eval6.3%
times-frac6.3%
fma-udef6.3%
associate--r+6.3%
+-inverses6.3%
metadata-eval6.3%
metadata-eval6.3%
neg-mul-16.3%
neg-sub012.1%
associate--r-12.1%
neg-sub012.1%
+-commutative12.1%
sub-neg12.1%
Simplified12.1%
Taylor expanded in x around inf 97.3%
+-commutative97.3%
mul-1-neg97.3%
log-rec97.3%
remove-double-neg97.3%
Simplified97.3%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(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 <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
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(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) 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(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -10Initial program 56.8%
Taylor expanded in x around -inf 98.4%
sub-neg98.4%
neg-mul-198.4%
associate-+r+98.3%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.3%
+-commutative10.3%
unsub-neg10.3%
associate-*r/10.3%
metadata-eval10.3%
distribute-neg-frac10.3%
metadata-eval10.3%
Simplified10.3%
Taylor expanded in x around 0 98.2%
if -10 < x < 1Initial program 24.9%
flip-+25.0%
sqr-abs25.0%
add-sqr-sqrt24.9%
div-sub25.0%
add-sqr-sqrt12.4%
fabs-sqr12.4%
add-sqr-sqrt23.0%
+-commutative23.0%
hypot-1-def23.0%
fma-def22.9%
add-sqr-sqrt12.4%
fabs-sqr12.4%
add-sqr-sqrt25.0%
+-commutative25.0%
hypot-1-def24.9%
Applied egg-rr24.9%
div-sub24.9%
*-lft-identity24.9%
metadata-eval24.9%
times-frac24.9%
fma-udef24.9%
associate--r+25.0%
+-inverses25.0%
metadata-eval25.0%
metadata-eval25.0%
neg-mul-125.0%
neg-sub025.0%
associate--r-25.0%
neg-sub025.0%
+-commutative25.0%
sub-neg25.0%
Simplified25.0%
Taylor expanded in x around 0 98.3%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 95.1%
associate-*r/95.1%
metadata-eval95.1%
rem-square-sqrt95.0%
fabs-sqr95.0%
rem-square-sqrt95.1%
Simplified95.1%
Final simplification97.4%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ 1.0 (- (* x -2.0) (/ 0.5 x)))) x)
(if (<= x 1.0)
(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 <= -10.0f) {
tmp = copysignf(logf((1.0f / ((x * -2.0f) - (0.5f / x)))), x);
} else if (x <= 1.0f) {
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(-10.0)) tmp = copysign(log(Float32(Float32(1.0) / Float32(Float32(x * Float32(-2.0)) - Float32(Float32(0.5) / x)))), x); elseif (x <= Float32(1.0)) 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(-10.0)) tmp = sign(x) * abs(log((single(1.0) / ((x * single(-2.0)) - (single(0.5) / x))))); elseif (x <= single(1.0)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{x \cdot -2 - \frac{0.5}{x}}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -10Initial program 56.8%
flip-+5.3%
sqr-abs5.3%
add-sqr-sqrt4.7%
div-sub4.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt1.7%
+-commutative1.7%
hypot-1-def1.7%
fma-def1.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt8.1%
+-commutative8.1%
hypot-1-def8.3%
Applied egg-rr8.3%
div-sub9.4%
*-lft-identity9.4%
metadata-eval9.4%
times-frac9.4%
fma-udef9.4%
associate--r+53.9%
+-inverses98.5%
metadata-eval98.5%
metadata-eval98.5%
neg-mul-198.5%
neg-sub098.5%
associate--r-98.5%
neg-sub098.5%
+-commutative98.5%
sub-neg98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.4%
*-commutative98.4%
associate-*r/98.4%
metadata-eval98.4%
Simplified98.4%
if -10 < x < 1Initial program 24.9%
flip-+25.0%
sqr-abs25.0%
add-sqr-sqrt24.9%
div-sub25.0%
add-sqr-sqrt12.4%
fabs-sqr12.4%
add-sqr-sqrt23.0%
+-commutative23.0%
hypot-1-def23.0%
fma-def22.9%
add-sqr-sqrt12.4%
fabs-sqr12.4%
add-sqr-sqrt25.0%
+-commutative25.0%
hypot-1-def24.9%
Applied egg-rr24.9%
div-sub24.9%
*-lft-identity24.9%
metadata-eval24.9%
times-frac24.9%
fma-udef24.9%
associate--r+25.0%
+-inverses25.0%
metadata-eval25.0%
metadata-eval25.0%
neg-mul-125.0%
neg-sub025.0%
associate--r-25.0%
neg-sub025.0%
+-commutative25.0%
sub-neg25.0%
Simplified25.0%
Taylor expanded in x around 0 98.3%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 95.1%
associate-*r/95.1%
metadata-eval95.1%
rem-square-sqrt95.0%
fabs-sqr95.0%
rem-square-sqrt95.1%
Simplified95.1%
Final simplification97.5%
(FPCore (x)
:precision binary32
(if (<= x -10.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
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(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) 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(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -10Initial program 56.8%
Taylor expanded in x around -inf 98.4%
sub-neg98.4%
neg-mul-198.4%
associate-+r+98.3%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.3%
+-commutative10.3%
unsub-neg10.3%
associate-*r/10.3%
metadata-eval10.3%
distribute-neg-frac10.3%
metadata-eval10.3%
Simplified10.3%
Taylor expanded in x around 0 98.2%
if -10 < x < 1Initial program 24.9%
flip-+25.0%
sqr-abs25.0%
add-sqr-sqrt24.9%
div-sub25.0%
add-sqr-sqrt12.4%
fabs-sqr12.4%
add-sqr-sqrt23.0%
+-commutative23.0%
hypot-1-def23.0%
fma-def22.9%
add-sqr-sqrt12.4%
fabs-sqr12.4%
add-sqr-sqrt25.0%
+-commutative25.0%
hypot-1-def24.9%
Applied egg-rr24.9%
div-sub24.9%
*-lft-identity24.9%
metadata-eval24.9%
times-frac24.9%
fma-udef24.9%
associate--r+25.0%
+-inverses25.0%
metadata-eval25.0%
metadata-eval25.0%
neg-mul-125.0%
neg-sub025.0%
associate--r-25.0%
neg-sub025.0%
+-commutative25.0%
sub-neg25.0%
Simplified25.0%
Taylor expanded in x around 0 98.3%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 93.9%
rem-square-sqrt93.8%
fabs-sqr93.8%
rem-square-sqrt93.9%
Simplified93.9%
Final simplification97.1%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-10.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) 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(-10.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) 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 -10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -10Initial program 56.8%
Taylor expanded in x around -inf 98.4%
sub-neg98.4%
neg-mul-198.4%
associate-+r+98.3%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt10.3%
+-commutative10.3%
unsub-neg10.3%
associate-*r/10.3%
metadata-eval10.3%
distribute-neg-frac10.3%
metadata-eval10.3%
Simplified10.3%
Taylor expanded in x around 0 98.2%
if -10 < x < 1Initial program 24.9%
Taylor expanded in x around 0 20.5%
log1p-def92.3%
rem-square-sqrt47.9%
fabs-sqr47.9%
rem-square-sqrt92.2%
Simplified92.2%
Taylor expanded in x around 0 96.5%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 93.9%
rem-square-sqrt93.8%
fabs-sqr93.8%
rem-square-sqrt93.9%
Simplified93.9%
Final simplification96.2%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (+ x 1.0)) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + 1.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) 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(1.0)) 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 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + 1\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 35.7%
Taylor expanded in x around 0 28.5%
log1p-def76.1%
rem-square-sqrt31.7%
fabs-sqr31.7%
rem-square-sqrt61.2%
Simplified61.2%
Taylor expanded in x around 0 67.8%
if 1 < x Initial program 53.9%
Taylor expanded in x around 0 44.0%
rem-square-sqrt44.0%
fabs-sqr44.0%
rem-square-sqrt44.0%
Simplified44.0%
Final simplification61.4%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
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(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(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(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 35.7%
Taylor expanded in x around 0 28.5%
log1p-def76.1%
rem-square-sqrt31.7%
fabs-sqr31.7%
rem-square-sqrt61.2%
Simplified61.2%
Taylor expanded in x around 0 67.8%
if 1 < x Initial program 53.9%
Taylor expanded in x around inf 93.9%
rem-square-sqrt93.8%
fabs-sqr93.8%
rem-square-sqrt93.9%
Simplified93.9%
Final simplification74.8%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) tmp = copysign(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(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 35.7%
Taylor expanded in x around 0 28.5%
log1p-def76.1%
rem-square-sqrt31.7%
fabs-sqr31.7%
rem-square-sqrt61.2%
Simplified61.2%
Taylor expanded in x around 0 67.8%
if 1 < x Initial program 53.9%
Taylor expanded in x around 0 44.0%
log1p-def44.0%
rem-square-sqrt44.0%
fabs-sqr44.0%
rem-square-sqrt44.0%
Simplified44.0%
Final simplification61.4%
(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.6%
Taylor expanded in x around 0 32.6%
log1p-def67.4%
rem-square-sqrt35.0%
fabs-sqr35.0%
rem-square-sqrt56.5%
Simplified56.5%
Taylor expanded in x around 0 52.6%
Final simplification52.6%
(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 2023174
(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))