
(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.4000000059604645)
(copysign
(+
(* -0.16666666666666666 (pow x 3.0))
(+ (* 0.075 (pow x 5.0)) (+ x (* -0.044642857142857144 (pow x 7.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.4000000059604645f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + ((0.075f * powf(x, 5.0f)) + (x + (-0.044642857142857144f * powf(x, 7.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.4000000059604645)) 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); 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.4000000059604645)) 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))))))); 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.4000000059604645:\\
\;\;\;\;\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)\\
\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 50.3%
+-commutative50.3%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt11.9%
flip-+8.4%
log-div8.4%
add-sqr-sqrt8.8%
fma-def9.7%
+-commutative9.7%
hypot-1-def9.7%
Applied egg-rr9.7%
fma-udef8.8%
+-commutative8.8%
associate--l+46.9%
+-inverses97.1%
metadata-eval97.1%
metadata-eval97.1%
neg-sub097.1%
Simplified97.1%
if -0.5 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.400000006Initial program 23.8%
+-commutative23.8%
add-sqr-sqrt10.1%
fabs-sqr10.1%
add-sqr-sqrt24.3%
flip-+23.6%
add-sqr-sqrt23.7%
fma-def23.7%
+-commutative23.7%
hypot-1-def23.7%
Applied egg-rr23.7%
fma-udef23.7%
+-commutative23.7%
associate--l+23.9%
+-inverses23.9%
metadata-eval23.9%
Simplified23.9%
Taylor expanded in x around 0 99.9%
if 0.400000006 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 63.6%
*-un-lft-identity63.6%
*-commutative63.6%
log-prod63.6%
add-sqr-sqrt63.5%
fabs-sqr63.5%
add-sqr-sqrt63.6%
+-commutative63.6%
hypot-1-def98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
Final simplification98.8%
(FPCore (x)
:precision binary32
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 -0.15000000596046448)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= t_0 0.10000000149011612)
(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 t_0 = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
float tmp;
if (t_0 <= -0.15000000596046448f) {
tmp = copysignf(-logf((hypotf(1.0f, x) - x)), x);
} else if (t_0 <= 0.10000000149011612f) {
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) 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.15000000596046448)) tmp = copysign(Float32(-log(Float32(hypot(Float32(1.0), x) - x))), x); elseif (t_0 <= Float32(0.10000000149011612)) 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) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); tmp = single(0.0); if (t_0 <= single(-0.15000000596046448)) tmp = sign(x) * abs(-log((hypot(single(1.0), x) - x))); elseif (t_0 <= single(0.10000000149011612)) 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}
t_0 := \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{if}\;t_0 \leq -0.15000000596046448:\\
\;\;\;\;\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(-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 (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < -0.150000006Initial program 50.9%
+-commutative50.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.2%
flip-+9.7%
log-div9.8%
add-sqr-sqrt10.1%
fma-def10.9%
+-commutative10.9%
hypot-1-def11.0%
Applied egg-rr11.0%
fma-udef10.1%
+-commutative10.1%
associate--l+47.6%
+-inverses97.0%
metadata-eval97.0%
metadata-eval97.0%
neg-sub097.0%
Simplified97.0%
if -0.150000006 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 22.7%
+-commutative22.7%
add-sqr-sqrt9.5%
fabs-sqr9.5%
add-sqr-sqrt23.1%
flip-+22.4%
add-sqr-sqrt22.6%
fma-def22.6%
+-commutative22.6%
hypot-1-def22.5%
Applied egg-rr22.5%
fma-udef22.5%
+-commutative22.5%
associate--l+22.8%
+-inverses22.8%
metadata-eval22.8%
Simplified22.8%
Taylor expanded in x around 0 99.9%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 64.0%
*-un-lft-identity64.0%
*-commutative64.0%
log-prod64.0%
add-sqr-sqrt64.0%
fabs-sqr64.0%
add-sqr-sqrt64.0%
+-commutative64.0%
hypot-1-def98.4%
metadata-eval98.4%
Applied egg-rr98.4%
+-rgt-identity98.4%
Simplified98.4%
Final simplification98.8%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.10000000149011612)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x + hypotf(1.0f, x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.10000000149011612)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x + hypot(Float32(1.0), x))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.10000000149011612)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x + hypot(single(1.0), x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.10000000149011612:\\
\;\;\;\;\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 49.5%
+-commutative49.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.6%
flip-+7.1%
add-sqr-sqrt7.3%
fma-def8.3%
+-commutative8.3%
hypot-1-def8.3%
Applied egg-rr8.3%
fma-udef7.3%
+-commutative7.3%
associate--l+46.0%
+-inverses96.9%
metadata-eval96.9%
Simplified96.9%
Taylor expanded in x around -inf 97.4%
if -1 < x < 0.100000001Initial program 23.8%
+-commutative23.8%
add-sqr-sqrt9.4%
fabs-sqr9.4%
add-sqr-sqrt24.3%
flip-+23.6%
add-sqr-sqrt23.8%
fma-def23.8%
+-commutative23.8%
hypot-1-def23.7%
Applied egg-rr23.7%
fma-udef23.7%
+-commutative23.7%
associate--l+24.0%
+-inverses24.0%
metadata-eval24.0%
Simplified24.0%
Taylor expanded in x around 0 98.9%
if 0.100000001 < x Initial program 64.0%
*-un-lft-identity64.0%
*-commutative64.0%
log-prod64.0%
add-sqr-sqrt64.0%
fabs-sqr64.0%
add-sqr-sqrt64.0%
+-commutative64.0%
hypot-1-def98.4%
metadata-eval98.4%
Applied egg-rr98.4%
+-rgt-identity98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x)
:precision binary32
(if (<= x -0.10000000149011612)
(copysign (- (log (- (hypot 1.0 x) x))) x)
(if (<= x 0.10000000149011612)
(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.10000000149011612f) {
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.10000000149011612)) 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.10000000149011612)) 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.10000000149011612:\\
\;\;\;\;\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 52.1%
+-commutative52.1%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt15.4%
flip-+12.1%
log-div12.2%
add-sqr-sqrt12.5%
fma-def13.3%
+-commutative13.3%
hypot-1-def13.4%
Applied egg-rr13.4%
fma-udef12.5%
+-commutative12.5%
associate--l+48.9%
+-inverses96.9%
metadata-eval96.9%
metadata-eval96.9%
neg-sub096.9%
Simplified96.9%
if -0.100000001 < x < 0.100000001Initial program 21.5%
+-commutative21.5%
add-sqr-sqrt9.7%
fabs-sqr9.7%
add-sqr-sqrt22.0%
flip-+21.3%
add-sqr-sqrt21.5%
fma-def21.5%
+-commutative21.5%
hypot-1-def21.4%
Applied egg-rr21.4%
fma-udef21.4%
+-commutative21.4%
associate--l+21.7%
+-inverses21.7%
metadata-eval21.7%
Simplified21.7%
Taylor expanded in x around 0 99.9%
if 0.100000001 < x Initial program 64.0%
*-un-lft-identity64.0%
*-commutative64.0%
log-prod64.0%
add-sqr-sqrt64.0%
fabs-sqr64.0%
add-sqr-sqrt64.0%
+-commutative64.0%
hypot-1-def98.4%
metadata-eval98.4%
Applied egg-rr98.4%
+-rgt-identity98.4%
Simplified98.4%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(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 <= -1.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(((0.5f / x) + (x + x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) 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(-1.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(((single(0.5) / x) + (x + x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\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 < -1Initial program 49.5%
+-commutative49.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.6%
flip-+7.1%
add-sqr-sqrt7.3%
fma-def8.3%
+-commutative8.3%
hypot-1-def8.3%
Applied egg-rr8.3%
fma-udef7.3%
+-commutative7.3%
associate--l+46.0%
+-inverses96.9%
metadata-eval96.9%
Simplified96.9%
Taylor expanded in x around -inf 97.4%
if -1 < x < 1Initial program 26.1%
+-commutative26.1%
add-sqr-sqrt12.1%
fabs-sqr12.1%
add-sqr-sqrt26.5%
flip-+25.8%
add-sqr-sqrt26.0%
fma-def26.0%
+-commutative26.0%
hypot-1-def25.9%
Applied egg-rr25.9%
fma-udef25.9%
+-commutative25.9%
associate--l+26.2%
+-inverses26.2%
metadata-eval26.2%
Simplified26.2%
Taylor expanded in x around 0 97.4%
if 1 < x Initial program 62.0%
Taylor expanded in x around inf 96.5%
associate-*r/96.5%
metadata-eval96.5%
rem-square-sqrt96.5%
fabs-sqr96.5%
rem-square-sqrt96.5%
Simplified96.5%
Final simplification97.2%
(FPCore (x)
:precision binary32
(if (<= x -1.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 <= -1.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(-1.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(-1.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 -1:\\
\;\;\;\;\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 < -1Initial program 49.5%
+-commutative49.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.6%
flip-+7.1%
add-sqr-sqrt7.3%
fma-def8.3%
+-commutative8.3%
hypot-1-def8.3%
Applied egg-rr8.3%
fma-udef7.3%
+-commutative7.3%
associate--l+46.0%
+-inverses96.9%
metadata-eval96.9%
Simplified96.9%
Taylor expanded in x around -inf 97.4%
if -1 < x < 2Initial program 26.7%
+-commutative26.7%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt27.1%
flip-+26.4%
add-sqr-sqrt26.6%
fma-def26.6%
+-commutative26.6%
hypot-1-def26.5%
Applied egg-rr26.5%
fma-udef26.5%
+-commutative26.5%
associate--l+26.7%
+-inverses26.7%
metadata-eval26.7%
Simplified26.7%
Taylor expanded in x around 0 96.9%
if 2 < x Initial program 61.4%
Taylor expanded in x around inf 97.3%
associate-*r/97.3%
metadata-eval97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
Simplified97.3%
Taylor expanded in x around 0 96.7%
Final simplification97.0%
(FPCore (x) :precision binary32 (if (<= x -1.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 <= -1.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(-1.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(-1.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 -1:\\
\;\;\;\;\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 < -1Initial program 49.5%
+-commutative49.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.6%
flip-+7.1%
add-sqr-sqrt7.3%
fma-def8.3%
+-commutative8.3%
hypot-1-def8.3%
Applied egg-rr8.3%
fma-udef7.3%
+-commutative7.3%
associate--l+46.0%
+-inverses96.9%
metadata-eval96.9%
Simplified96.9%
Taylor expanded in x around -inf 97.4%
if -1 < x < 2Initial program 26.7%
+-commutative26.7%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt27.1%
flip-+26.4%
add-sqr-sqrt26.6%
fma-def26.6%
+-commutative26.6%
hypot-1-def26.5%
Applied egg-rr26.5%
fma-udef26.5%
+-commutative26.5%
associate--l+26.7%
+-inverses26.7%
metadata-eval26.7%
Simplified26.7%
Taylor expanded in x around 0 94.9%
if 2 < x Initial program 61.4%
Taylor expanded in x around inf 95.3%
rem-square-sqrt95.3%
fabs-sqr95.3%
rem-square-sqrt95.3%
Simplified95.3%
Final simplification95.6%
(FPCore (x) :precision binary32 (if (<= x -1.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 <= -1.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(-1.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(-1.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 -1:\\
\;\;\;\;\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 < -1Initial program 49.5%
+-commutative49.5%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.6%
flip-+7.1%
add-sqr-sqrt7.3%
fma-def8.3%
+-commutative8.3%
hypot-1-def8.3%
Applied egg-rr8.3%
fma-udef7.3%
+-commutative7.3%
associate--l+46.0%
+-inverses96.9%
metadata-eval96.9%
Simplified96.9%
Taylor expanded in x around -inf 97.4%
if -1 < x < 2Initial program 26.7%
+-commutative26.7%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt27.1%
flip-+26.4%
add-sqr-sqrt26.6%
fma-def26.6%
+-commutative26.6%
hypot-1-def26.5%
Applied egg-rr26.5%
fma-udef26.5%
+-commutative26.5%
associate--l+26.7%
+-inverses26.7%
metadata-eval26.7%
Simplified26.7%
Taylor expanded in x around 0 94.9%
if 2 < x Initial program 61.4%
Taylor expanded in x around inf 97.3%
associate-*r/97.3%
metadata-eval97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
Simplified97.3%
Taylor expanded in x around 0 96.7%
Final simplification96.0%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log (+ x x)) x)))
float code(float x) {
float tmp;
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(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(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(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < 2Initial program 34.1%
+-commutative34.1%
add-sqr-sqrt8.6%
fabs-sqr8.6%
add-sqr-sqrt21.7%
flip-+20.1%
add-sqr-sqrt20.3%
fma-def20.6%
+-commutative20.6%
hypot-1-def20.5%
Applied egg-rr20.5%
fma-udef20.2%
+-commutative20.2%
associate--l+33.0%
+-inverses49.6%
metadata-eval49.6%
Simplified49.6%
Taylor expanded in x around 0 67.6%
if 2 < x Initial program 61.4%
Taylor expanded in x around inf 95.3%
rem-square-sqrt95.3%
fabs-sqr95.3%
rem-square-sqrt95.3%
Simplified95.3%
Final simplification74.4%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log 0.125) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(0.125f), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(0.125)), 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(\log 0.125, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.5%
Taylor expanded in x around inf -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%
clear-num-0.0%
flip-+-0.0%
frac-add-0.0%
*-un-lft-identity-0.0%
+-inverses-0.0%
+-inverses-0.0%
+-inverses-0.0%
div-inv-0.0%
metadata-eval-0.0%
*-commutative-0.0%
count-2-0.0%
difference-of-squares-0.0%
+-inverses-0.0%
metadata-eval-0.0%
metadata-eval-0.0%
+-inverses-0.0%
div-inv-0.0%
metadata-eval-0.0%
*-commutative-0.0%
count-2-0.0%
difference-of-squares-0.0%
+-inverses-0.0%
metadata-eval-0.0%
+-inverses-0.0%
Applied egg-rr4.0%
Simplified22.2%
if -1 < x Initial program 38.0%
Taylor expanded in x around 0 28.1%
log1p-def75.2%
rem-square-sqrt39.9%
fabs-sqr39.9%
rem-square-sqrt75.1%
Simplified75.1%
Final simplification62.1%
(FPCore (x) :precision binary32 (copysign 0.8333333333333334 x))
float code(float x) {
return copysignf(0.8333333333333334f, x);
}
function code(x) return copysign(Float32(0.8333333333333334), x) end
function tmp = code(x) tmp = sign(x) * abs(single(0.8333333333333334)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(0.8333333333333334, x\right)
\end{array}
Initial program 40.8%
+-commutative40.8%
add-sqr-sqrt21.6%
fabs-sqr21.6%
add-sqr-sqrt31.5%
flip-+17.7%
add-sqr-sqrt17.8%
fma-def18.0%
+-commutative18.0%
hypot-1-def18.0%
Applied egg-rr18.0%
fma-udef17.7%
+-commutative17.7%
associate--l+28.1%
+-inverses41.3%
metadata-eval41.3%
Simplified41.3%
Taylor expanded in x around 0 53.4%
Simplified16.1%
Final simplification16.1%
(FPCore (x) :precision binary32 (copysign 1.09375 x))
float code(float x) {
return copysignf(1.09375f, x);
}
function code(x) return copysign(Float32(1.09375), x) end
function tmp = code(x) tmp = sign(x) * abs(single(1.09375)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(1.09375, x\right)
\end{array}
Initial program 40.8%
+-commutative40.8%
add-sqr-sqrt21.6%
fabs-sqr21.6%
add-sqr-sqrt31.5%
flip-+17.7%
add-sqr-sqrt17.8%
fma-def18.0%
+-commutative18.0%
hypot-1-def18.0%
Applied egg-rr18.0%
fma-udef17.7%
+-commutative17.7%
associate--l+28.1%
+-inverses41.3%
metadata-eval41.3%
Simplified41.3%
Taylor expanded in x around -inf 25.3%
Simplified16.3%
Final simplification16.3%
(FPCore (x) :precision binary32 (copysign 1.9583333333333333 x))
float code(float x) {
return copysignf(1.9583333333333333f, x);
}
function code(x) return copysign(Float32(1.9583333333333333), x) end
function tmp = code(x) tmp = sign(x) * abs(single(1.9583333333333333)); end
\begin{array}{l}
\\
\mathsf{copysign}\left(1.9583333333333333, x\right)
\end{array}
Initial program 40.8%
+-commutative40.8%
add-sqr-sqrt21.6%
fabs-sqr21.6%
add-sqr-sqrt31.5%
flip-+17.7%
add-sqr-sqrt17.8%
fma-def18.0%
+-commutative18.0%
hypot-1-def18.0%
Applied egg-rr18.0%
fma-udef17.7%
+-commutative17.7%
associate--l+28.1%
+-inverses41.3%
metadata-eval41.3%
Simplified41.3%
Taylor expanded in x around inf 25.3%
Simplified16.7%
Final simplification16.7%
(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 40.8%
+-commutative40.8%
add-sqr-sqrt21.6%
fabs-sqr21.6%
add-sqr-sqrt31.5%
flip-+17.7%
add-sqr-sqrt17.8%
fma-def18.0%
+-commutative18.0%
hypot-1-def18.0%
Applied egg-rr18.0%
fma-udef17.7%
+-commutative17.7%
associate--l+28.1%
+-inverses41.3%
metadata-eval41.3%
Simplified41.3%
Taylor expanded in x around 0 54.0%
Final simplification54.0%
(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 2023193
(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))