
(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
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.5)
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(+
x
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* -0.044642857142857144 (pow x 7.0)) (* 0.075 (pow x 5.0)))))
x)
(copysign (log (/ 0.5 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((fabsf(x) + hypotf(1.0f, x))), x);
} else if (t_0 <= 0.10000000149011612f) {
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((0.5f / 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(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); elseif (t_0 <= Float32(0.10000000149011612)) 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(Float32(0.5) / 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((abs(x) + hypot(single(1.0), x)))); elseif (t_0 <= single(0.10000000149011612)) 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((single(0.5) / 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(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\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(\frac{0.5}{x}\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 56.0%
+-commutative56.0%
hypot-1-def99.9%
Simplified99.9%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 19.1%
*-un-lft-identity19.1%
*-commutative19.1%
log-prod19.1%
+-commutative19.1%
hypot-1-def19.1%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt19.3%
metadata-eval19.3%
Applied egg-rr19.3%
+-rgt-identity19.3%
Simplified19.3%
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 65.3%
Taylor expanded in x around inf 95.5%
associate-+r+95.4%
+-commutative95.4%
associate-*r/95.4%
metadata-eval95.4%
rem-square-sqrt95.4%
fabs-sqr95.4%
rem-square-sqrt95.4%
Simplified95.4%
Taylor expanded in x around 0 99.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 (+ (fabs x) (hypot 1.0 x))) x)
(if (<= t_0 0.10000000149011612)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
x)
(copysign (log (/ 0.5 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((fabsf(x) + hypotf(1.0f, x))), x);
} else if (t_0 <= 0.10000000149011612f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf((0.5f / 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(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); elseif (t_0 <= Float32(0.10000000149011612)) 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(Float32(0.5) / 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((abs(x) + hypot(single(1.0), x)))); elseif (t_0 <= single(0.10000000149011612)) 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((single(0.5) / 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(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.10000000149011612:\\
\;\;\;\;\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(\frac{0.5}{x}\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 56.0%
+-commutative56.0%
hypot-1-def99.9%
Simplified99.9%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 19.1%
*-un-lft-identity19.1%
*-commutative19.1%
log-prod19.1%
+-commutative19.1%
hypot-1-def19.1%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt19.3%
metadata-eval19.3%
Applied egg-rr19.3%
+-rgt-identity19.3%
Simplified19.3%
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 65.3%
Taylor expanded in x around inf 95.5%
associate-+r+95.4%
+-commutative95.4%
associate-*r/95.4%
metadata-eval95.4%
rem-square-sqrt95.4%
fabs-sqr95.4%
rem-square-sqrt95.4%
Simplified95.4%
Taylor expanded in x around 0 99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.10000000149011612)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.10000000149011612)) 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(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(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.10000000149011612)) 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((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{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\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(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 56.0%
expm1-log1p-u55.9%
expm1-undefine55.9%
+-commutative55.9%
hypot-1-def99.7%
Applied egg-rr99.7%
expm1-define99.6%
Simplified99.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
expm1-log1p-u-0.0%
add-sqr-sqrt13.3%
flip-+10.1%
div-sub10.2%
pow210.2%
hypot-1-def10.4%
hypot-1-def10.1%
add-sqr-sqrt10.6%
pow210.6%
Applied egg-rr10.6%
div-sub11.7%
*-rgt-identity11.7%
associate-*r/11.7%
+-commutative11.7%
associate--r+52.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-/r*99.9%
neg-mul-199.9%
associate-/l*99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
mul-1-neg99.9%
+-commutative99.9%
mul-1-neg99.9%
sub-neg99.9%
Simplified99.9%
if -1 < x < 0.100000001Initial program 19.1%
*-un-lft-identity19.1%
*-commutative19.1%
log-prod19.1%
+-commutative19.1%
hypot-1-def19.1%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt19.3%
metadata-eval19.3%
Applied egg-rr19.3%
+-rgt-identity19.3%
Simplified19.3%
Taylor expanded in x around 0 100.0%
if 0.100000001 < x Initial program 65.3%
Taylor expanded in x around inf 95.5%
associate-+r+95.4%
+-commutative95.4%
associate-*r/95.4%
metadata-eval95.4%
rem-square-sqrt95.4%
fabs-sqr95.4%
rem-square-sqrt95.4%
Simplified95.4%
Taylor expanded in x around 0 99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(0.5) / x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 56.0%
expm1-log1p-u55.9%
expm1-undefine55.9%
+-commutative55.9%
hypot-1-def99.7%
Applied egg-rr99.7%
expm1-define99.6%
Simplified99.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
expm1-log1p-u-0.0%
add-sqr-sqrt13.3%
flip-+10.1%
div-sub10.2%
pow210.2%
hypot-1-def10.4%
hypot-1-def10.1%
add-sqr-sqrt10.6%
pow210.6%
Applied egg-rr10.6%
div-sub11.7%
*-rgt-identity11.7%
associate-*r/11.7%
+-commutative11.7%
associate--r+52.9%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-/r*99.9%
neg-mul-199.9%
associate-/l*99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
mul-1-neg99.9%
+-commutative99.9%
mul-1-neg99.9%
sub-neg99.9%
Simplified99.9%
if -1 < x < 0.100000001Initial program 19.1%
*-un-lft-identity19.1%
*-commutative19.1%
log-prod19.1%
+-commutative19.1%
hypot-1-def19.1%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt19.3%
metadata-eval19.3%
Applied egg-rr19.3%
+-rgt-identity19.3%
Simplified19.3%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
Simplified99.8%
if 0.100000001 < x Initial program 65.3%
Taylor expanded in x around inf 95.5%
associate-+r+95.4%
+-commutative95.4%
associate-*r/95.4%
metadata-eval95.4%
rem-square-sqrt95.4%
fabs-sqr95.4%
rem-square-sqrt95.4%
Simplified95.4%
Taylor expanded in x around 0 99.9%
Final simplification99.8%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 0.5 x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(abs(x) - x)), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(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((abs(x) - x))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 55.3%
Taylor expanded in x around -inf 97.3%
neg-mul-197.3%
unsub-neg97.3%
Simplified97.3%
if -2 < x < 0.100000001Initial program 19.7%
*-un-lft-identity19.7%
*-commutative19.7%
log-prod19.7%
+-commutative19.7%
hypot-1-def19.7%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt19.9%
metadata-eval19.9%
Applied egg-rr19.9%
+-rgt-identity19.9%
Simplified19.9%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
Simplified99.3%
if 0.100000001 < x Initial program 65.3%
Taylor expanded in x around inf 95.5%
associate-+r+95.4%
+-commutative95.4%
associate-*r/95.4%
metadata-eval95.4%
rem-square-sqrt95.4%
fabs-sqr95.4%
rem-square-sqrt95.4%
Simplified95.4%
Taylor expanded in x around 0 99.9%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (/ 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.10000000149011612f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((0.5f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(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.10000000149011612)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 55.3%
*-un-lft-identity55.3%
*-commutative55.3%
log-prod55.3%
+-commutative55.3%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.0%
metadata-eval12.0%
Applied egg-rr12.0%
+-rgt-identity12.0%
Simplified12.0%
Taylor expanded in x around -inf 97.2%
if -2 < x < 0.100000001Initial program 19.7%
*-un-lft-identity19.7%
*-commutative19.7%
log-prod19.7%
+-commutative19.7%
hypot-1-def19.7%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt19.9%
metadata-eval19.9%
Applied egg-rr19.9%
+-rgt-identity19.9%
Simplified19.9%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
Simplified99.3%
if 0.100000001 < x Initial program 65.3%
Taylor expanded in x around inf 95.5%
associate-+r+95.4%
+-commutative95.4%
associate-*r/95.4%
metadata-eval95.4%
rem-square-sqrt95.4%
fabs-sqr95.4%
rem-square-sqrt95.4%
Simplified95.4%
Taylor expanded in x around 0 99.9%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign (* 2.0 (* x 0.5)) 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.10000000149011612f) {
tmp = copysignf((2.0f * (x * 0.5f)), 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.10000000149011612)) tmp = copysign(Float32(Float32(2.0) * Float32(x * Float32(0.5))), 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.10000000149011612)) tmp = sign(x) * abs((single(2.0) * (x * single(0.5)))); 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left(x \cdot 0.5\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 55.3%
*-un-lft-identity55.3%
*-commutative55.3%
log-prod55.3%
+-commutative55.3%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.0%
metadata-eval12.0%
Applied egg-rr12.0%
+-rgt-identity12.0%
Simplified12.0%
Taylor expanded in x around -inf 97.2%
if -2 < x < 0.100000001Initial program 19.7%
add-sqr-sqrt19.0%
pow219.0%
log-pow19.0%
+-commutative19.0%
hypot-1-def19.0%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt19.6%
Applied egg-rr19.6%
Taylor expanded in x around 0 98.1%
*-commutative98.1%
Simplified98.1%
if 0.100000001 < x Initial program 65.3%
Taylor expanded in x around inf 95.4%
rem-square-sqrt95.4%
fabs-sqr95.4%
rem-square-sqrt95.4%
Simplified95.4%
Final simplification97.2%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign (* 2.0 (* x 0.5)) x)
(copysign (log (/ 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.10000000149011612f) {
tmp = copysignf((2.0f * (x * 0.5f)), x);
} else {
tmp = copysignf(logf((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.10000000149011612)) tmp = copysign(Float32(Float32(2.0) * Float32(x * Float32(0.5))), x); else tmp = copysign(log(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.10000000149011612)) tmp = sign(x) * abs((single(2.0) * (x * single(0.5)))); else tmp = sign(x) * abs(log((single(0.5) / x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left(x \cdot 0.5\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 55.3%
*-un-lft-identity55.3%
*-commutative55.3%
log-prod55.3%
+-commutative55.3%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.0%
metadata-eval12.0%
Applied egg-rr12.0%
+-rgt-identity12.0%
Simplified12.0%
Taylor expanded in x around -inf 97.2%
if -2 < x < 0.100000001Initial program 19.7%
add-sqr-sqrt19.0%
pow219.0%
log-pow19.0%
+-commutative19.0%
hypot-1-def19.0%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt19.6%
Applied egg-rr19.6%
Taylor expanded in x around 0 98.1%
*-commutative98.1%
Simplified98.1%
if 0.100000001 < x Initial program 65.3%
Taylor expanded in x around inf 95.5%
associate-+r+95.4%
+-commutative95.4%
associate-*r/95.4%
metadata-eval95.4%
rem-square-sqrt95.4%
fabs-sqr95.4%
rem-square-sqrt95.4%
Simplified95.4%
Taylor expanded in x around 0 99.9%
Final simplification98.3%
(FPCore (x) :precision binary32 (if (<= x 0.10000000149011612) (copysign (* 2.0 (* x 0.5)) x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
if (x <= 0.10000000149011612f) {
tmp = copysignf((2.0f * (x * 0.5f)), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(Float32(2.0) * Float32(x * Float32(0.5))), x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(0.10000000149011612)) tmp = sign(x) * abs((single(2.0) * (x * single(0.5)))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left(x \cdot 0.5\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < 0.100000001Initial program 31.7%
add-sqr-sqrt31.1%
pow231.1%
log-pow31.2%
+-commutative31.2%
hypot-1-def46.1%
add-sqr-sqrt6.4%
fabs-sqr6.4%
add-sqr-sqrt17.0%
Applied egg-rr17.0%
Taylor expanded in x around 0 69.1%
*-commutative69.1%
Simplified69.1%
if 0.100000001 < x Initial program 65.3%
Taylor expanded in x around inf 95.4%
rem-square-sqrt95.4%
fabs-sqr95.4%
rem-square-sqrt95.4%
Simplified95.4%
Final simplification75.5%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign -2.0 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(-2.0f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(Float32(-2.0), 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(-2, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 56.0%
Taylor expanded in x around inf 6.4%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified22.4%
if -1 < x Initial program 34.2%
Taylor expanded in x around 0 26.1%
log1p-define79.1%
rem-square-sqrt47.2%
fabs-sqr47.2%
rem-square-sqrt79.1%
Simplified79.1%
Final simplification64.5%
(FPCore (x) :precision binary32 (copysign (* 2.0 (* x 0.5)) x))
float code(float x) {
return copysignf((2.0f * (x * 0.5f)), x);
}
function code(x) return copysign(Float32(Float32(2.0) * Float32(x * Float32(0.5))), x) end
function tmp = code(x) tmp = sign(x) * abs((single(2.0) * (x * single(0.5)))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(2 \cdot \left(x \cdot 0.5\right), x\right)
\end{array}
Initial program 39.8%
add-sqr-sqrt39.4%
pow239.4%
log-pow39.4%
+-commutative39.4%
hypot-1-def58.1%
add-sqr-sqrt28.0%
fabs-sqr28.0%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
Taylor expanded in x around 0 55.1%
*-commutative55.1%
Simplified55.1%
Final simplification55.1%
(FPCore (x) :precision binary32 (copysign -2.0 x))
float code(float x) {
return copysignf(-2.0f, x);
}
function code(x) return copysign(Float32(-2.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-2.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-2, x\right)
\end{array}
Initial program 39.8%
Taylor expanded in x around inf 28.4%
rem-square-sqrt25.6%
fabs-sqr25.6%
rem-square-sqrt25.6%
Simplified25.6%
Taylor expanded in x around 0 26.6%
Simplified16.1%
Final simplification16.1%
(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 2024039
(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))