
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.5)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.20000000298023224)
(copysign
(+
x
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* -0.044642857142857144 (pow x 7.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.5f) {
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.044642857142857144f * powf(x, 7.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.5)) 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(Float32(-0.044642857142857144) * (x ^ Float32(7.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.5)) 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.044642857142857144) * (x ^ single(7.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.5:\\
\;\;\;\;\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} + \left(-0.044642857142857144 \cdot {x}^{7} + 0.075 \cdot {x}^{5}\right)\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.5Initial program 57.8%
+-commutative57.8%
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-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
Applied egg-rr12.2%
+-lft-identity12.2%
Simplified12.2%
flip-+10.1%
frac-2neg10.1%
log-div10.1%
hypot-udef10.9%
hypot-udef10.0%
add-sqr-sqrt11.3%
metadata-eval11.3%
+-commutative11.3%
fma-def11.3%
Applied egg-rr11.3%
unpow211.3%
fma-udef11.3%
unpow211.3%
associate--r+54.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 22.0%
+-commutative22.0%
hypot-1-def22.1%
Simplified22.1%
expm1-log1p-u22.1%
expm1-udef21.8%
log1p-udef21.8%
add-exp-log21.8%
*-un-lft-identity21.8%
*-un-lft-identity21.8%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt22.2%
Applied egg-rr22.2%
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 54.0%
+-commutative54.0%
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 simplification100.0%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.5)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.019999999552965164)
(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.5f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.019999999552965164f) {
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.5)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.019999999552965164)) 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.5)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.019999999552965164)) 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.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.019999999552965164:\\
\;\;\;\;\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.5Initial program 57.8%
+-commutative57.8%
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-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
Applied egg-rr12.2%
+-lft-identity12.2%
Simplified12.2%
flip-+10.1%
frac-2neg10.1%
log-div10.1%
hypot-udef10.9%
hypot-udef10.0%
add-sqr-sqrt11.3%
metadata-eval11.3%
+-commutative11.3%
fma-def11.3%
Applied egg-rr11.3%
unpow211.3%
fma-udef11.3%
unpow211.3%
associate--r+54.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0199999996Initial program 21.4%
+-commutative21.4%
hypot-1-def21.5%
Simplified21.5%
expm1-log1p-u21.5%
expm1-udef21.2%
log1p-udef21.2%
add-exp-log21.2%
*-un-lft-identity21.2%
*-un-lft-identity21.2%
add-sqr-sqrt8.7%
fabs-sqr8.7%
add-sqr-sqrt21.6%
Applied egg-rr21.6%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 54.7%
+-commutative54.7%
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 simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.019999999552965164)
(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 <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.019999999552965164f) {
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(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.019999999552965164)) 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.019999999552965164)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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 < -2Initial program 57.2%
+-commutative57.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
associate--l+99.2%
unpow199.2%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.8%
unpow19.8%
associate-+r-98.3%
mul-1-neg98.3%
sub-neg98.3%
+-inverses98.3%
neg-sub098.3%
associate-*r/98.3%
metadata-eval98.3%
distribute-neg-frac98.3%
metadata-eval98.3%
Simplified98.3%
if -2 < x < 0.0199999996Initial program 22.0%
+-commutative22.0%
hypot-1-def22.1%
Simplified22.1%
Taylor expanded in x around 0 22.4%
+-commutative22.4%
fma-def22.4%
unpow222.4%
associate-/l*22.4%
unpow122.4%
sqr-pow9.4%
fabs-sqr9.4%
sqr-pow22.0%
unpow122.0%
log1p-def98.2%
unpow198.2%
sqr-pow50.6%
fabs-sqr50.6%
sqr-pow98.8%
unpow198.8%
Simplified98.8%
Taylor expanded in x around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 0.0199999996 < x Initial program 54.7%
+-commutative54.7%
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.2%
(FPCore (x)
:precision binary32
(if (<= x -0.05000000074505806)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.019999999552965164)
(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.05000000074505806f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (x <= 0.019999999552965164f) {
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.05000000074505806)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.019999999552965164)) 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.05000000074505806)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (x <= single(0.019999999552965164)) 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.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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.0500000007Initial program 58.1%
+-commutative58.1%
hypot-1-def99.8%
Simplified99.8%
*-un-lft-identity99.8%
log-prod99.8%
metadata-eval99.8%
*-un-lft-identity99.8%
*-un-lft-identity99.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.3%
Applied egg-rr13.3%
+-lft-identity13.3%
Simplified13.3%
flip-+11.1%
frac-2neg11.1%
log-div11.1%
hypot-udef12.1%
hypot-udef11.1%
add-sqr-sqrt12.5%
metadata-eval12.5%
+-commutative12.5%
fma-def12.5%
Applied egg-rr12.5%
unpow212.5%
fma-udef12.5%
unpow212.5%
associate--r+55.4%
+-inverses99.8%
metadata-eval99.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.0500000007 < x < 0.0199999996Initial program 20.9%
+-commutative20.9%
hypot-1-def20.9%
Simplified20.9%
Taylor expanded in x around 0 21.8%
+-commutative21.8%
fma-def21.8%
unpow221.8%
associate-/l*21.8%
unpow121.8%
sqr-pow9.5%
fabs-sqr9.5%
sqr-pow21.8%
unpow121.8%
log1p-def99.1%
unpow199.1%
sqr-pow51.4%
fabs-sqr51.4%
sqr-pow99.8%
unpow199.8%
Simplified99.8%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 0.0199999996 < x Initial program 54.7%
+-commutative54.7%
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.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(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 <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
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(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(x + x) + Float32(Float32(0.5) / x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(x + x\right) + \frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 57.2%
+-commutative57.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
associate--l+99.2%
unpow199.2%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.8%
unpow19.8%
associate-+r-98.3%
mul-1-neg98.3%
sub-neg98.3%
+-inverses98.3%
neg-sub098.3%
associate-*r/98.3%
metadata-eval98.3%
distribute-neg-frac98.3%
metadata-eval98.3%
Simplified98.3%
if -2 < x < 0.200000003Initial program 22.6%
+-commutative22.6%
hypot-1-def22.7%
Simplified22.7%
Taylor expanded in x around 0 22.7%
+-commutative22.7%
fma-def22.7%
unpow222.7%
associate-/l*22.7%
unpow122.7%
sqr-pow9.8%
fabs-sqr9.8%
sqr-pow22.3%
unpow122.3%
log1p-def97.9%
unpow197.9%
sqr-pow50.7%
fabs-sqr50.7%
sqr-pow98.5%
unpow198.5%
Simplified98.5%
Taylor expanded in x around 0 99.2%
*-commutative99.2%
Simplified99.2%
if 0.200000003 < x Initial program 54.0%
+-commutative54.0%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 99.8%
+-commutative99.8%
associate-+l+99.8%
unpow199.8%
sqr-pow99.6%
fabs-sqr99.6%
sqr-pow99.8%
unpow199.8%
+-commutative99.8%
associate-+r+99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.1%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
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(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\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 < -2Initial program 57.2%
+-commutative57.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
associate--l+99.2%
unpow199.2%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.8%
unpow19.8%
associate-+r-98.3%
mul-1-neg98.3%
sub-neg98.3%
+-inverses98.3%
neg-sub098.3%
associate-*r/98.3%
metadata-eval98.3%
distribute-neg-frac98.3%
metadata-eval98.3%
Simplified98.3%
if -2 < x < 0.200000003Initial program 22.6%
+-commutative22.6%
hypot-1-def22.7%
Simplified22.7%
Taylor expanded in x around 0 22.7%
+-commutative22.7%
fma-def22.7%
unpow222.7%
associate-/l*22.7%
unpow122.7%
sqr-pow9.8%
fabs-sqr9.8%
sqr-pow22.3%
unpow122.3%
log1p-def97.9%
unpow197.9%
sqr-pow50.7%
fabs-sqr50.7%
sqr-pow98.5%
unpow198.5%
Simplified98.5%
Taylor expanded in x around 0 99.2%
*-commutative99.2%
Simplified99.2%
if 0.200000003 < x Initial program 54.0%
+-commutative54.0%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 98.5%
unpow198.5%
sqr-pow98.4%
fabs-sqr98.4%
sqr-pow98.5%
unpow198.5%
Simplified98.5%
Final simplification98.8%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (log (- x)) x) (if (<= x 0.20000000298023224) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.20000000298023224f) {
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(-x)), x); elseif (x <= Float32(0.20000000298023224)) 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(-x)); elseif (x <= single(0.20000000298023224)) 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(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\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.6%
+-commutative56.6%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 44.6%
mul-1-neg44.6%
Simplified44.6%
if -10 < x < 0.200000003Initial program 23.2%
+-commutative23.2%
hypot-1-def23.3%
Simplified23.3%
Taylor expanded in x around 0 19.8%
log1p-def93.4%
add-sqr-sqrt48.6%
fabs-sqr48.6%
add-sqr-sqrt92.9%
log1p-udef19.5%
add-cbrt-cube19.5%
pow1/319.5%
log-pow19.5%
pow319.5%
log-pow19.5%
log1p-udef91.9%
Applied egg-rr91.9%
Taylor expanded in x around 0 97.6%
if 0.200000003 < x Initial program 54.0%
+-commutative54.0%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 98.5%
unpow198.5%
sqr-pow98.4%
fabs-sqr98.4%
sqr-pow98.5%
unpow198.5%
Simplified98.5%
Final simplification83.5%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.20000000298023224) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 57.2%
+-commutative57.2%
hypot-1-def100.0%
Simplified100.0%
Taylor expanded in x around -inf 99.2%
associate--l+99.2%
unpow199.2%
sqr-pow-0.0%
fabs-sqr-0.0%
sqr-pow9.8%
unpow19.8%
associate-+r-98.3%
mul-1-neg98.3%
sub-neg98.3%
+-inverses98.3%
neg-sub098.3%
associate-*r/98.3%
metadata-eval98.3%
distribute-neg-frac98.3%
metadata-eval98.3%
Simplified98.3%
if -2 < x < 0.200000003Initial program 22.6%
+-commutative22.6%
hypot-1-def22.7%
Simplified22.7%
Taylor expanded in x around 0 19.7%
log1p-def93.9%
add-sqr-sqrt49.0%
fabs-sqr49.0%
add-sqr-sqrt93.7%
log1p-udef19.7%
add-cbrt-cube19.7%
pow1/319.7%
log-pow19.6%
pow319.6%
log-pow19.7%
log1p-udef92.6%
Applied egg-rr92.6%
Taylor expanded in x around 0 98.1%
if 0.200000003 < x Initial program 54.0%
+-commutative54.0%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 98.5%
unpow198.5%
sqr-pow98.4%
fabs-sqr98.4%
sqr-pow98.5%
unpow198.5%
Simplified98.5%
Final simplification98.2%
(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 57.8%
+-commutative57.8%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around -inf 44.1%
mul-1-neg44.1%
Simplified44.1%
if -1 < x Initial program 32.2%
+-commutative32.2%
hypot-1-def46.9%
Simplified46.9%
Taylor expanded in x around 0 27.3%
log1p-def78.3%
unpow178.3%
sqr-pow47.6%
fabs-sqr47.6%
sqr-pow78.3%
unpow178.3%
Simplified78.3%
Final simplification68.8%
(FPCore (x) :precision binary32 (if (<= x 0.20000000298023224) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.20000000298023224f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.20000000298023224)) 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.20000000298023224:\\
\;\;\;\;\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.200000003Initial program 34.9%
+-commutative34.9%
hypot-1-def50.2%
Simplified50.2%
Taylor expanded in x around 0 28.5%
log1p-def76.3%
add-sqr-sqrt31.6%
fabs-sqr31.6%
add-sqr-sqrt60.4%
log1p-udef12.7%
add-cbrt-cube12.7%
pow1/314.3%
log-pow12.7%
pow312.7%
log-pow12.7%
log1p-udef59.7%
Applied egg-rr59.7%
Taylor expanded in x around 0 67.2%
if 0.200000003 < x Initial program 54.0%
+-commutative54.0%
hypot-1-def99.9%
Simplified99.9%
Taylor expanded in x around 0 43.9%
log1p-def43.9%
unpow143.9%
sqr-pow43.9%
fabs-sqr43.9%
sqr-pow43.9%
unpow143.9%
Simplified43.9%
Final simplification61.8%
(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 39.3%
+-commutative39.3%
hypot-1-def61.6%
Simplified61.6%
Taylor expanded in x around 0 32.0%
log1p-def68.9%
add-sqr-sqrt34.4%
fabs-sqr34.4%
add-sqr-sqrt56.6%
log1p-udef19.9%
add-cbrt-cube14.2%
pow1/315.5%
log-pow14.2%
pow314.2%
log-pow19.9%
log1p-udef56.1%
Applied egg-rr56.1%
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 2023275
(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))