
(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 14 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.4000000059604645)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.019999999552965164)
(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 <= -0.4000000059604645f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.019999999552965164f) {
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(-0.4000000059604645)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.019999999552965164)) 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(-0.4000000059604645)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.019999999552965164)) 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 -0.4000000059604645:\\
\;\;\;\;\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(-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) < -0.400000006Initial program 50.8%
+-commutative50.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.3%
flip-+12.0%
log-div11.9%
add-sqr-sqrt12.6%
fma-def12.1%
+-commutative12.1%
hypot-1-def12.1%
Applied egg-rr12.1%
fma-udef12.6%
+-commutative12.6%
associate--l+47.4%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
if -0.400000006 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0199999996Initial program 20.2%
+-commutative20.2%
add-sqr-sqrt11.0%
fabs-sqr11.0%
add-sqr-sqrt20.4%
flip-+20.2%
add-sqr-sqrt20.1%
fma-def20.1%
+-commutative20.1%
hypot-1-def20.2%
Applied egg-rr20.2%
fma-udef20.2%
+-commutative20.2%
associate--l+20.2%
+-inverses20.2%
metadata-eval20.2%
Simplified20.2%
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 56.3%
*-un-lft-identity56.3%
*-commutative56.3%
log-prod56.3%
add-sqr-sqrt56.3%
fabs-sqr56.3%
add-sqr-sqrt56.3%
+-commutative56.3%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (+ (* x -2.0) (* 0.5 (/ -1.0 x))))) x)
(if (<= x 0.019999999552965164)
(copysign (fma (* x x) (* x -0.16666666666666666) x) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf(((x * -2.0f) + (0.5f * (-1.0f / x)))), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf(fmaf((x * x), (x * -0.16666666666666666f), x), 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(Float32(-log(Float32(Float32(x * Float32(-2.0)) + Float32(Float32(0.5) * Float32(Float32(-1.0) / x))))), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(fma(Float32(x * x), Float32(x * Float32(-0.16666666666666666)), x), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 + 0.5 \cdot \frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(x \cdot x, x \cdot -0.16666666666666666, x\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 x < -2Initial program 48.3%
+-commutative48.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.1%
flip-+7.7%
log-div7.7%
add-sqr-sqrt8.2%
fma-def7.7%
+-commutative7.7%
hypot-1-def7.7%
Applied egg-rr7.7%
fma-udef8.2%
+-commutative8.2%
associate--l+44.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 99.3%
if -2 < x < 0.0199999996Initial program 21.9%
+-commutative21.9%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt22.0%
flip-+21.8%
add-sqr-sqrt21.8%
fma-def21.8%
+-commutative21.8%
hypot-1-def21.9%
Applied egg-rr21.9%
fma-udef21.9%
+-commutative21.9%
associate--l+21.9%
+-inverses21.9%
metadata-eval21.9%
Simplified21.9%
Taylor expanded in x around 0 98.7%
*-commutative98.7%
unpow398.7%
associate-*l*98.7%
fma-def98.7%
Applied egg-rr98.7%
if 0.0199999996 < x Initial program 56.3%
*-un-lft-identity56.3%
*-commutative56.3%
log-prod56.3%
add-sqr-sqrt56.3%
fabs-sqr56.3%
add-sqr-sqrt56.3%
+-commutative56.3%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-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 51.5%
+-commutative51.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.6%
flip-+13.3%
log-div13.2%
add-sqr-sqrt13.9%
fma-def13.4%
+-commutative13.4%
hypot-1-def13.4%
Applied egg-rr13.4%
fma-udef13.9%
+-commutative13.9%
associate--l+48.2%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
neg-sub099.8%
Simplified99.8%
if -0.0500000007 < x < 0.0199999996Initial program 19.7%
+-commutative19.7%
add-sqr-sqrt11.1%
fabs-sqr11.1%
add-sqr-sqrt19.8%
flip-+19.6%
add-sqr-sqrt19.5%
fma-def19.5%
+-commutative19.5%
hypot-1-def19.6%
Applied egg-rr19.6%
fma-udef19.6%
+-commutative19.6%
associate--l+19.7%
+-inverses19.7%
metadata-eval19.7%
Simplified19.7%
Taylor expanded in x around 0 100.0%
if 0.0199999996 < x Initial program 56.3%
*-un-lft-identity56.3%
*-commutative56.3%
log-prod56.3%
add-sqr-sqrt56.3%
fabs-sqr56.3%
add-sqr-sqrt56.3%
+-commutative56.3%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (+ (* x -2.0) (* 0.5 (/ -1.0 x))))) x)
(if (<= x 0.019999999552965164)
(copysign (fma (* x x) (* x -0.16666666666666666) x) x)
(copysign (log (+ x (+ x (/ 0.5 x)))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf(((x * -2.0f) + (0.5f * (-1.0f / x)))), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf(fmaf((x * x), (x * -0.16666666666666666f), x), 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(Float32(-log(Float32(Float32(x * Float32(-2.0)) + Float32(Float32(0.5) * Float32(Float32(-1.0) / x))))), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(fma(Float32(x * x), Float32(x * Float32(-0.16666666666666666)), x), x); else tmp = copysign(log(Float32(x + Float32(x + Float32(Float32(0.5) / x)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 + 0.5 \cdot \frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(x \cdot x, x \cdot -0.16666666666666666, x\right), 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 < -2Initial program 48.3%
+-commutative48.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.1%
flip-+7.7%
log-div7.7%
add-sqr-sqrt8.2%
fma-def7.7%
+-commutative7.7%
hypot-1-def7.7%
Applied egg-rr7.7%
fma-udef8.2%
+-commutative8.2%
associate--l+44.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 99.3%
if -2 < x < 0.0199999996Initial program 21.9%
+-commutative21.9%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt22.0%
flip-+21.8%
add-sqr-sqrt21.8%
fma-def21.8%
+-commutative21.8%
hypot-1-def21.9%
Applied egg-rr21.9%
fma-udef21.9%
+-commutative21.9%
associate--l+21.9%
+-inverses21.9%
metadata-eval21.9%
Simplified21.9%
Taylor expanded in x around 0 98.7%
*-commutative98.7%
unpow398.7%
associate-*l*98.7%
fma-def98.7%
Applied egg-rr98.7%
if 0.0199999996 < x Initial program 56.3%
Taylor expanded in x around inf 99.3%
+-commutative99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
*-un-lft-identity99.3%
*-commutative99.3%
log-prod99.3%
add-sqr-sqrt99.2%
fabs-sqr99.2%
add-sqr-sqrt99.3%
metadata-eval99.3%
Applied egg-rr99.3%
+-rgt-identity99.3%
Simplified99.3%
Final simplification99.0%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.019999999552965164)
(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((x * -2.0f)), x);
} else if (x <= 0.019999999552965164f) {
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(Float32(-log(Float32(x * Float32(-2.0)))), 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 + Float32(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((x * single(-2.0)))); elseif (x <= single(0.019999999552965164)) 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(x \cdot -2\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 + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 48.3%
+-commutative48.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.1%
flip-+7.7%
log-div7.7%
add-sqr-sqrt8.2%
fma-def7.7%
+-commutative7.7%
hypot-1-def7.7%
Applied egg-rr7.7%
fma-udef8.2%
+-commutative8.2%
associate--l+44.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 98.6%
if -2 < x < 0.0199999996Initial program 21.9%
+-commutative21.9%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt22.0%
flip-+21.8%
add-sqr-sqrt21.8%
fma-def21.8%
+-commutative21.8%
hypot-1-def21.9%
Applied egg-rr21.9%
fma-udef21.9%
+-commutative21.9%
associate--l+21.9%
+-inverses21.9%
metadata-eval21.9%
Simplified21.9%
Taylor expanded in x around 0 98.7%
if 0.0199999996 < x Initial program 56.3%
Taylor expanded in x around inf 99.3%
+-commutative99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
*-un-lft-identity99.3%
*-commutative99.3%
log-prod99.3%
add-sqr-sqrt99.2%
fabs-sqr99.2%
add-sqr-sqrt99.3%
metadata-eval99.3%
Applied egg-rr99.3%
+-rgt-identity99.3%
Simplified99.3%
Final simplification98.8%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.019999999552965164)
(copysign (fma (* x x) (* x -0.16666666666666666) x) x)
(copysign (log (+ x (+ x (/ 0.5 x)))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf(fmaf((x * x), (x * -0.16666666666666666f), x), 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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.019999999552965164)) tmp = copysign(fma(Float32(x * x), Float32(x * Float32(-0.16666666666666666)), x), x); else tmp = copysign(log(Float32(x + Float32(x + Float32(Float32(0.5) / x)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{fma}\left(x \cdot x, x \cdot -0.16666666666666666, x\right), 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 < -2Initial program 48.3%
+-commutative48.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.1%
flip-+7.7%
log-div7.7%
add-sqr-sqrt8.2%
fma-def7.7%
+-commutative7.7%
hypot-1-def7.7%
Applied egg-rr7.7%
fma-udef8.2%
+-commutative8.2%
associate--l+44.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 98.6%
if -2 < x < 0.0199999996Initial program 21.9%
+-commutative21.9%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt22.0%
flip-+21.8%
add-sqr-sqrt21.8%
fma-def21.8%
+-commutative21.8%
hypot-1-def21.9%
Applied egg-rr21.9%
fma-udef21.9%
+-commutative21.9%
associate--l+21.9%
+-inverses21.9%
metadata-eval21.9%
Simplified21.9%
Taylor expanded in x around 0 98.7%
*-commutative98.7%
unpow398.7%
associate-*l*98.7%
fma-def98.7%
Applied egg-rr98.7%
if 0.0199999996 < x Initial program 56.3%
Taylor expanded in x around inf 99.3%
+-commutative99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
*-un-lft-identity99.3%
*-commutative99.3%
log-prod99.3%
add-sqr-sqrt99.2%
fabs-sqr99.2%
add-sqr-sqrt99.3%
metadata-eval99.3%
Applied egg-rr99.3%
+-rgt-identity99.3%
Simplified99.3%
Final simplification98.8%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.019999999552965164)
(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((x * -2.0f)), x);
} else if (x <= 0.019999999552965164f) {
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(Float32(-log(Float32(x * Float32(-2.0)))), 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 + 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((x * single(-2.0)))); elseif (x <= single(0.019999999552965164)) 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(x \cdot -2\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 + x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 48.3%
+-commutative48.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.1%
flip-+7.7%
log-div7.7%
add-sqr-sqrt8.2%
fma-def7.7%
+-commutative7.7%
hypot-1-def7.7%
Applied egg-rr7.7%
fma-udef8.2%
+-commutative8.2%
associate--l+44.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 98.6%
if -2 < x < 0.0199999996Initial program 21.9%
+-commutative21.9%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt22.0%
flip-+21.8%
add-sqr-sqrt21.8%
fma-def21.8%
+-commutative21.8%
hypot-1-def21.9%
Applied egg-rr21.9%
fma-udef21.9%
+-commutative21.9%
associate--l+21.9%
+-inverses21.9%
metadata-eval21.9%
Simplified21.9%
Taylor expanded in x around 0 98.7%
if 0.0199999996 < x Initial program 56.3%
Taylor expanded in x around inf 97.0%
rem-square-sqrt97.0%
fabs-sqr97.0%
rem-square-sqrt97.0%
Simplified97.0%
Final simplification98.3%
(FPCore (x) :precision binary32 (if (<= x -40.0) (copysign 15.333333333333334 x) (if (<= x 0.019999999552965164) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -40.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 0.019999999552965164f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-40.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(0.019999999552965164)) 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(-40.0)) tmp = sign(x) * abs(single(15.333333333333334)); elseif (x <= single(0.019999999552965164)) 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 -40:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -40Initial program 47.5%
Taylor expanded in x around inf -0.0%
associate-*r/-0.0%
metadata-eval-0.0%
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%
Simplified26.9%
if -40 < x < 0.0199999996Initial program 22.5%
Taylor expanded in x around 0 18.4%
log1p-def93.4%
rem-square-sqrt50.7%
fabs-sqr50.7%
rem-square-sqrt93.1%
Simplified93.1%
Taylor expanded in x around 0 96.7%
if 0.0199999996 < x Initial program 56.3%
Taylor expanded in x around inf 97.0%
rem-square-sqrt97.0%
fabs-sqr97.0%
rem-square-sqrt97.0%
Simplified97.0%
Final simplification81.3%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.019999999552965164) (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.019999999552965164f) {
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.019999999552965164)) 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.019999999552965164)) 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.019999999552965164:\\
\;\;\;\;\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 48.3%
+-commutative48.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.1%
flip-+7.7%
add-sqr-sqrt8.2%
fma-def7.7%
+-commutative7.7%
hypot-1-def7.7%
Applied egg-rr7.7%
fma-udef8.2%
+-commutative8.2%
associate--l+44.7%
+-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around -inf 98.5%
if -2 < x < 0.0199999996Initial program 21.9%
Taylor expanded in x around 0 18.3%
log1p-def93.8%
rem-square-sqrt51.1%
fabs-sqr51.1%
rem-square-sqrt93.7%
Simplified93.7%
Taylor expanded in x around 0 97.2%
if 0.0199999996 < x Initial program 56.3%
Taylor expanded in x around inf 97.0%
rem-square-sqrt97.0%
fabs-sqr97.0%
rem-square-sqrt97.0%
Simplified97.0%
Final simplification97.5%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (- (log (* x -2.0))) x) (if (<= x 0.019999999552965164) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.019999999552965164f) {
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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.019999999552965164)) 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((x * single(-2.0)))); elseif (x <= single(0.019999999552965164)) 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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.019999999552965164:\\
\;\;\;\;\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 48.3%
+-commutative48.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.1%
flip-+7.7%
log-div7.7%
add-sqr-sqrt8.2%
fma-def7.7%
+-commutative7.7%
hypot-1-def7.7%
Applied egg-rr7.7%
fma-udef8.2%
+-commutative8.2%
associate--l+44.8%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in x around -inf 98.6%
if -2 < x < 0.0199999996Initial program 21.9%
Taylor expanded in x around 0 18.3%
log1p-def93.8%
rem-square-sqrt51.1%
fabs-sqr51.1%
rem-square-sqrt93.7%
Simplified93.7%
Taylor expanded in x around 0 97.2%
if 0.0199999996 < x Initial program 56.3%
Taylor expanded in x around inf 97.0%
rem-square-sqrt97.0%
fabs-sqr97.0%
rem-square-sqrt97.0%
Simplified97.0%
Final simplification97.5%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign 15.333333333333334 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(15.333333333333334f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(Float32(15.333333333333334), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 48.3%
Taylor expanded in x around inf -0.0%
associate-*r/-0.0%
metadata-eval-0.0%
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%
Simplified26.8%
if -2 < x Initial program 32.3%
Taylor expanded in x around 0 26.0%
log1p-def78.6%
rem-square-sqrt48.8%
fabs-sqr48.8%
rem-square-sqrt78.6%
Simplified78.6%
Final simplification66.8%
(FPCore (x) :precision binary32 (if (<= x -40.0) (copysign 15.333333333333334 x) (if (<= x 15.0) (copysign x x) (copysign 15.333333333333334 x))))
float code(float x) {
float tmp;
if (x <= -40.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 15.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(15.333333333333334f, x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-40.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(15.0)) tmp = copysign(x, x); else tmp = copysign(Float32(15.333333333333334), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-40.0)) tmp = sign(x) * abs(single(15.333333333333334)); elseif (x <= single(15.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(single(15.333333333333334)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -40:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 15:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\end{array}
\end{array}
if x < -40 or 15 < x Initial program 51.2%
Taylor expanded in x around inf 50.3%
associate-*r/50.3%
metadata-eval50.3%
rem-square-sqrt50.3%
fabs-sqr50.3%
rem-square-sqrt50.3%
Simplified50.3%
Taylor expanded in x around 0 1.0%
Simplified27.2%
if -40 < x < 15Initial program 23.6%
Taylor expanded in x around 0 18.6%
log1p-def92.5%
rem-square-sqrt50.5%
fabs-sqr50.5%
rem-square-sqrt92.2%
Simplified92.2%
Taylor expanded in x around 0 95.7%
Final simplification64.9%
(FPCore (x) :precision binary32 (copysign -6.0 x))
float code(float x) {
return copysignf(-6.0f, x);
}
function code(x) return copysign(Float32(-6.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-6.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-6, x\right)
\end{array}
Initial program 36.0%
Taylor expanded in x around inf 26.2%
associate-*r/26.2%
metadata-eval26.2%
rem-square-sqrt26.2%
fabs-sqr26.2%
rem-square-sqrt26.2%
Simplified26.2%
Taylor expanded in x around 0 4.0%
Simplified16.7%
Final simplification16.7%
(FPCore (x) :precision binary32 (copysign 15.333333333333334 x))
float code(float x) {
return copysignf(15.333333333333334f, x);
}
function code(x) return copysign(Float32(15.333333333333334), x) end
function tmp = code(x) tmp = sign(x) * abs(single(15.333333333333334)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(15.333333333333334, x\right)
\end{array}
Initial program 36.0%
Taylor expanded in x around inf 26.2%
associate-*r/26.2%
metadata-eval26.2%
rem-square-sqrt26.2%
fabs-sqr26.2%
rem-square-sqrt26.2%
Simplified26.2%
Taylor expanded in x around 0 3.4%
Simplified17.9%
Final simplification17.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 2023178
(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))