
(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 (or (<= t_0 -0.20000000298023224) (not (<= t_0 0.20000000298023224)))
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)
(copysign
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* 0.075 (pow x 5.0)) (+ x (* -0.044642857142857144 (pow x 7.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) || !(t_0 <= 0.20000000298023224f)) {
tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
} else {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + ((0.075f * powf(x, 5.0f)) + (x + (-0.044642857142857144f * powf(x, 7.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)) || !(t_0 <= Float32(0.20000000298023224))) tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); else tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(Float32(0.075) * (x ^ Float32(5.0))) + Float32(x + Float32(Float32(-0.044642857142857144) * (x ^ Float32(7.0)))))), 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)) || ~((t_0 <= single(0.20000000298023224)))) tmp = sign(x) * abs(log((abs(x) + hypot(single(1.0), x)))); else tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + ((single(0.075) * (x ^ single(5.0))) + (x + (single(-0.044642857142857144) * (x ^ single(7.0))))))); 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 \lor \neg \left(t_0 \leq 0.20000000298023224\right):\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(0.075 \cdot {x}^{5} + \left(x + -0.044642857142857144 \cdot {x}^{7}\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.200000003 or 0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 60.0%
+-commutative60.0%
hypot-1-def99.3%
Simplified99.3%
if -0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 22.9%
*-un-lft-identity22.9%
*-commutative22.9%
log-prod22.9%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt23.5%
+-commutative23.5%
hypot-1-def23.6%
metadata-eval23.6%
Applied egg-rr23.6%
+-rgt-identity23.6%
Simplified23.6%
Taylor expanded in x around 0 100.0%
Final simplification99.6%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (or (<= t_0 -0.10000000149011612) (not (<= t_0 0.20000000298023224)))
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.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.10000000149011612f) || !(t_0 <= 0.20000000298023224f)) {
tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
} else {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.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.10000000149011612)) || !(t_0 <= Float32(0.20000000298023224))) tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); else tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(x + Float32(Float32(0.075) * (x ^ Float32(5.0))))), 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.10000000149011612)) || ~((t_0 <= single(0.20000000298023224)))) tmp = sign(x) * abs(log((abs(x) + hypot(single(1.0), x)))); else tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + (x + (single(0.075) * (x ^ single(5.0)))))); 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.10000000149011612 \lor \neg \left(t_0 \leq 0.20000000298023224\right):\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\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.100000001 or 0.200000003 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 60.5%
+-commutative60.5%
hypot-1-def99.3%
Simplified99.3%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 21.6%
*-un-lft-identity21.6%
*-commutative21.6%
log-prod21.6%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt22.3%
+-commutative22.3%
hypot-1-def22.4%
metadata-eval22.4%
Applied egg-rr22.4%
+-rgt-identity22.4%
Simplified22.4%
Taylor expanded in x around 0 100.0%
Final simplification99.6%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (log (/ 1.0 (- (hypot 1.0 x) x))) x)
(if (<= x 0.20000000298023224)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -0.10000000149011612f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, x) - x))), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-0.10000000149011612)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), x) - x))), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(x + Float32(Float32(0.075) * (x ^ Float32(5.0))))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-0.10000000149011612)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), x) - x)))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs(((single(-0.16666666666666666) * (x ^ single(3.0))) + (x + (single(0.075) * (x ^ single(5.0)))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, x\right) - x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -0.100000001Initial program 58.6%
*-un-lft-identity58.6%
*-commutative58.6%
log-prod58.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.8%
+-commutative15.8%
hypot-1-def15.8%
metadata-eval15.8%
Applied egg-rr15.8%
+-rgt-identity15.8%
Simplified15.8%
flip-+15.4%
div-sub13.0%
hypot-udef13.0%
hypot-udef13.0%
add-sqr-sqrt13.5%
metadata-eval13.5%
+-commutative13.5%
Applied egg-rr13.5%
div-sub17.2%
associate--r+55.7%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
+-inverses55.7%
associate--r+17.2%
associate-/r*17.2%
neg-mul-117.2%
associate--r+55.7%
+-inverses99.8%
metadata-eval99.8%
neg-mul-199.8%
metadata-eval99.8%
neg-sub099.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
if -0.100000001 < x < 0.200000003Initial program 21.6%
*-un-lft-identity21.6%
*-commutative21.6%
log-prod21.6%
add-sqr-sqrt9.3%
fabs-sqr9.3%
add-sqr-sqrt22.3%
+-commutative22.3%
hypot-1-def22.4%
metadata-eval22.4%
Applied egg-rr22.4%
+-rgt-identity22.4%
Simplified22.4%
Taylor expanded in x around 0 100.0%
if 0.200000003 < x Initial program 62.3%
*-un-lft-identity62.3%
*-commutative62.3%
log-prod62.3%
add-sqr-sqrt62.3%
fabs-sqr62.3%
add-sqr-sqrt62.3%
+-commutative62.3%
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 -20.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 <= -20.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(-20.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(-20.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 -20:\\
\;\;\;\;\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 < -20Initial program 56.8%
Taylor expanded in x around -inf 98.9%
neg-mul-198.9%
unsub-neg98.9%
Simplified98.9%
if -20 < x < 0.0500000007Initial program 22.9%
*-un-lft-identity22.9%
*-commutative22.9%
log-prod22.9%
add-sqr-sqrt8.3%
fabs-sqr8.3%
add-sqr-sqrt23.5%
+-commutative23.5%
hypot-1-def23.7%
metadata-eval23.7%
Applied egg-rr23.7%
+-rgt-identity23.7%
Simplified23.7%
Taylor expanded in x around 0 99.2%
if 0.0500000007 < x Initial program 62.8%
*-un-lft-identity62.8%
*-commutative62.8%
log-prod62.8%
add-sqr-sqrt62.8%
fabs-sqr62.8%
add-sqr-sqrt62.8%
+-commutative62.8%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (log (/ 1.0 (- (hypot 1.0 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 <= -0.10000000149011612f) {
tmp = copysignf(logf((1.0f / (hypotf(1.0f, 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(-0.10000000149011612)) tmp = copysign(log(Float32(Float32(1.0) / Float32(hypot(Float32(1.0), 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(-0.10000000149011612)) tmp = sign(x) * abs(log((single(1.0) / (hypot(single(1.0), 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 -0.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{1}{\mathsf{hypot}\left(1, 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 < -0.100000001Initial program 58.6%
*-un-lft-identity58.6%
*-commutative58.6%
log-prod58.6%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.8%
+-commutative15.8%
hypot-1-def15.8%
metadata-eval15.8%
Applied egg-rr15.8%
+-rgt-identity15.8%
Simplified15.8%
flip-+15.4%
div-sub13.0%
hypot-udef13.0%
hypot-udef13.0%
add-sqr-sqrt13.5%
metadata-eval13.5%
+-commutative13.5%
Applied egg-rr13.5%
div-sub17.2%
associate--r+55.7%
+-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
+-inverses55.7%
associate--r+17.2%
associate-/r*17.2%
neg-mul-117.2%
associate--r+55.7%
+-inverses99.8%
metadata-eval99.8%
neg-mul-199.8%
metadata-eval99.8%
neg-sub099.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
if -0.100000001 < x < 0.0500000007Initial program 21.0%
*-un-lft-identity21.0%
*-commutative21.0%
log-prod21.0%
add-sqr-sqrt8.5%
fabs-sqr8.5%
add-sqr-sqrt21.7%
+-commutative21.7%
hypot-1-def21.8%
metadata-eval21.8%
Applied egg-rr21.8%
+-rgt-identity21.8%
Simplified21.8%
Taylor expanded in x around 0 99.9%
if 0.0500000007 < x Initial program 62.8%
*-un-lft-identity62.8%
*-commutative62.8%
log-prod62.8%
add-sqr-sqrt62.8%
fabs-sqr62.8%
add-sqr-sqrt62.8%
+-commutative62.8%
hypot-1-def98.7%
metadata-eval98.7%
Applied egg-rr98.7%
+-rgt-identity98.7%
Simplified98.7%
Final simplification99.5%
(FPCore (x)
:precision binary32
(if (<= x -20.0)
(copysign (log (- (fabs x) x)) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(logf((fabsf(x) - x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-20.0)) tmp = copysign(log(Float32(abs(x) - x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + Float32(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-20.0)) tmp = sign(x) * abs(log((abs(x) - x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| - x\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -20Initial program 56.8%
Taylor expanded in x around -inf 98.9%
neg-mul-198.9%
unsub-neg98.9%
Simplified98.9%
if -20 < x < 0.200000003Initial program 23.5%
*-un-lft-identity23.5%
*-commutative23.5%
log-prod23.5%
add-sqr-sqrt9.0%
fabs-sqr9.0%
add-sqr-sqrt24.1%
+-commutative24.1%
hypot-1-def24.3%
metadata-eval24.3%
Applied egg-rr24.3%
+-rgt-identity24.3%
Simplified24.3%
Taylor expanded in x around 0 99.0%
if 0.200000003 < x Initial program 62.3%
Taylor expanded in x around inf 97.8%
+-commutative97.8%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.8%
associate-*r/97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification98.6%
(FPCore (x)
:precision binary32
(if (<= x -20.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.20000000298023224)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (/ 0.5 x) (+ x x))) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.20000000298023224f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-20.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + Float32(x + x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-20.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.20000000298023224)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -20Initial program 56.8%
*-un-lft-identity56.8%
*-commutative56.8%
log-prod56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
+-commutative12.2%
hypot-1-def12.2%
metadata-eval12.2%
Applied egg-rr12.2%
+-rgt-identity12.2%
Simplified12.2%
Taylor expanded in x around -inf 98.8%
if -20 < x < 0.200000003Initial program 23.5%
*-un-lft-identity23.5%
*-commutative23.5%
log-prod23.5%
add-sqr-sqrt9.0%
fabs-sqr9.0%
add-sqr-sqrt24.1%
+-commutative24.1%
hypot-1-def24.3%
metadata-eval24.3%
Applied egg-rr24.3%
+-rgt-identity24.3%
Simplified24.3%
Taylor expanded in x around 0 99.0%
if 0.200000003 < x Initial program 62.3%
Taylor expanded in x around inf 97.8%
+-commutative97.8%
rem-square-sqrt97.8%
fabs-sqr97.8%
rem-square-sqrt97.8%
associate-*r/97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification98.6%
(FPCore (x)
:precision binary32
(if (<= x -20.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-20.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-20.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -20Initial program 56.8%
*-un-lft-identity56.8%
*-commutative56.8%
log-prod56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
+-commutative12.2%
hypot-1-def12.2%
metadata-eval12.2%
Applied egg-rr12.2%
+-rgt-identity12.2%
Simplified12.2%
Taylor expanded in x around -inf 98.8%
if -20 < x < 1Initial program 24.1%
*-un-lft-identity24.1%
*-commutative24.1%
log-prod24.1%
add-sqr-sqrt9.8%
fabs-sqr9.8%
add-sqr-sqrt24.7%
+-commutative24.7%
hypot-1-def24.9%
metadata-eval24.9%
Applied egg-rr24.9%
+-rgt-identity24.9%
Simplified24.9%
Taylor expanded in x around 0 98.5%
if 1 < x Initial program 61.8%
Taylor expanded in x around inf 98.0%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.0%
Simplified98.0%
Final simplification98.4%
(FPCore (x) :precision binary32 (if (<= x -20.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -20.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-20.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-20.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -20:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -20Initial program 56.8%
*-un-lft-identity56.8%
*-commutative56.8%
log-prod56.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.2%
+-commutative12.2%
hypot-1-def12.2%
metadata-eval12.2%
Applied egg-rr12.2%
+-rgt-identity12.2%
Simplified12.2%
Taylor expanded in x around -inf 98.8%
if -20 < x < 1Initial program 24.1%
Taylor expanded in x around 0 20.0%
rem-square-sqrt8.2%
fabs-sqr8.2%
rem-square-sqrt20.6%
Simplified20.6%
Taylor expanded in x around 0 96.7%
if 1 < x Initial program 61.8%
Taylor expanded in x around inf 98.0%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.0%
Simplified98.0%
Final simplification97.6%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x + x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(1.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 35.6%
Taylor expanded in x around 0 28.5%
rem-square-sqrt5.3%
fabs-sqr5.3%
rem-square-sqrt13.3%
Simplified13.3%
Taylor expanded in x around 0 66.7%
if 1 < x Initial program 61.8%
Taylor expanded in x around inf 98.0%
rem-square-sqrt98.0%
fabs-sqr98.0%
rem-square-sqrt98.0%
Simplified98.0%
Final simplification75.3%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) tmp = copysign(x, x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 35.6%
Taylor expanded in x around 0 28.5%
rem-square-sqrt5.3%
fabs-sqr5.3%
rem-square-sqrt13.3%
Simplified13.3%
Taylor expanded in x around 0 66.7%
if 1 < x Initial program 61.8%
Taylor expanded in x around 0 43.8%
log1p-def43.8%
rem-square-sqrt43.8%
fabs-sqr43.8%
rem-square-sqrt43.8%
Simplified43.8%
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 42.9%
Taylor expanded in x around 0 32.8%
rem-square-sqrt16.0%
fabs-sqr16.0%
rem-square-sqrt21.8%
Simplified21.8%
Taylor expanded in x around 0 51.4%
Final simplification51.4%
(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 2023200
(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))