
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -4.0)
(copysign (log (/ -0.5 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 <= -4.0f) {
tmp = copysignf(logf((-0.5f / 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(-4.0)) tmp = copysign(log(Float32(Float32(-0.5) / 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(-4.0)) tmp = sign(x) * abs(log((single(-0.5) / 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 -4:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{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) < -4Initial program 50.3%
*-un-lft-identity50.3%
*-commutative50.3%
log-prod50.3%
*-un-lft-identity50.3%
*-un-lft-identity50.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.2%
+-commutative10.2%
hypot-1-def10.2%
metadata-eval10.2%
Applied egg-rr10.2%
+-rgt-identity10.2%
Simplified10.2%
Taylor expanded in x around -inf 99.3%
if -4 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0199999996Initial program 23.9%
*-un-lft-identity23.9%
*-commutative23.9%
log-prod23.9%
*-un-lft-identity23.9%
*-un-lft-identity23.9%
add-sqr-sqrt11.1%
fabs-sqr11.1%
add-sqr-sqrt24.0%
+-commutative24.0%
hypot-1-def23.9%
metadata-eval23.9%
Applied egg-rr23.9%
+-rgt-identity23.9%
Simplified23.9%
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 57.4%
*-un-lft-identity57.4%
*-commutative57.4%
log-prod57.4%
*-un-lft-identity57.4%
*-un-lft-identity57.4%
add-sqr-sqrt57.4%
fabs-sqr57.4%
add-sqr-sqrt57.4%
+-commutative57.4%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x)
:precision binary32
(if (<= x -40.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 <= -40.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(-40.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(-40.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 -40:\\
\;\;\;\;\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 < -40Initial program 50.3%
*-un-lft-identity50.3%
*-commutative50.3%
log-prod50.3%
*-un-lft-identity50.3%
*-un-lft-identity50.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.2%
+-commutative10.2%
hypot-1-def10.2%
metadata-eval10.2%
Applied egg-rr10.2%
+-rgt-identity10.2%
Simplified10.2%
Taylor expanded in x around -inf 99.3%
if -40 < x < 0.0199999996Initial program 23.9%
*-un-lft-identity23.9%
*-commutative23.9%
log-prod23.9%
*-un-lft-identity23.9%
*-un-lft-identity23.9%
add-sqr-sqrt11.1%
fabs-sqr11.1%
add-sqr-sqrt24.0%
+-commutative24.0%
hypot-1-def23.9%
metadata-eval23.9%
Applied egg-rr23.9%
+-rgt-identity23.9%
Simplified23.9%
Taylor expanded in x around 0 99.6%
if 0.0199999996 < x Initial program 57.4%
*-un-lft-identity57.4%
*-commutative57.4%
log-prod57.4%
*-un-lft-identity57.4%
*-un-lft-identity57.4%
add-sqr-sqrt57.4%
fabs-sqr57.4%
add-sqr-sqrt57.4%
+-commutative57.4%
hypot-1-def99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -40.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
float tmp;
if (x <= -40.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-40.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-40.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log(((x * single(2.0)) + (single(0.5) * (single(1.0) / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -40:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -40Initial program 50.3%
*-un-lft-identity50.3%
*-commutative50.3%
log-prod50.3%
*-un-lft-identity50.3%
*-un-lft-identity50.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.2%
+-commutative10.2%
hypot-1-def10.2%
metadata-eval10.2%
Applied egg-rr10.2%
+-rgt-identity10.2%
Simplified10.2%
Taylor expanded in x around -inf 99.3%
if -40 < x < 0.5Initial program 25.7%
*-un-lft-identity25.7%
*-commutative25.7%
log-prod25.7%
*-un-lft-identity25.7%
*-un-lft-identity25.7%
add-sqr-sqrt13.1%
fabs-sqr13.1%
add-sqr-sqrt25.7%
+-commutative25.7%
hypot-1-def25.7%
metadata-eval25.7%
Applied egg-rr25.7%
+-rgt-identity25.7%
Simplified25.7%
Taylor expanded in x around 0 98.7%
if 0.5 < x Initial program 55.4%
*-un-lft-identity55.4%
*-commutative55.4%
log-prod55.4%
*-un-lft-identity55.4%
*-un-lft-identity55.4%
add-sqr-sqrt55.4%
fabs-sqr55.4%
add-sqr-sqrt55.4%
+-commutative55.4%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 96.5%
Final simplification98.3%
(FPCore (x)
:precision binary32
(if (<= x -40.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -40.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-40.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-40.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -40:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -40Initial program 50.3%
*-un-lft-identity50.3%
*-commutative50.3%
log-prod50.3%
*-un-lft-identity50.3%
*-un-lft-identity50.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.2%
+-commutative10.2%
hypot-1-def10.2%
metadata-eval10.2%
Applied egg-rr10.2%
+-rgt-identity10.2%
Simplified10.2%
Taylor expanded in x around -inf 99.3%
if -40 < x < 0.5Initial program 25.7%
*-un-lft-identity25.7%
*-commutative25.7%
log-prod25.7%
*-un-lft-identity25.7%
*-un-lft-identity25.7%
add-sqr-sqrt13.1%
fabs-sqr13.1%
add-sqr-sqrt25.7%
+-commutative25.7%
hypot-1-def25.7%
metadata-eval25.7%
Applied egg-rr25.7%
+-rgt-identity25.7%
Simplified25.7%
Taylor expanded in x around 0 98.7%
if 0.5 < x Initial program 55.4%
*-un-lft-identity55.4%
*-commutative55.4%
log-prod55.4%
*-un-lft-identity55.4%
*-un-lft-identity55.4%
add-sqr-sqrt55.4%
fabs-sqr55.4%
add-sqr-sqrt55.4%
+-commutative55.4%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 94.0%
*-commutative94.0%
Simplified94.0%
Final simplification97.7%
(FPCore (x) :precision binary32 (if (<= x -40.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -40.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-40.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-40.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -40:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -40Initial program 50.3%
*-un-lft-identity50.3%
*-commutative50.3%
log-prod50.3%
*-un-lft-identity50.3%
*-un-lft-identity50.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.2%
+-commutative10.2%
hypot-1-def10.2%
metadata-eval10.2%
Applied egg-rr10.2%
+-rgt-identity10.2%
Simplified10.2%
Taylor expanded in x around -inf 99.3%
if -40 < x < 0.5Initial program 25.7%
*-un-lft-identity25.7%
*-commutative25.7%
log-prod25.7%
*-un-lft-identity25.7%
*-un-lft-identity25.7%
add-sqr-sqrt13.1%
fabs-sqr13.1%
add-sqr-sqrt25.7%
+-commutative25.7%
hypot-1-def25.7%
metadata-eval25.7%
Applied egg-rr25.7%
+-rgt-identity25.7%
Simplified25.7%
Taylor expanded in x around 0 96.7%
if 0.5 < x Initial program 55.4%
*-un-lft-identity55.4%
*-commutative55.4%
log-prod55.4%
*-un-lft-identity55.4%
*-un-lft-identity55.4%
add-sqr-sqrt55.4%
fabs-sqr55.4%
add-sqr-sqrt55.4%
+-commutative55.4%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 94.0%
*-commutative94.0%
Simplified94.0%
Final simplification96.7%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(0.5)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 33.8%
*-un-lft-identity33.8%
*-commutative33.8%
log-prod33.8%
*-un-lft-identity33.8%
*-un-lft-identity33.8%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt20.6%
+-commutative20.6%
hypot-1-def20.6%
metadata-eval20.6%
Applied egg-rr20.6%
+-rgt-identity20.6%
Simplified20.6%
Taylor expanded in x around 0 68.2%
if 0.5 < x Initial program 55.4%
*-un-lft-identity55.4%
*-commutative55.4%
log-prod55.4%
*-un-lft-identity55.4%
*-un-lft-identity55.4%
add-sqr-sqrt55.4%
fabs-sqr55.4%
add-sqr-sqrt55.4%
+-commutative55.4%
hypot-1-def100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 94.0%
*-commutative94.0%
Simplified94.0%
Final simplification74.6%
(FPCore (x) :precision binary32 (if (<= x 5.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 5.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(5.0)) tmp = copysign(x, x); else tmp = copysign(log(x), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(5.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log(x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 5Initial program 35.2%
*-un-lft-identity35.2%
*-commutative35.2%
log-prod35.2%
*-un-lft-identity35.2%
*-un-lft-identity35.2%
add-sqr-sqrt10.6%
fabs-sqr10.6%
add-sqr-sqrt22.2%
+-commutative22.2%
hypot-1-def22.2%
metadata-eval22.2%
Applied egg-rr22.2%
+-rgt-identity22.2%
Simplified22.2%
Taylor expanded in x around 0 67.5%
if 5 < x Initial program 52.4%
Taylor expanded in x around inf 43.7%
mul-1-neg43.7%
log-rec43.7%
remove-double-neg43.7%
Simplified43.7%
Final simplification62.0%
(FPCore (x) :precision binary32 (if (<= x 0.5) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.5f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.5)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 0.5Initial program 33.8%
*-un-lft-identity33.8%
*-commutative33.8%
log-prod33.8%
*-un-lft-identity33.8%
*-un-lft-identity33.8%
add-sqr-sqrt8.8%
fabs-sqr8.8%
add-sqr-sqrt20.6%
+-commutative20.6%
hypot-1-def20.6%
metadata-eval20.6%
Applied egg-rr20.6%
+-rgt-identity20.6%
Simplified20.6%
Taylor expanded in x around 0 68.2%
if 0.5 < x Initial program 55.4%
Taylor expanded in x around 0 18.7%
Taylor expanded in x around 0 43.0%
log1p-def43.0%
rem-square-sqrt43.0%
fabs-sqr43.0%
rem-square-sqrt43.0%
Simplified43.0%
Final simplification62.0%
(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.1%
*-un-lft-identity39.1%
*-commutative39.1%
log-prod39.1%
*-un-lft-identity39.1%
*-un-lft-identity39.1%
add-sqr-sqrt20.2%
fabs-sqr20.2%
add-sqr-sqrt29.2%
+-commutative29.2%
hypot-1-def40.1%
metadata-eval40.1%
Applied egg-rr40.1%
+-rgt-identity40.1%
Simplified40.1%
Taylor expanded in x around 0 54.6%
Final simplification54.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 2024041
(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))