
(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 14 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 (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.20000000298023224)
(copysign
(+
x
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* -0.044642857142857144 (pow x 7.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.5f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.20000000298023224f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + ((-0.044642857142857144f * powf(x, 7.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.5)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.20000000298023224)) tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(Float32(-0.044642857142857144) * (x ^ Float32(7.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.5)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.20000000298023224)) tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + ((single(-0.044642857142857144) * (x ^ single(7.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.5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\right), x\right)\\
\mathbf{elif}\;t_0 \leq 0.20000000298023224:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + \left(-0.044642857142857144 \cdot {x}^{7} + 0.075 \cdot {x}^{5}\right)\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 63.3%
+-commutative63.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.4%
flip-+11.3%
log-div11.3%
add-sqr-sqrt12.8%
fma-def13.2%
+-commutative13.2%
hypot-1-def13.2%
Applied egg-rr13.2%
fma-udef12.8%
+-commutative12.8%
associate--l+60.8%
+-inverses98.7%
metadata-eval98.7%
metadata-eval98.7%
neg-sub098.7%
Simplified98.7%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.200000003Initial program 24.6%
+-commutative24.6%
add-sqr-sqrt12.8%
fabs-sqr12.8%
add-sqr-sqrt24.7%
flip-+24.5%
add-sqr-sqrt24.6%
fma-def24.6%
+-commutative24.6%
hypot-1-def24.7%
Applied egg-rr24.7%
fma-udef24.7%
+-commutative24.7%
associate--l+24.7%
+-inverses24.7%
metadata-eval24.7%
Simplified24.7%
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 50.7%
*-un-lft-identity50.7%
*-commutative50.7%
log-prod50.7%
add-sqr-sqrt50.7%
fabs-sqr50.7%
add-sqr-sqrt50.7%
+-commutative50.7%
hypot-1-def98.3%
metadata-eval98.3%
Applied egg-rr98.3%
+-rgt-identity98.3%
Simplified98.3%
Final simplification99.2%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) 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.10000000149011612f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - 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.10000000149011612)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - 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.10000000149011612)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - 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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\mathsf{hypot}\left(1, x\right) - x\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.100000001Initial program 63.8%
+-commutative63.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.5%
flip-+12.3%
log-div12.4%
add-sqr-sqrt13.9%
fma-def14.2%
+-commutative14.2%
hypot-1-def14.2%
Applied egg-rr14.2%
fma-udef13.9%
+-commutative13.9%
associate--l+61.3%
+-inverses98.7%
metadata-eval98.7%
metadata-eval98.7%
neg-sub098.7%
Simplified98.7%
if -0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 23.4%
+-commutative23.4%
add-sqr-sqrt12.3%
fabs-sqr12.3%
add-sqr-sqrt23.5%
flip-+23.4%
add-sqr-sqrt23.4%
fma-def23.4%
+-commutative23.4%
hypot-1-def23.5%
Applied egg-rr23.5%
fma-udef23.5%
+-commutative23.5%
associate--l+23.5%
+-inverses23.5%
metadata-eval23.5%
Simplified23.5%
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 51.4%
*-un-lft-identity51.4%
*-commutative51.4%
log-prod51.4%
add-sqr-sqrt51.4%
fabs-sqr51.4%
add-sqr-sqrt51.4%
+-commutative51.4%
hypot-1-def98.3%
metadata-eval98.3%
Applied egg-rr98.3%
+-rgt-identity98.3%
Simplified98.3%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (+ (* x -2.0) (* 0.5 (/ -1.0 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(((x * -2.0f) + (0.5f * (-1.0f / 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(Float32(-log(Float32(Float32(x * Float32(-2.0)) + Float32(Float32(0.5) * Float32(Float32(-1.0) / 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(((x * single(-2.0)) + (single(0.5) * (single(-1.0) / 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(x \cdot -2 + 0.5 \cdot \frac{-1}{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 62.8%
+-commutative62.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.3%
flip-+10.1%
log-div10.1%
add-sqr-sqrt11.6%
fma-def12.0%
+-commutative12.0%
hypot-1-def12.0%
Applied egg-rr12.0%
fma-udef11.6%
+-commutative11.6%
associate--l+60.3%
+-inverses98.7%
metadata-eval98.7%
metadata-eval98.7%
neg-sub098.7%
Simplified98.7%
Taylor expanded in x around -inf 97.9%
if -2 < x < 0.0500000007Initial program 24.0%
+-commutative24.0%
add-sqr-sqrt11.4%
fabs-sqr11.4%
add-sqr-sqrt24.1%
flip-+24.0%
add-sqr-sqrt24.1%
fma-def24.1%
+-commutative24.1%
hypot-1-def24.2%
Applied egg-rr24.2%
fma-udef24.2%
+-commutative24.2%
associate--l+24.1%
+-inverses24.1%
metadata-eval24.1%
Simplified24.1%
Taylor expanded in x around 0 99.3%
if 0.0500000007 < x Initial program 52.2%
*-un-lft-identity52.2%
*-commutative52.2%
log-prod52.2%
add-sqr-sqrt52.2%
fabs-sqr52.2%
add-sqr-sqrt52.2%
+-commutative52.2%
hypot-1-def98.2%
metadata-eval98.2%
Applied egg-rr98.2%
+-rgt-identity98.2%
Simplified98.2%
Final simplification98.6%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (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((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(Float32(-log(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((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(\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 63.8%
+-commutative63.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt14.5%
flip-+12.3%
log-div12.4%
add-sqr-sqrt13.9%
fma-def14.2%
+-commutative14.2%
hypot-1-def14.2%
Applied egg-rr14.2%
fma-udef13.9%
+-commutative13.9%
associate--l+61.3%
+-inverses98.7%
metadata-eval98.7%
metadata-eval98.7%
neg-sub098.7%
Simplified98.7%
if -0.100000001 < x < 0.0500000007Initial program 22.8%
+-commutative22.8%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt22.9%
flip-+22.9%
add-sqr-sqrt22.8%
fma-def22.8%
+-commutative22.8%
hypot-1-def22.9%
Applied egg-rr22.9%
fma-udef22.9%
+-commutative22.9%
associate--l+22.9%
+-inverses22.9%
metadata-eval22.9%
Simplified22.9%
Taylor expanded in x around 0 99.9%
if 0.0500000007 < x Initial program 52.2%
*-un-lft-identity52.2%
*-commutative52.2%
log-prod52.2%
add-sqr-sqrt52.2%
fabs-sqr52.2%
add-sqr-sqrt52.2%
+-commutative52.2%
hypot-1-def98.2%
metadata-eval98.2%
Applied egg-rr98.2%
+-rgt-identity98.2%
Simplified98.2%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (- (log (+ (* x -2.0) (* 0.5 (/ -1.0 x))))) x)
(if (<= x 0.5)
(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 <= -2.0f) {
tmp = copysignf(-logf(((x * -2.0f) + (0.5f * (-1.0f / x)))), x);
} else if (x <= 0.5f) {
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(-2.0)) tmp = copysign(Float32(-log(Float32(Float32(x * Float32(-2.0)) + Float32(Float32(0.5) * Float32(Float32(-1.0) / x))))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(Float32(0.5) / x) + Float32(x + 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(((x * single(-2.0)) + (single(0.5) * (single(-1.0) / x))))); elseif (x <= single(0.5)) 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 -2:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2 + 0.5 \cdot \frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + x\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 62.8%
+-commutative62.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.3%
flip-+10.1%
log-div10.1%
add-sqr-sqrt11.6%
fma-def12.0%
+-commutative12.0%
hypot-1-def12.0%
Applied egg-rr12.0%
fma-udef11.6%
+-commutative11.6%
associate--l+60.3%
+-inverses98.7%
metadata-eval98.7%
metadata-eval98.7%
neg-sub098.7%
Simplified98.7%
Taylor expanded in x around -inf 97.9%
if -2 < x < 0.5Initial program 26.3%
+-commutative26.3%
add-sqr-sqrt14.1%
fabs-sqr14.1%
add-sqr-sqrt26.4%
flip-+26.3%
add-sqr-sqrt26.3%
fma-def26.3%
+-commutative26.3%
hypot-1-def26.4%
Applied egg-rr26.4%
fma-udef26.4%
+-commutative26.4%
associate--l+26.4%
+-inverses26.4%
metadata-eval26.4%
Simplified26.4%
Taylor expanded in x around 0 98.3%
if 0.5 < x Initial program 49.0%
Taylor expanded in x around inf 97.3%
+-commutative97.3%
+-commutative97.3%
associate-+l+97.3%
associate-*r/97.3%
metadata-eval97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
Simplified97.3%
Final simplification98.0%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(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 <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf(((0.5f / x) + (x + 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(0.5)) 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(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log(((single(0.5) / x) + (x + 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 0.5:\\
\;\;\;\;\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 < -2Initial program 62.8%
+-commutative62.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.3%
flip-+10.1%
add-sqr-sqrt11.6%
fma-def12.0%
+-commutative12.0%
hypot-1-def12.0%
Applied egg-rr12.0%
fma-udef11.6%
+-commutative11.6%
associate--l+60.2%
+-inverses98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in x around -inf 97.5%
if -2 < x < 0.5Initial program 26.3%
+-commutative26.3%
add-sqr-sqrt14.1%
fabs-sqr14.1%
add-sqr-sqrt26.4%
flip-+26.3%
add-sqr-sqrt26.3%
fma-def26.3%
+-commutative26.3%
hypot-1-def26.4%
Applied egg-rr26.4%
fma-udef26.4%
+-commutative26.4%
associate--l+26.4%
+-inverses26.4%
metadata-eval26.4%
Simplified26.4%
Taylor expanded in x around 0 98.3%
if 0.5 < x Initial program 49.0%
Taylor expanded in x around inf 97.3%
+-commutative97.3%
+-commutative97.3%
associate-+l+97.3%
associate-*r/97.3%
metadata-eval97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
Simplified97.3%
Final simplification97.9%
(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 62.8%
+-commutative62.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.3%
flip-+10.1%
add-sqr-sqrt11.6%
fma-def12.0%
+-commutative12.0%
hypot-1-def12.0%
Applied egg-rr12.0%
fma-udef11.6%
+-commutative11.6%
associate--l+60.2%
+-inverses98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in x around -inf 97.5%
if -2 < x < 2Initial program 26.9%
+-commutative26.9%
add-sqr-sqrt14.7%
fabs-sqr14.7%
add-sqr-sqrt26.9%
flip-+26.8%
add-sqr-sqrt26.9%
fma-def26.9%
+-commutative26.9%
hypot-1-def27.0%
Applied egg-rr27.0%
fma-udef27.0%
+-commutative27.0%
associate--l+27.0%
+-inverses27.0%
metadata-eval27.0%
Simplified27.0%
Taylor expanded in x around 0 97.9%
if 2 < x Initial program 48.2%
Taylor expanded in x around inf 98.3%
+-commutative98.3%
+-commutative98.3%
associate-+l+98.3%
associate-*r/98.3%
metadata-eval98.3%
rem-square-sqrt98.3%
fabs-sqr98.3%
rem-square-sqrt98.3%
Simplified98.3%
Taylor expanded in x around 0 98.3%
Final simplification97.8%
(FPCore (x) :precision binary32 (if (<= x -40.0) (copysign 15.333333333333334 x) (if (<= x 2.0) (copysign x x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -40.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-40.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(2.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(-40.0)) tmp = sign(x) * abs(single(15.333333333333334)); elseif (x <= single(2.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 -40:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -40Initial program 61.2%
Taylor expanded in x around inf 6.2%
+-commutative6.2%
+-commutative6.2%
associate-+l+-0.0%
associate-*r/-0.0%
metadata-eval-0.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified28.3%
if -40 < x < 2Initial program 28.6%
+-commutative28.6%
add-sqr-sqrt14.4%
fabs-sqr14.4%
add-sqr-sqrt28.3%
flip-+28.3%
add-sqr-sqrt28.6%
fma-def28.6%
+-commutative28.6%
hypot-1-def28.7%
Applied egg-rr28.7%
fma-udef28.7%
+-commutative28.7%
associate--l+28.7%
+-inverses28.7%
metadata-eval28.7%
Simplified28.7%
Taylor expanded in x around 0 93.4%
if 2 < x Initial program 48.2%
Taylor expanded in x around inf 96.8%
rem-square-sqrt96.8%
fabs-sqr96.8%
rem-square-sqrt96.8%
Simplified96.8%
Final simplification76.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 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((x + 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(x + 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((x + 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(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 62.8%
+-commutative62.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.3%
flip-+10.1%
add-sqr-sqrt11.6%
fma-def12.0%
+-commutative12.0%
hypot-1-def12.0%
Applied egg-rr12.0%
fma-udef11.6%
+-commutative11.6%
associate--l+60.2%
+-inverses98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in x around -inf 97.5%
if -2 < x < 2Initial program 26.9%
+-commutative26.9%
add-sqr-sqrt14.7%
fabs-sqr14.7%
add-sqr-sqrt26.9%
flip-+26.8%
add-sqr-sqrt26.9%
fma-def26.9%
+-commutative26.9%
hypot-1-def27.0%
Applied egg-rr27.0%
fma-udef27.0%
+-commutative27.0%
associate--l+27.0%
+-inverses27.0%
metadata-eval27.0%
Simplified27.0%
Taylor expanded in x around 0 95.0%
if 2 < x Initial program 48.2%
Taylor expanded in x around inf 96.8%
rem-square-sqrt96.8%
fabs-sqr96.8%
rem-square-sqrt96.8%
Simplified96.8%
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 62.8%
+-commutative62.8%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.3%
flip-+10.1%
add-sqr-sqrt11.6%
fma-def12.0%
+-commutative12.0%
hypot-1-def12.0%
Applied egg-rr12.0%
fma-udef11.6%
+-commutative11.6%
associate--l+60.2%
+-inverses98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in x around -inf 97.5%
if -2 < x < 2Initial program 26.9%
+-commutative26.9%
add-sqr-sqrt14.7%
fabs-sqr14.7%
add-sqr-sqrt26.9%
flip-+26.8%
add-sqr-sqrt26.9%
fma-def26.9%
+-commutative26.9%
hypot-1-def27.0%
Applied egg-rr27.0%
fma-udef27.0%
+-commutative27.0%
associate--l+27.0%
+-inverses27.0%
metadata-eval27.0%
Simplified27.0%
Taylor expanded in x around 0 95.0%
if 2 < x Initial program 48.2%
Taylor expanded in x around inf 98.3%
+-commutative98.3%
+-commutative98.3%
associate-+l+98.3%
associate-*r/98.3%
metadata-eval98.3%
rem-square-sqrt98.3%
fabs-sqr98.3%
rem-square-sqrt98.3%
Simplified98.3%
Taylor expanded in x around 0 98.3%
Final simplification96.4%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign 15.333333333333334 x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(15.333333333333334f, x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(Float32(15.333333333333334), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 62.8%
Taylor expanded in x around inf 5.9%
+-commutative5.9%
+-commutative5.9%
associate-+l+-0.0%
associate-*r/-0.0%
metadata-eval-0.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt-0.0%
Simplified-0.0%
Taylor expanded in x around 0 -0.0%
Simplified28.2%
if -2 < x Initial program 33.4%
Taylor expanded in x around 0 28.0%
log1p-def76.5%
rem-square-sqrt45.5%
fabs-sqr45.5%
rem-square-sqrt76.4%
Simplified76.4%
Final simplification62.7%
(FPCore (x) :precision binary32 (if (<= x -40.0) (copysign 15.333333333333334 x) (if (<= x 2.0) (copysign x x) (copysign 15.333333333333334 x))))
float code(float x) {
float tmp;
if (x <= -40.0f) {
tmp = copysignf(15.333333333333334f, x);
} else if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(15.333333333333334f, x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-40.0)) tmp = copysign(Float32(15.333333333333334), x); elseif (x <= Float32(2.0)) tmp = copysign(x, x); else tmp = copysign(Float32(15.333333333333334), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-40.0)) tmp = sign(x) * abs(single(15.333333333333334)); elseif (x <= single(2.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(single(15.333333333333334)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -40:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(15.333333333333334, x\right)\\
\end{array}
\end{array}
if x < -40 or 2 < x Initial program 55.4%
Taylor expanded in x around inf 47.1%
+-commutative47.1%
+-commutative47.1%
associate-+l+43.7%
associate-*r/43.7%
metadata-eval43.7%
rem-square-sqrt43.7%
fabs-sqr43.7%
rem-square-sqrt43.7%
Simplified43.7%
Taylor expanded in x around 0 0.9%
Simplified28.0%
if -40 < x < 2Initial program 28.6%
+-commutative28.6%
add-sqr-sqrt14.4%
fabs-sqr14.4%
add-sqr-sqrt28.3%
flip-+28.3%
add-sqr-sqrt28.6%
fma-def28.6%
+-commutative28.6%
hypot-1-def28.7%
Applied egg-rr28.7%
fma-udef28.7%
+-commutative28.7%
associate--l+28.7%
+-inverses28.7%
metadata-eval28.7%
Simplified28.7%
Taylor expanded in x around 0 93.4%
Final simplification61.2%
(FPCore (x) :precision binary32 (copysign -7.0 x))
float code(float x) {
return copysignf(-7.0f, x);
}
function code(x) return copysign(Float32(-7.0), x) end
function tmp = code(x) tmp = sign(x) * abs(single(-7.0)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(-7, x\right)
\end{array}
Initial program 41.8%
Taylor expanded in x around inf 26.1%
+-commutative26.1%
+-commutative26.1%
associate-+l+24.4%
associate-*r/24.4%
metadata-eval24.4%
rem-square-sqrt24.4%
fabs-sqr24.4%
rem-square-sqrt24.4%
Simplified24.4%
Taylor expanded in x around 0 3.7%
Simplified17.8%
Final simplification17.8%
(FPCore (x) :precision binary32 (copysign 15.333333333333334 x))
float code(float x) {
return copysignf(15.333333333333334f, x);
}
function code(x) return copysign(Float32(15.333333333333334), x) end
function tmp = code(x) tmp = sign(x) * abs(single(15.333333333333334)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(15.333333333333334, x\right)
\end{array}
Initial program 41.8%
Taylor expanded in x around inf 26.1%
+-commutative26.1%
+-commutative26.1%
associate-+l+24.4%
associate-*r/24.4%
metadata-eval24.4%
rem-square-sqrt24.4%
fabs-sqr24.4%
rem-square-sqrt24.4%
Simplified24.4%
Taylor expanded in x around 0 3.3%
Simplified19.3%
Final simplification19.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 2023283
(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))