
(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.20000000298023224)
(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 (+ 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.20000000298023224f) {
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((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.20000000298023224)) 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(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.20000000298023224)) 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((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.20000000298023224:\\
\;\;\;\;\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(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.200000003Initial program 58.4%
+-commutative58.4%
hypot-1-def98.7%
Simplified98.7%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 21.8%
*-un-lft-identity21.8%
*-commutative21.8%
log-prod21.8%
+-commutative21.8%
hypot-1-def21.7%
add-sqr-sqrt12.4%
fabs-sqr12.4%
add-sqr-sqrt22.0%
metadata-eval22.0%
Applied egg-rr22.0%
+-rgt-identity22.0%
Simplified22.0%
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 43.9%
*-un-lft-identity43.9%
*-commutative43.9%
log-prod43.9%
+-commutative43.9%
hypot-1-def100.0%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (+ (- (fabs x) x) (/ -0.5 x))) x)
(if (<= x 0.10000000149011612)
(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 tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(((fabsf(x) - x) + (-0.5f / 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((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(abs(x) - x) + Float32(Float32(-0.5) / 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(x + hypot(Float32(1.0), 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(((abs(x) - x) + (single(-0.5) / 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((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \frac{-0.5}{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(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 57.2%
Taylor expanded in x around -inf 96.9%
sub-neg96.9%
neg-mul-196.9%
unsub-neg96.9%
associate-*r/96.9%
metadata-eval96.9%
distribute-neg-frac96.9%
metadata-eval96.9%
Simplified96.9%
if -1 < x < 0.100000001Initial program 23.1%
*-un-lft-identity23.1%
*-commutative23.1%
log-prod23.1%
+-commutative23.1%
hypot-1-def23.0%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt23.2%
metadata-eval23.2%
Applied egg-rr23.2%
+-rgt-identity23.2%
Simplified23.2%
Taylor expanded in x around 0 99.4%
if 0.100000001 < x Initial program 43.9%
*-un-lft-identity43.9%
*-commutative43.9%
log-prod43.9%
+-commutative43.9%
hypot-1-def100.0%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (+ (- (fabs x) x) (/ -0.5 x))) x)
(if (<= x 0.05000000074505806)
(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 <= -1.0f) {
tmp = copysignf(logf(((fabsf(x) - x) + (-0.5f / x))), x);
} else if (x <= 0.05000000074505806f) {
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(-1.0)) tmp = copysign(log(Float32(Float32(abs(x) - x) + Float32(Float32(-0.5) / x))), x); elseif (x <= Float32(0.05000000074505806)) 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(-1.0)) tmp = sign(x) * abs(log(((abs(x) - x) + (single(-0.5) / x)))); elseif (x <= single(0.05000000074505806)) 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\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 < -1Initial program 57.2%
Taylor expanded in x around -inf 96.9%
sub-neg96.9%
neg-mul-196.9%
unsub-neg96.9%
associate-*r/96.9%
metadata-eval96.9%
distribute-neg-frac96.9%
metadata-eval96.9%
Simplified96.9%
if -1 < x < 0.0500000007Initial program 21.9%
*-un-lft-identity21.9%
*-commutative21.9%
log-prod21.9%
+-commutative21.9%
hypot-1-def21.8%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt22.0%
metadata-eval22.0%
Applied egg-rr22.0%
+-rgt-identity22.0%
Simplified22.0%
Taylor expanded in x around 0 99.2%
if 0.0500000007 < x Initial program 45.4%
*-un-lft-identity45.4%
*-commutative45.4%
log-prod45.4%
+-commutative45.4%
hypot-1-def99.8%
add-sqr-sqrt99.7%
fabs-sqr99.7%
add-sqr-sqrt99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.05000000074505806)
(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 <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.05000000074505806f) {
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(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.05000000074505806)) 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(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.05000000074505806)) 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\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 < -1Initial program 57.2%
*-un-lft-identity57.2%
*-commutative57.2%
log-prod57.2%
+-commutative57.2%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.2%
metadata-eval13.2%
Applied egg-rr13.2%
+-rgt-identity13.2%
Simplified13.2%
Taylor expanded in x around -inf 96.4%
if -1 < x < 0.0500000007Initial program 21.9%
*-un-lft-identity21.9%
*-commutative21.9%
log-prod21.9%
+-commutative21.9%
hypot-1-def21.8%
add-sqr-sqrt10.8%
fabs-sqr10.8%
add-sqr-sqrt22.0%
metadata-eval22.0%
Applied egg-rr22.0%
+-rgt-identity22.0%
Simplified22.0%
Taylor expanded in x around 0 99.2%
if 0.0500000007 < x Initial program 45.4%
*-un-lft-identity45.4%
*-commutative45.4%
log-prod45.4%
+-commutative45.4%
hypot-1-def99.8%
add-sqr-sqrt99.7%
fabs-sqr99.7%
add-sqr-sqrt99.8%
metadata-eval99.8%
Applied egg-rr99.8%
+-rgt-identity99.8%
Simplified99.8%
Final simplification98.6%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(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 <= -1.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(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.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(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(-1.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(((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 -1:\\
\;\;\;\;\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(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 57.2%
*-un-lft-identity57.2%
*-commutative57.2%
log-prod57.2%
+-commutative57.2%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.2%
metadata-eval13.2%
Applied egg-rr13.2%
+-rgt-identity13.2%
Simplified13.2%
Taylor expanded in x around -inf 96.4%
if -1 < x < 0.100000001Initial program 23.1%
*-un-lft-identity23.1%
*-commutative23.1%
log-prod23.1%
+-commutative23.1%
hypot-1-def23.0%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt23.2%
metadata-eval23.2%
Applied egg-rr23.2%
+-rgt-identity23.2%
Simplified23.2%
Taylor expanded in x around 0 98.9%
if 0.100000001 < x Initial program 43.9%
*-un-lft-identity43.9%
*-commutative43.9%
log-prod43.9%
+-commutative43.9%
hypot-1-def100.0%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 99.4%
Final simplification98.3%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.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((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.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(x * Float32(2.0))), 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(-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((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\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(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 57.2%
*-un-lft-identity57.2%
*-commutative57.2%
log-prod57.2%
+-commutative57.2%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.2%
metadata-eval13.2%
Applied egg-rr13.2%
+-rgt-identity13.2%
Simplified13.2%
Taylor expanded in x around -inf 96.4%
if -1 < x < 0.100000001Initial program 23.1%
*-un-lft-identity23.1%
*-commutative23.1%
log-prod23.1%
+-commutative23.1%
hypot-1-def23.0%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt23.2%
metadata-eval23.2%
Applied egg-rr23.2%
+-rgt-identity23.2%
Simplified23.2%
Taylor expanded in x around 0 98.9%
if 0.100000001 < x Initial program 43.9%
*-un-lft-identity43.9%
*-commutative43.9%
log-prod43.9%
+-commutative43.9%
hypot-1-def100.0%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.9%
*-commutative98.9%
Simplified98.9%
Final simplification98.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign x x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.10000000149011612)) 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(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.10000000149011612)) 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\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 < -1Initial program 57.2%
*-un-lft-identity57.2%
*-commutative57.2%
log-prod57.2%
+-commutative57.2%
hypot-1-def98.7%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.2%
metadata-eval13.2%
Applied egg-rr13.2%
+-rgt-identity13.2%
Simplified13.2%
Taylor expanded in x around -inf 96.4%
if -1 < x < 0.100000001Initial program 23.1%
*-un-lft-identity23.1%
*-commutative23.1%
log-prod23.1%
+-commutative23.1%
hypot-1-def23.0%
add-sqr-sqrt12.2%
fabs-sqr12.2%
add-sqr-sqrt23.2%
metadata-eval23.2%
Applied egg-rr23.2%
+-rgt-identity23.2%
Simplified23.2%
Taylor expanded in x around 0 96.8%
if 0.100000001 < x Initial program 43.9%
*-un-lft-identity43.9%
*-commutative43.9%
log-prod43.9%
+-commutative43.9%
hypot-1-def100.0%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.9%
*-commutative98.9%
Simplified98.9%
Final simplification97.2%
(FPCore (x) :precision binary32 (if (<= x 0.10000000149011612) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.10000000149011612f) {
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.10000000149011612)) 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.10000000149011612)) 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.10000000149011612:\\
\;\;\;\;\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.100000001Initial program 35.6%
*-un-lft-identity35.6%
*-commutative35.6%
log-prod35.6%
+-commutative35.6%
hypot-1-def50.7%
add-sqr-sqrt7.7%
fabs-sqr7.7%
add-sqr-sqrt19.5%
metadata-eval19.5%
Applied egg-rr19.5%
+-rgt-identity19.5%
Simplified19.5%
Taylor expanded in x around 0 65.5%
if 0.100000001 < x Initial program 43.9%
*-un-lft-identity43.9%
*-commutative43.9%
log-prod43.9%
+-commutative43.9%
hypot-1-def100.0%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.9%
*-commutative98.9%
Simplified98.9%
Final simplification74.0%
(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.9%
*-un-lft-identity35.9%
*-commutative35.9%
log-prod35.9%
+-commutative35.9%
hypot-1-def51.0%
add-sqr-sqrt8.2%
fabs-sqr8.2%
add-sqr-sqrt19.9%
metadata-eval19.9%
Applied egg-rr19.9%
+-rgt-identity19.9%
Simplified19.9%
Taylor expanded in x around 0 65.3%
if 5 < x Initial program 43.0%
Taylor expanded in x around inf 45.3%
mul-1-neg45.3%
log-rec45.3%
remove-double-neg45.3%
Simplified45.3%
Final simplification60.3%
(FPCore (x) :precision binary32 (if (<= x 0.10000000149011612) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 0.10000000149011612f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(0.10000000149011612)) 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.10000000149011612:\\
\;\;\;\;\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.100000001Initial program 35.6%
*-un-lft-identity35.6%
*-commutative35.6%
log-prod35.6%
+-commutative35.6%
hypot-1-def50.7%
add-sqr-sqrt7.7%
fabs-sqr7.7%
add-sqr-sqrt19.5%
metadata-eval19.5%
Applied egg-rr19.5%
+-rgt-identity19.5%
Simplified19.5%
Taylor expanded in x around 0 65.5%
if 0.100000001 < x Initial program 43.9%
Taylor expanded in x around 0 45.1%
log1p-def45.1%
Simplified45.1%
add-log-exp45.1%
*-un-lft-identity45.1%
log-prod45.1%
metadata-eval45.1%
add-log-exp45.1%
add-sqr-sqrt45.1%
fabs-sqr45.1%
add-sqr-sqrt45.1%
Applied egg-rr45.1%
+-lft-identity45.1%
Simplified45.1%
Final simplification60.3%
(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 37.7%
*-un-lft-identity37.7%
*-commutative37.7%
log-prod37.7%
+-commutative37.7%
hypot-1-def63.2%
add-sqr-sqrt31.1%
fabs-sqr31.1%
add-sqr-sqrt40.0%
metadata-eval40.0%
Applied egg-rr40.0%
+-rgt-identity40.0%
Simplified40.0%
Taylor expanded in x around 0 51.5%
Final simplification51.5%
(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 2024010
(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))