
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.5)
(copysign (- (log (/ (- x (hypot 1.0 x)) -1.0))) x)
(if (<= t_0 0.20000000298023224)
(copysign
(+ x (+ (* 0.075 (pow x 5.0)) (* -0.16666666666666666 (pow x 3.0))))
x)
(copysign (log (+ x (hypot 1.0 x))) x)))))
float code(float x) {
float t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.5f) {
tmp = copysignf(-logf(((x - hypotf(1.0f, x)) / -1.0f)), x);
} else if (t_0 <= 0.20000000298023224f) {
tmp = copysignf((x + ((0.075f * powf(x, 5.0f)) + (-0.16666666666666666f * powf(x, 3.0f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) t_0 = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) tmp = Float32(0.0) if (t_0 <= Float32(-0.5)) tmp = copysign(Float32(-log(Float32(Float32(x - hypot(Float32(1.0), x)) / Float32(-1.0)))), x); elseif (t_0 <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(Float32(0.075) * (x ^ Float32(5.0))) + 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) 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(((x - hypot(single(1.0), x)) / single(-1.0)))); elseif (t_0 <= single(0.20000000298023224)) tmp = sign(x) * abs((x + ((single(0.075) * (x ^ single(5.0))) + (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}
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(\frac{x - \mathsf{hypot}\left(1, x\right)}{-1}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(0.075 \cdot {x}^{5} + -0.16666666666666666 \cdot {x}^{3}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.5Initial program 58.7%
flip-+11.7%
clear-num11.6%
log-rec11.6%
+-commutative11.6%
hypot-1-def11.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.5%
Applied egg-rr14.7%
Taylor expanded in x around 0 100.0%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 19.1%
*-un-lft-identity19.1%
*-commutative19.1%
log-prod19.1%
*-un-lft-identity19.1%
*-un-lft-identity19.1%
add-sqr-sqrt10.4%
fabs-sqr10.4%
add-sqr-sqrt19.4%
+-commutative19.4%
hypot-1-def19.4%
metadata-eval19.4%
Applied egg-rr19.4%
+-rgt-identity19.4%
Simplified19.4%
Taylor expanded in x around 0 100.0%
if 0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 52.0%
*-un-lft-identity52.0%
*-commutative52.0%
log-prod52.0%
*-un-lft-identity52.0%
*-un-lft-identity52.0%
add-sqr-sqrt51.9%
fabs-sqr51.9%
add-sqr-sqrt52.0%
+-commutative52.0%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (- (fabs x) 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 <= -2.0f) {
tmp = copysignf(logf((fabsf(x) - 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(-2.0)) tmp = copysign(log(Float32(abs(x) - 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(-2.0)) tmp = sign(x) * abs(log((abs(x) - 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - 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 < -2Initial program 57.5%
Taylor expanded in x around -inf 97.0%
neg-mul-197.0%
unsub-neg97.0%
Simplified97.0%
if -2 < x < 0.0500000007Initial program 19.8%
*-un-lft-identity19.8%
*-commutative19.8%
log-prod19.8%
*-un-lft-identity19.8%
*-un-lft-identity19.8%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt20.1%
+-commutative20.1%
hypot-1-def20.2%
metadata-eval20.2%
Applied egg-rr20.2%
+-rgt-identity20.2%
Simplified20.2%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
Simplified98.8%
if 0.0500000007 < x Initial program 52.5%
*-un-lft-identity52.5%
*-commutative52.5%
log-prod52.5%
*-un-lft-identity52.5%
*-un-lft-identity52.5%
add-sqr-sqrt52.4%
fabs-sqr52.4%
add-sqr-sqrt52.5%
+-commutative52.5%
hypot-1-def98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification98.3%
(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 58.1%
Taylor expanded in x around -inf 98.4%
sub-neg98.4%
neg-mul-198.4%
unsub-neg98.4%
associate-*r/98.4%
metadata-eval98.4%
distribute-neg-frac98.4%
metadata-eval98.4%
Simplified98.4%
if -1 < x < 0.0500000007Initial program 19.1%
*-un-lft-identity19.1%
*-commutative19.1%
log-prod19.1%
*-un-lft-identity19.1%
*-un-lft-identity19.1%
add-sqr-sqrt9.6%
fabs-sqr9.6%
add-sqr-sqrt19.5%
+-commutative19.5%
hypot-1-def19.4%
metadata-eval19.4%
Applied egg-rr19.4%
+-rgt-identity19.4%
Simplified19.4%
Taylor expanded in x around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 0.0500000007 < x Initial program 52.5%
*-un-lft-identity52.5%
*-commutative52.5%
log-prod52.5%
*-un-lft-identity52.5%
*-un-lft-identity52.5%
add-sqr-sqrt52.4%
fabs-sqr52.4%
add-sqr-sqrt52.5%
+-commutative52.5%
hypot-1-def98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -0.5)
(copysign (- (log (/ (- x (hypot 1.0 x)) -1.0))) 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 <= -0.5f) {
tmp = copysignf(-logf(((x - hypotf(1.0f, x)) / -1.0f)), 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(-0.5)) tmp = copysign(Float32(-log(Float32(Float32(x - hypot(Float32(1.0), x)) / Float32(-1.0)))), 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(-0.5)) tmp = sign(x) * abs(-log(((x - hypot(single(1.0), x)) / single(-1.0)))); 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 -0.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{x - \mathsf{hypot}\left(1, x\right)}{-1}\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 < -0.5Initial program 58.7%
flip-+11.7%
clear-num11.6%
log-rec11.6%
+-commutative11.6%
hypot-1-def11.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.5%
Applied egg-rr14.7%
Taylor expanded in x around 0 100.0%
if -0.5 < x < 0.0500000007Initial program 18.4%
*-un-lft-identity18.4%
*-commutative18.4%
log-prod18.4%
*-un-lft-identity18.4%
*-un-lft-identity18.4%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt18.7%
+-commutative18.7%
hypot-1-def18.7%
metadata-eval18.7%
Applied egg-rr18.7%
+-rgt-identity18.7%
Simplified18.7%
Taylor expanded in x around 0 99.9%
*-commutative99.9%
Simplified99.9%
if 0.0500000007 < x Initial program 52.5%
*-un-lft-identity52.5%
*-commutative52.5%
log-prod52.5%
*-un-lft-identity52.5%
*-un-lft-identity52.5%
add-sqr-sqrt52.4%
fabs-sqr52.4%
add-sqr-sqrt52.5%
+-commutative52.5%
hypot-1-def98.6%
metadata-eval98.6%
Applied egg-rr98.6%
+-rgt-identity98.6%
Simplified98.6%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 2.0)
(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 <= 2.0f) {
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(2.0)) 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(2.0)) 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 2:\\
\;\;\;\;\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 57.5%
Taylor expanded in x around -inf 97.0%
neg-mul-197.0%
unsub-neg97.0%
Simplified97.0%
if -2 < x < 2Initial program 23.9%
*-un-lft-identity23.9%
*-commutative23.9%
log-prod23.9%
*-un-lft-identity23.9%
*-un-lft-identity23.9%
add-sqr-sqrt14.0%
fabs-sqr14.0%
add-sqr-sqrt24.1%
+-commutative24.1%
hypot-1-def24.1%
metadata-eval24.1%
Applied egg-rr24.1%
+-rgt-identity24.1%
Simplified24.1%
Taylor expanded in x around 0 96.4%
*-commutative96.4%
Simplified96.4%
if 2 < x Initial program 48.7%
*-un-lft-identity48.7%
*-commutative48.7%
log-prod48.7%
*-un-lft-identity48.7%
*-un-lft-identity48.7%
add-sqr-sqrt48.7%
fabs-sqr48.7%
add-sqr-sqrt48.7%
+-commutative48.7%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 98.5%
Taylor expanded in x around 0 98.4%
mul-1-neg98.4%
unsub-neg98.4%
log-div99.1%
Simplified99.1%
Final simplification97.3%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 2.0)
(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 <= 2.0f) {
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(2.0)) 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(2.0)) 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 2:\\
\;\;\;\;\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 57.5%
*-un-lft-identity57.5%
*-commutative57.5%
log-prod57.5%
*-un-lft-identity57.5%
*-un-lft-identity57.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.6%
+-commutative14.6%
hypot-1-def14.7%
metadata-eval14.7%
Applied egg-rr14.7%
+-rgt-identity14.7%
Simplified14.7%
Taylor expanded in x around -inf 97.0%
if -2 < x < 2Initial program 23.9%
*-un-lft-identity23.9%
*-commutative23.9%
log-prod23.9%
*-un-lft-identity23.9%
*-un-lft-identity23.9%
add-sqr-sqrt14.0%
fabs-sqr14.0%
add-sqr-sqrt24.1%
+-commutative24.1%
hypot-1-def24.1%
metadata-eval24.1%
Applied egg-rr24.1%
+-rgt-identity24.1%
Simplified24.1%
Taylor expanded in x around 0 96.4%
*-commutative96.4%
Simplified96.4%
if 2 < x Initial program 48.7%
*-un-lft-identity48.7%
*-commutative48.7%
log-prod48.7%
*-un-lft-identity48.7%
*-un-lft-identity48.7%
add-sqr-sqrt48.7%
fabs-sqr48.7%
add-sqr-sqrt48.7%
+-commutative48.7%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 98.5%
Taylor expanded in x around 0 98.4%
mul-1-neg98.4%
unsub-neg98.4%
log-div99.1%
Simplified99.1%
Final simplification97.3%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 2.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), 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(2.0)) 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(2.0)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\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 < -2Initial program 57.5%
*-un-lft-identity57.5%
*-commutative57.5%
log-prod57.5%
*-un-lft-identity57.5%
*-un-lft-identity57.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.6%
+-commutative14.6%
hypot-1-def14.7%
metadata-eval14.7%
Applied egg-rr14.7%
+-rgt-identity14.7%
Simplified14.7%
Taylor expanded in x around -inf 97.0%
if -2 < x < 2Initial program 23.9%
*-un-lft-identity23.9%
*-commutative23.9%
log-prod23.9%
*-un-lft-identity23.9%
*-un-lft-identity23.9%
add-sqr-sqrt14.0%
fabs-sqr14.0%
add-sqr-sqrt24.1%
+-commutative24.1%
hypot-1-def24.1%
metadata-eval24.1%
Applied egg-rr24.1%
+-rgt-identity24.1%
Simplified24.1%
Taylor expanded in x around 0 94.4%
if 2 < x Initial program 48.7%
*-un-lft-identity48.7%
*-commutative48.7%
log-prod48.7%
*-un-lft-identity48.7%
*-un-lft-identity48.7%
add-sqr-sqrt48.7%
fabs-sqr48.7%
add-sqr-sqrt48.7%
+-commutative48.7%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 97.9%
*-commutative97.9%
Simplified97.9%
Final simplification96.1%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 2.0) (copysign x 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 <= 2.0f) {
tmp = copysignf(x, 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(2.0)) tmp = copysign(x, 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(2.0)) tmp = sign(x) * abs(x); 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 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 57.5%
*-un-lft-identity57.5%
*-commutative57.5%
log-prod57.5%
*-un-lft-identity57.5%
*-un-lft-identity57.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.6%
+-commutative14.6%
hypot-1-def14.7%
metadata-eval14.7%
Applied egg-rr14.7%
+-rgt-identity14.7%
Simplified14.7%
Taylor expanded in x around -inf 97.0%
if -2 < x < 2Initial program 23.9%
*-un-lft-identity23.9%
*-commutative23.9%
log-prod23.9%
*-un-lft-identity23.9%
*-un-lft-identity23.9%
add-sqr-sqrt14.0%
fabs-sqr14.0%
add-sqr-sqrt24.1%
+-commutative24.1%
hypot-1-def24.1%
metadata-eval24.1%
Applied egg-rr24.1%
+-rgt-identity24.1%
Simplified24.1%
Taylor expanded in x around 0 94.4%
if 2 < x Initial program 48.7%
*-un-lft-identity48.7%
*-commutative48.7%
log-prod48.7%
*-un-lft-identity48.7%
*-un-lft-identity48.7%
add-sqr-sqrt48.7%
fabs-sqr48.7%
add-sqr-sqrt48.7%
+-commutative48.7%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 98.5%
Taylor expanded in x around 0 98.4%
mul-1-neg98.4%
unsub-neg98.4%
log-div99.1%
Simplified99.1%
Final simplification96.4%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(2.0)) 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(2.0)) 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 2:\\
\;\;\;\;\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 < 2Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt9.0%
fabs-sqr9.0%
add-sqr-sqrt20.7%
+-commutative20.7%
hypot-1-def20.7%
metadata-eval20.7%
Applied egg-rr20.7%
+-rgt-identity20.7%
Simplified20.7%
Taylor expanded in x around 0 64.6%
if 2 < x Initial program 48.7%
*-un-lft-identity48.7%
*-commutative48.7%
log-prod48.7%
*-un-lft-identity48.7%
*-un-lft-identity48.7%
add-sqr-sqrt48.7%
fabs-sqr48.7%
add-sqr-sqrt48.7%
+-commutative48.7%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Taylor expanded in x around inf 97.9%
*-commutative97.9%
Simplified97.9%
Final simplification74.1%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(2.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(2.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 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 2Initial program 36.0%
*-un-lft-identity36.0%
*-commutative36.0%
log-prod36.0%
*-un-lft-identity36.0%
*-un-lft-identity36.0%
add-sqr-sqrt9.0%
fabs-sqr9.0%
add-sqr-sqrt20.7%
+-commutative20.7%
hypot-1-def20.7%
metadata-eval20.7%
Applied egg-rr20.7%
+-rgt-identity20.7%
Simplified20.7%
Taylor expanded in x around 0 64.6%
if 2 < x Initial program 48.7%
Taylor expanded in x around inf 44.6%
mul-1-neg44.6%
log-rec44.6%
remove-double-neg44.6%
Simplified44.6%
Final simplification58.9%
(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.6%
*-un-lft-identity39.6%
*-commutative39.6%
log-prod39.6%
*-un-lft-identity39.6%
*-un-lft-identity39.6%
add-sqr-sqrt20.3%
fabs-sqr20.3%
add-sqr-sqrt28.7%
+-commutative28.7%
hypot-1-def43.0%
metadata-eval43.0%
Applied egg-rr43.0%
+-rgt-identity43.0%
Simplified43.0%
Taylor expanded in x around 0 49.3%
Final simplification49.3%
(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 2024024
(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))