
(FPCore (x) :precision binary32 (asinh x))
float code(float x) {
return asinhf(x);
}
function code(x) return asinh(x) end
function tmp = code(x) tmp = asinh(x); end
\begin{array}{l}
\\
\sinh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\end{array}
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.20000000298023224)
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)
(if (<= t_0 0.00039999998989515007)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
x)
(copysign (log1p (+ (+ x (hypot 1.0 x)) -1.0)) 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.00039999998989515007f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(log1pf(((x + hypotf(1.0f, x)) + -1.0f)), 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.00039999998989515007)) 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(log1p(Float32(Float32(x + hypot(Float32(1.0), x)) + Float32(-1.0))), x); end return 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.00039999998989515007:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left(x + \mathsf{hypot}\left(1, x\right)\right) + -1\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 55.3%
+-commutative55.3%
hypot-1-def100.0%
Simplified100.0%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 3.9999999e-4Initial program 18.6%
*-un-lft-identity18.6%
*-commutative18.6%
log-prod18.6%
+-commutative18.6%
hypot-1-def18.6%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt19.0%
metadata-eval19.0%
Applied egg-rr19.0%
+-rgt-identity19.0%
Simplified19.0%
Taylor expanded in x around 0 100.0%
if 3.9999999e-4 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 61.1%
log1p-expm1-u61.1%
expm1-udef61.1%
add-exp-log61.2%
add-sqr-sqrt61.2%
fabs-sqr61.2%
add-sqr-sqrt61.2%
+-commutative61.2%
hypot-1-def99.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.4000000059604645)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.00039999998989515007)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
x)
(copysign (log1p (+ (+ x (hypot 1.0 x)) -1.0)) x))))
float code(float x) {
float tmp;
if (x <= -0.4000000059604645f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.00039999998989515007f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(log1pf(((x + hypotf(1.0f, x)) + -1.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.4000000059604645)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.00039999998989515007)) 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(log1p(Float32(Float32(x + hypot(Float32(1.0), x)) + Float32(-1.0))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.00039999998989515007:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left(x + \mathsf{hypot}\left(1, x\right)\right) + -1\right), x\right)\\
\end{array}
\end{array}
if x < -0.400000006Initial program 55.3%
*-un-lft-identity55.3%
*-commutative55.3%
log-prod55.3%
+-commutative55.3%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.3%
metadata-eval14.3%
Applied egg-rr14.3%
+-rgt-identity14.3%
Simplified14.3%
flip-+11.6%
unpow211.6%
div-sub11.3%
hypot-udef11.6%
metadata-eval11.6%
unpow211.6%
hypot-udef11.3%
metadata-eval11.3%
unpow211.3%
add-sqr-sqrt11.7%
+-commutative11.7%
Applied egg-rr11.7%
div-sub13.1%
associate--r+52.1%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
+-inverses52.1%
associate--r+13.1%
associate-/r*13.1%
neg-sub013.1%
neg-mul-113.1%
associate--r+52.1%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if -0.400000006 < x < 3.9999999e-4Initial program 18.6%
*-un-lft-identity18.6%
*-commutative18.6%
log-prod18.6%
+-commutative18.6%
hypot-1-def18.6%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt19.0%
metadata-eval19.0%
Applied egg-rr19.0%
+-rgt-identity19.0%
Simplified19.0%
Taylor expanded in x around 0 100.0%
if 3.9999999e-4 < x Initial program 61.1%
log1p-expm1-u61.1%
expm1-udef61.1%
add-exp-log61.2%
add-sqr-sqrt61.2%
fabs-sqr61.2%
add-sqr-sqrt61.2%
+-commutative61.2%
hypot-1-def99.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (x)
:precision binary32
(if (<= x -0.4000000059604645)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.00039999998989515007)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log1p (+ (+ x (hypot 1.0 x)) -1.0)) x))))
float code(float x) {
float tmp;
if (x <= -0.4000000059604645f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.00039999998989515007f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(log1pf(((x + hypotf(1.0f, x)) + -1.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.4000000059604645)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.00039999998989515007)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log1p(Float32(Float32(x + hypot(Float32(1.0), x)) + Float32(-1.0))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.00039999998989515007:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\left(x + \mathsf{hypot}\left(1, x\right)\right) + -1\right), x\right)\\
\end{array}
\end{array}
if x < -0.400000006Initial program 55.3%
*-un-lft-identity55.3%
*-commutative55.3%
log-prod55.3%
+-commutative55.3%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.3%
metadata-eval14.3%
Applied egg-rr14.3%
+-rgt-identity14.3%
Simplified14.3%
flip-+11.6%
unpow211.6%
div-sub11.3%
hypot-udef11.6%
metadata-eval11.6%
unpow211.6%
hypot-udef11.3%
metadata-eval11.3%
unpow211.3%
add-sqr-sqrt11.7%
+-commutative11.7%
Applied egg-rr11.7%
div-sub13.1%
associate--r+52.1%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
+-inverses52.1%
associate--r+13.1%
associate-/r*13.1%
neg-sub013.1%
neg-mul-113.1%
associate--r+52.1%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if -0.400000006 < x < 3.9999999e-4Initial program 18.6%
*-un-lft-identity18.6%
*-commutative18.6%
log-prod18.6%
+-commutative18.6%
hypot-1-def18.6%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt19.0%
metadata-eval19.0%
Applied egg-rr19.0%
+-rgt-identity19.0%
Simplified19.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 3.9999999e-4 < x Initial program 61.1%
log1p-expm1-u61.1%
expm1-udef61.1%
add-exp-log61.2%
add-sqr-sqrt61.2%
fabs-sqr61.2%
add-sqr-sqrt61.2%
+-commutative61.2%
hypot-1-def99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.00039999998989515007)
(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 <= -5.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else if (x <= 0.00039999998989515007f) {
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(-5.0)) tmp = copysign(log(Float32(abs(x) - x)), x); elseif (x <= Float32(0.00039999998989515007)) 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(-5.0)) tmp = sign(x) * abs(log((abs(x) - x))); elseif (x <= single(0.00039999998989515007)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.00039999998989515007:\\
\;\;\;\;\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 < -5Initial program 54.0%
Taylor expanded in x around -inf 98.1%
neg-mul-198.1%
unsub-neg98.1%
Simplified98.1%
if -5 < x < 3.9999999e-4Initial program 19.8%
*-un-lft-identity19.8%
*-commutative19.8%
log-prod19.8%
+-commutative19.8%
hypot-1-def19.8%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt20.2%
metadata-eval20.2%
Applied egg-rr20.2%
+-rgt-identity20.2%
Simplified20.2%
Taylor expanded in x around 0 99.3%
*-commutative99.3%
Simplified99.3%
if 3.9999999e-4 < x Initial program 61.1%
*-un-lft-identity61.1%
*-commutative61.1%
log-prod61.1%
+-commutative61.1%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.1%
(FPCore (x)
:precision binary32
(if (<= x -0.4000000059604645)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.00039999998989515007)
(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.4000000059604645f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.00039999998989515007f) {
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.4000000059604645)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.00039999998989515007)) 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.4000000059604645)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.00039999998989515007)) 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.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.00039999998989515007:\\
\;\;\;\;\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.400000006Initial program 55.3%
*-un-lft-identity55.3%
*-commutative55.3%
log-prod55.3%
+-commutative55.3%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.3%
metadata-eval14.3%
Applied egg-rr14.3%
+-rgt-identity14.3%
Simplified14.3%
flip-+11.6%
unpow211.6%
div-sub11.3%
hypot-udef11.6%
metadata-eval11.6%
unpow211.6%
hypot-udef11.3%
metadata-eval11.3%
unpow211.3%
add-sqr-sqrt11.7%
+-commutative11.7%
Applied egg-rr11.7%
div-sub13.1%
associate--r+52.1%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
+-inverses52.1%
associate--r+13.1%
associate-/r*13.1%
neg-sub013.1%
neg-mul-113.1%
associate--r+52.1%
+-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
neg-sub099.9%
associate--r-99.9%
neg-sub099.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if -0.400000006 < x < 3.9999999e-4Initial program 18.6%
*-un-lft-identity18.6%
*-commutative18.6%
log-prod18.6%
+-commutative18.6%
hypot-1-def18.6%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt19.0%
metadata-eval19.0%
Applied egg-rr19.0%
+-rgt-identity19.0%
Simplified19.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 3.9999999e-4 < x Initial program 61.1%
*-un-lft-identity61.1%
*-commutative61.1%
log-prod61.1%
+-commutative61.1%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.4000000059604645)
(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 <= -5.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else if (x <= 0.4000000059604645f) {
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(-5.0)) tmp = copysign(log(Float32(abs(x) - x)), x); elseif (x <= Float32(0.4000000059604645)) 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(-5.0)) tmp = sign(x) * abs(log((abs(x) - x))); elseif (x <= single(0.4000000059604645)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.4000000059604645:\\
\;\;\;\;\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 < -5Initial program 54.0%
Taylor expanded in x around -inf 98.1%
neg-mul-198.1%
unsub-neg98.1%
Simplified98.1%
if -5 < x < 0.400000006Initial program 20.3%
*-un-lft-identity20.3%
*-commutative20.3%
log-prod20.3%
+-commutative20.3%
hypot-1-def20.3%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt20.7%
metadata-eval20.7%
Applied egg-rr20.7%
+-rgt-identity20.7%
Simplified20.7%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
Simplified99.0%
if 0.400000006 < x Initial program 60.5%
*-un-lft-identity60.5%
*-commutative60.5%
log-prod60.5%
+-commutative60.5%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around inf 98.7%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.4000000059604645)
(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 <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.4000000059604645f) {
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(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.4000000059604645)) 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.4000000059604645)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.4000000059604645:\\
\;\;\;\;\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 < -5Initial program 54.0%
*-un-lft-identity54.0%
*-commutative54.0%
log-prod54.0%
+-commutative54.0%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.8%
metadata-eval11.8%
Applied egg-rr11.8%
+-rgt-identity11.8%
Simplified11.8%
Taylor expanded in x around -inf 98.1%
if -5 < x < 0.400000006Initial program 20.3%
*-un-lft-identity20.3%
*-commutative20.3%
log-prod20.3%
+-commutative20.3%
hypot-1-def20.3%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt20.7%
metadata-eval20.7%
Applied egg-rr20.7%
+-rgt-identity20.7%
Simplified20.7%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
Simplified99.0%
if 0.400000006 < x Initial program 60.5%
*-un-lft-identity60.5%
*-commutative60.5%
log-prod60.5%
+-commutative60.5%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around inf 98.7%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.4000000059604645)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.4000000059604645f) {
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(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.4000000059604645)) 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.4000000059604645)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.4000000059604645:\\
\;\;\;\;\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 < -5Initial program 54.0%
*-un-lft-identity54.0%
*-commutative54.0%
log-prod54.0%
+-commutative54.0%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.8%
metadata-eval11.8%
Applied egg-rr11.8%
+-rgt-identity11.8%
Simplified11.8%
Taylor expanded in x around -inf 98.1%
if -5 < x < 0.400000006Initial program 20.3%
*-un-lft-identity20.3%
*-commutative20.3%
log-prod20.3%
+-commutative20.3%
hypot-1-def20.3%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt20.7%
metadata-eval20.7%
Applied egg-rr20.7%
+-rgt-identity20.7%
Simplified20.7%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
Simplified99.0%
if 0.400000006 < x Initial program 60.5%
*-un-lft-identity60.5%
*-commutative60.5%
log-prod60.5%
+-commutative60.5%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around inf 95.3%
*-commutative95.3%
Simplified95.3%
Final simplification97.9%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (/ -0.5 x)) x) (if (<= x 0.4000000059604645) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.4000000059604645f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.4000000059604645)) 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(-5.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.4000000059604645)) 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 -5:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.4000000059604645:\\
\;\;\;\;\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 < -5Initial program 54.0%
*-un-lft-identity54.0%
*-commutative54.0%
log-prod54.0%
+-commutative54.0%
hypot-1-def100.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.8%
metadata-eval11.8%
Applied egg-rr11.8%
+-rgt-identity11.8%
Simplified11.8%
Taylor expanded in x around -inf 98.1%
if -5 < x < 0.400000006Initial program 20.3%
*-un-lft-identity20.3%
*-commutative20.3%
log-prod20.3%
+-commutative20.3%
hypot-1-def20.3%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt20.7%
metadata-eval20.7%
Applied egg-rr20.7%
+-rgt-identity20.7%
Simplified20.7%
Taylor expanded in x around 0 97.8%
if 0.400000006 < x Initial program 60.5%
*-un-lft-identity60.5%
*-commutative60.5%
log-prod60.5%
+-commutative60.5%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around inf 95.3%
*-commutative95.3%
Simplified95.3%
Final simplification97.3%
(FPCore (x) :precision binary32 (if (<= x 0.4000000059604645) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 0.4000000059604645f) {
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.4000000059604645)) 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.4000000059604645)) 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.4000000059604645:\\
\;\;\;\;\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.400000006Initial program 31.3%
*-un-lft-identity31.3%
*-commutative31.3%
log-prod31.3%
+-commutative31.3%
hypot-1-def46.4%
add-sqr-sqrt6.6%
fabs-sqr6.6%
add-sqr-sqrt17.8%
metadata-eval17.8%
Applied egg-rr17.8%
+-rgt-identity17.8%
Simplified17.8%
Taylor expanded in x around 0 69.4%
if 0.400000006 < x Initial program 60.5%
*-un-lft-identity60.5%
*-commutative60.5%
log-prod60.5%
+-commutative60.5%
hypot-1-def99.9%
add-sqr-sqrt99.9%
fabs-sqr99.9%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Taylor expanded in x around inf 95.3%
*-commutative95.3%
Simplified95.3%
Final simplification75.2%
(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 31.6%
*-un-lft-identity31.6%
*-commutative31.6%
log-prod31.6%
+-commutative31.6%
hypot-1-def46.6%
add-sqr-sqrt7.1%
fabs-sqr7.1%
add-sqr-sqrt18.2%
metadata-eval18.2%
Applied egg-rr18.2%
+-rgt-identity18.2%
Simplified18.2%
Taylor expanded in x around 0 69.3%
if 5 < x Initial program 59.9%
Taylor expanded in x around inf 43.4%
mul-1-neg43.4%
log-rec43.4%
remove-double-neg43.4%
Simplified43.4%
Final simplification63.6%
(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.8%
*-un-lft-identity37.8%
*-commutative37.8%
log-prod37.8%
+-commutative37.8%
hypot-1-def58.3%
add-sqr-sqrt27.4%
fabs-sqr27.4%
add-sqr-sqrt36.1%
metadata-eval36.1%
Applied egg-rr36.1%
+-rgt-identity36.1%
Simplified36.1%
Taylor expanded in x around 0 56.8%
Final simplification56.8%
(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 2023321
(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))