
(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.4000000059604645)
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)
(if (<= t_0 0.0005000000237487257)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) 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.4000000059604645f) {
tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
} else if (t_0 <= 0.0005000000237487257f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), 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.4000000059604645)) tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); elseif (t_0 <= Float32(0.0005000000237487257)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), 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.4000000059604645)) tmp = sign(x) * abs(log((abs(x) + hypot(single(1.0), x)))); elseif (t_0 <= single(0.0005000000237487257)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); 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.4000000059604645:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.0005000000237487257:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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.400000006Initial program 63.9%
+-commutative63.9%
hypot-1-def99.9%
Simplified99.9%
if -0.400000006 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 5.00000024e-4Initial program 20.6%
add-cbrt-cube20.6%
pow1/320.6%
log-pow20.5%
pow320.6%
log-pow20.6%
+-commutative20.6%
hypot-1-def20.6%
add-sqr-sqrt9.2%
fabs-sqr9.2%
add-sqr-sqrt20.8%
Applied egg-rr20.8%
Taylor expanded in x around 0 98.9%
+-commutative98.9%
*-commutative98.9%
fma-define99.1%
*-commutative99.1%
Simplified99.1%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
if 5.00000024e-4 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 53.1%
*-un-lft-identity53.1%
*-commutative53.1%
log-prod53.1%
+-commutative53.1%
hypot-1-def99.9%
add-sqr-sqrt99.8%
fabs-sqr99.8%
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 (* x -2.0))) x)
(if (<= x 0.0005000000237487257)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x (hypot 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.0005000000237487257f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), 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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.0005000000237487257)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), 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((x * single(-2.0)))); elseif (x <= single(0.0005000000237487257)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); 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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.0005000000237487257:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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 63.3%
add-cbrt-cube38.2%
pow1/338.0%
log-pow37.9%
pow337.9%
log-pow62.5%
+-commutative62.5%
hypot-1-def98.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
Taylor expanded in x around -inf 97.2%
associate-*r*98.3%
metadata-eval98.3%
*-un-lft-identity98.3%
clear-num98.3%
log-rec98.4%
div-inv98.4%
metadata-eval98.4%
Applied egg-rr98.4%
if -5 < x < 5.00000024e-4Initial program 21.2%
add-cbrt-cube21.2%
pow1/321.2%
log-pow21.1%
pow321.2%
log-pow21.2%
+-commutative21.2%
hypot-1-def21.2%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt21.4%
Applied egg-rr21.4%
Taylor expanded in x around 0 98.6%
+-commutative98.6%
*-commutative98.6%
fma-define98.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
Simplified99.6%
if 5.00000024e-4 < x Initial program 53.1%
*-un-lft-identity53.1%
*-commutative53.1%
log-prod53.1%
+-commutative53.1%
hypot-1-def99.9%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.4%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (log (+ (- (fabs x) x) (/ -0.5 x))) x)
(if (<= x 0.0005000000237487257)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) 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) + (-0.5f / x))), x);
} else if (x <= 0.0005000000237487257f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), 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(Float32(abs(x) - x) + Float32(Float32(-0.5) / x))), x); elseif (x <= Float32(0.0005000000237487257)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), 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) + (single(-0.5) / x)))); elseif (x <= single(0.0005000000237487257)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); 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(\left|x\right| - x\right) + \frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.0005000000237487257:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, 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 63.3%
Taylor expanded in x around -inf 99.6%
sub-neg99.6%
neg-mul-199.6%
unsub-neg99.6%
associate-*r/99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
metadata-eval99.6%
Simplified99.6%
if -5 < x < 5.00000024e-4Initial program 21.2%
add-cbrt-cube21.2%
pow1/321.2%
log-pow21.1%
pow321.2%
log-pow21.2%
+-commutative21.2%
hypot-1-def21.2%
add-sqr-sqrt9.1%
fabs-sqr9.1%
add-sqr-sqrt21.4%
Applied egg-rr21.4%
Taylor expanded in x around 0 98.6%
+-commutative98.6%
*-commutative98.6%
fma-define98.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
Simplified99.6%
if 5.00000024e-4 < x Initial program 53.1%
*-un-lft-identity53.1%
*-commutative53.1%
log-prod53.1%
+-commutative53.1%
hypot-1-def99.9%
add-sqr-sqrt99.8%
fabs-sqr99.8%
add-sqr-sqrt99.9%
metadata-eval99.9%
Applied egg-rr99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.7%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.5)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (log (+ x (fabs x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(logf((x + fabsf(x))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(log(Float32(x + abs(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((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(log((x + abs(x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + \left|x\right|\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 63.3%
add-cbrt-cube38.2%
pow1/338.0%
log-pow37.9%
pow337.9%
log-pow62.5%
+-commutative62.5%
hypot-1-def98.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
Taylor expanded in x around -inf 97.2%
associate-*r*98.3%
metadata-eval98.3%
*-un-lft-identity98.3%
clear-num98.3%
log-rec98.4%
div-inv98.4%
metadata-eval98.4%
Applied egg-rr98.4%
if -5 < x < 0.5Initial program 22.4%
add-cbrt-cube22.4%
pow1/322.4%
log-pow22.3%
pow322.3%
log-pow22.4%
+-commutative22.4%
hypot-1-def22.4%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt22.6%
Applied egg-rr22.6%
Taylor expanded in x around 0 97.9%
+-commutative97.9%
*-commutative97.9%
fma-define98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in x around 0 98.9%
*-commutative98.9%
Simplified98.9%
if 0.5 < x Initial program 51.9%
Taylor expanded in x around inf 97.7%
Final simplification98.5%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.5)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign
(* 0.3333333333333333 (* 3.0 (log (+ (* x 2.0) (* 0.5 (/ 1.0 x))))))
x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf((0.3333333333333333f * (3.0f * 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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * 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((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * 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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right)\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 63.3%
add-cbrt-cube38.2%
pow1/338.0%
log-pow37.9%
pow337.9%
log-pow62.5%
+-commutative62.5%
hypot-1-def98.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
Taylor expanded in x around -inf 97.2%
associate-*r*98.3%
metadata-eval98.3%
*-un-lft-identity98.3%
clear-num98.3%
log-rec98.4%
div-inv98.4%
metadata-eval98.4%
Applied egg-rr98.4%
if -5 < x < 0.5Initial program 22.4%
add-cbrt-cube22.4%
pow1/322.4%
log-pow22.3%
pow322.3%
log-pow22.4%
+-commutative22.4%
hypot-1-def22.4%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt22.6%
Applied egg-rr22.6%
Taylor expanded in x around 0 97.9%
+-commutative97.9%
*-commutative97.9%
fma-define98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in x around 0 98.9%
*-commutative98.9%
Simplified98.9%
if 0.5 < x Initial program 51.9%
add-cbrt-cube38.5%
pow1/338.2%
log-pow38.2%
pow338.2%
log-pow51.5%
+-commutative51.5%
hypot-1-def99.0%
add-sqr-sqrt99.0%
fabs-sqr99.0%
add-sqr-sqrt99.0%
Applied egg-rr99.0%
Taylor expanded in x around inf 97.5%
Final simplification98.4%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.5)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (* 0.3333333333333333 (* 3.0 (log (* x 2.0)))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf((0.3333333333333333f * (3.0f * logf((x * 2.0f)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(Float32(Float32(0.3333333333333333) * Float32(Float32(3.0) * 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((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs((single(0.3333333333333333) * (single(3.0) * 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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(0.3333333333333333 \cdot \left(3 \cdot \log \left(x \cdot 2\right)\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 63.3%
add-cbrt-cube38.2%
pow1/338.0%
log-pow37.9%
pow337.9%
log-pow62.5%
+-commutative62.5%
hypot-1-def98.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
Taylor expanded in x around -inf 97.2%
associate-*r*98.3%
metadata-eval98.3%
*-un-lft-identity98.3%
clear-num98.3%
log-rec98.4%
div-inv98.4%
metadata-eval98.4%
Applied egg-rr98.4%
if -5 < x < 0.5Initial program 22.4%
add-cbrt-cube22.4%
pow1/322.4%
log-pow22.3%
pow322.3%
log-pow22.4%
+-commutative22.4%
hypot-1-def22.4%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt22.6%
Applied egg-rr22.6%
Taylor expanded in x around 0 97.9%
+-commutative97.9%
*-commutative97.9%
fma-define98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in x around 0 98.9%
*-commutative98.9%
Simplified98.9%
if 0.5 < x Initial program 51.9%
add-cbrt-cube38.5%
pow1/338.2%
log-pow38.2%
pow338.2%
log-pow51.5%
+-commutative51.5%
hypot-1-def99.0%
add-sqr-sqrt99.0%
fabs-sqr99.0%
add-sqr-sqrt99.0%
Applied egg-rr99.0%
Taylor expanded in x around inf 96.8%
*-commutative96.8%
Simplified96.8%
Final simplification98.2%
(FPCore (x)
:precision binary32
(if (<= x -5.0)
(copysign (- (log (* x -2.0))) x)
(if (<= x 0.5)
(copysign (+ x (* (pow x 3.0) -0.16666666666666666)) x)
(copysign (- (log (/ 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 0.5f) {
tmp = copysignf((x + (powf(x, 3.0f) * -0.16666666666666666f)), x);
} else {
tmp = copysignf(-logf((1.0f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(x + Float32((x ^ Float32(3.0)) * Float32(-0.16666666666666666))), x); else tmp = copysign(Float32(-log(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((x * single(-2.0)))); elseif (x <= single(0.5)) tmp = sign(x) * abs((x + ((x ^ single(3.0)) * single(-0.16666666666666666)))); else tmp = sign(x) * abs(-log((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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(x + {x}^{3} \cdot -0.16666666666666666, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 63.3%
add-cbrt-cube38.2%
pow1/338.0%
log-pow37.9%
pow337.9%
log-pow62.5%
+-commutative62.5%
hypot-1-def98.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
Taylor expanded in x around -inf 97.2%
associate-*r*98.3%
metadata-eval98.3%
*-un-lft-identity98.3%
clear-num98.3%
log-rec98.4%
div-inv98.4%
metadata-eval98.4%
Applied egg-rr98.4%
if -5 < x < 0.5Initial program 22.4%
add-cbrt-cube22.4%
pow1/322.4%
log-pow22.3%
pow322.3%
log-pow22.4%
+-commutative22.4%
hypot-1-def22.4%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt22.6%
Applied egg-rr22.6%
Taylor expanded in x around 0 97.9%
+-commutative97.9%
*-commutative97.9%
fma-define98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in x around 0 98.9%
*-commutative98.9%
Simplified98.9%
if 0.5 < x Initial program 51.9%
Taylor expanded in x around inf 44.0%
Final simplification83.8%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (- (log (* x -2.0))) x) (if (<= x 3.0) (copysign x x) (copysign (- (log (/ 1.0 x))) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 3.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(-logf((1.0f / x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-5.0)) tmp = copysign(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(3.0)) tmp = copysign(x, x); else tmp = copysign(Float32(-log(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((x * single(-2.0)))); elseif (x <= single(3.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(-log((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(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 3:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -5Initial program 63.3%
add-cbrt-cube38.2%
pow1/338.0%
log-pow37.9%
pow337.9%
log-pow62.5%
+-commutative62.5%
hypot-1-def98.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
Taylor expanded in x around -inf 97.2%
associate-*r*98.3%
metadata-eval98.3%
*-un-lft-identity98.3%
clear-num98.3%
log-rec98.4%
div-inv98.4%
metadata-eval98.4%
Applied egg-rr98.4%
if -5 < x < 3Initial program 23.0%
add-cbrt-cube23.0%
pow1/323.0%
log-pow22.9%
pow322.9%
log-pow23.0%
+-commutative23.0%
hypot-1-def22.9%
add-sqr-sqrt11.2%
fabs-sqr11.2%
add-sqr-sqrt23.2%
Applied egg-rr23.2%
Taylor expanded in x around 0 97.3%
+-commutative97.3%
*-commutative97.3%
fma-define97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in x around 0 97.8%
if 3 < x Initial program 51.2%
Taylor expanded in x around inf 44.2%
Final simplification83.5%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (log (/ -0.5 x)) x) (if (<= x 3.0) (copysign x x) (copysign (log x) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 3.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(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(3.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(log((single(-0.5) / x))); elseif (x <= single(3.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(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 3:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < -5Initial program 63.3%
add-cbrt-cube38.2%
pow1/338.0%
log-pow37.9%
pow337.9%
log-pow62.5%
+-commutative62.5%
hypot-1-def98.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
Taylor expanded in x around -inf 97.2%
Taylor expanded in x around 0 -0.0%
neg-mul-1-0.0%
sub-neg-0.0%
log-div98.3%
Simplified98.3%
if -5 < x < 3Initial program 23.0%
add-cbrt-cube23.0%
pow1/323.0%
log-pow22.9%
pow322.9%
log-pow23.0%
+-commutative23.0%
hypot-1-def22.9%
add-sqr-sqrt11.2%
fabs-sqr11.2%
add-sqr-sqrt23.2%
Applied egg-rr23.2%
Taylor expanded in x around 0 97.3%
+-commutative97.3%
*-commutative97.3%
fma-define97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in x around 0 97.8%
if 3 < x Initial program 51.2%
Taylor expanded in x around inf 44.2%
mul-1-neg44.2%
log-rec44.2%
remove-double-neg44.2%
Simplified44.2%
Final simplification83.5%
(FPCore (x) :precision binary32 (if (<= x -5.0) (copysign (- (log (* x -2.0))) x) (if (<= x 3.0) (copysign x x) (copysign (log x) x))))
float code(float x) {
float tmp;
if (x <= -5.0f) {
tmp = copysignf(-logf((x * -2.0f)), x);
} else if (x <= 3.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(Float32(-log(Float32(x * Float32(-2.0)))), x); elseif (x <= Float32(3.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(-log((x * single(-2.0)))); elseif (x <= single(3.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(-\log \left(x \cdot -2\right), x\right)\\
\mathbf{elif}\;x \leq 3:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < -5Initial program 63.3%
add-cbrt-cube38.2%
pow1/338.0%
log-pow37.9%
pow337.9%
log-pow62.5%
+-commutative62.5%
hypot-1-def98.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt10.7%
Applied egg-rr10.7%
Taylor expanded in x around -inf 97.2%
associate-*r*98.3%
metadata-eval98.3%
*-un-lft-identity98.3%
clear-num98.3%
log-rec98.4%
div-inv98.4%
metadata-eval98.4%
Applied egg-rr98.4%
if -5 < x < 3Initial program 23.0%
add-cbrt-cube23.0%
pow1/323.0%
log-pow22.9%
pow322.9%
log-pow23.0%
+-commutative23.0%
hypot-1-def22.9%
add-sqr-sqrt11.2%
fabs-sqr11.2%
add-sqr-sqrt23.2%
Applied egg-rr23.2%
Taylor expanded in x around 0 97.3%
+-commutative97.3%
*-commutative97.3%
fma-define97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in x around 0 97.8%
if 3 < x Initial program 51.2%
Taylor expanded in x around inf 44.2%
mul-1-neg44.2%
log-rec44.2%
remove-double-neg44.2%
Simplified44.2%
Final simplification83.5%
(FPCore (x) :precision binary32 (if (<= x 3.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 3.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(3.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(3.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 3:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 3Initial program 35.0%
add-cbrt-cube27.5%
pow1/327.5%
log-pow27.4%
pow327.4%
log-pow34.8%
+-commutative34.8%
hypot-1-def45.7%
add-sqr-sqrt7.8%
fabs-sqr7.8%
add-sqr-sqrt19.4%
Applied egg-rr19.4%
Taylor expanded in x around 0 70.5%
+-commutative70.5%
*-commutative70.5%
fma-define70.6%
*-commutative70.6%
Simplified70.6%
Taylor expanded in x around 0 71.9%
if 3 < x Initial program 51.2%
Taylor expanded in x around inf 44.2%
mul-1-neg44.2%
log-rec44.2%
remove-double-neg44.2%
Simplified44.2%
Final simplification64.5%
(FPCore (x) :precision binary32 (copysign x x))
float code(float x) {
return copysignf(x, x);
}
function code(x) return copysign(x, x) end
function tmp = code(x) tmp = sign(x) * abs(x); end
\begin{array}{l}
\\
\mathsf{copysign}\left(x, x\right)
\end{array}
Initial program 39.4%
add-cbrt-cube30.3%
pow1/330.1%
log-pow30.0%
pow330.1%
log-pow39.1%
+-commutative39.1%
hypot-1-def60.1%
add-sqr-sqrt32.4%
fabs-sqr32.4%
add-sqr-sqrt40.9%
Applied egg-rr40.9%
Taylor expanded in x around 0 53.7%
+-commutative53.7%
*-commutative53.7%
fma-define53.8%
*-commutative53.8%
Simplified53.8%
Taylor expanded in x around 0 55.6%
Final simplification55.6%
(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 2024030
(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))