
(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 13 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 -1.0)
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)
(if (<= t_0 0.05000000074505806)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
x)
(copysign (* 2.0 (log (sqrt (+ 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 <= -1.0f) {
tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
} else if (t_0 <= 0.05000000074505806f) {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf((2.0f * logf(sqrtf((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(-1.0)) tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); elseif (t_0 <= Float32(0.05000000074505806)) 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(Float32(Float32(2.0) * log(sqrt(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(-1.0)) tmp = sign(x) * abs(log((abs(x) + hypot(single(1.0), x)))); elseif (t_0 <= single(0.05000000074505806)) tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + (single(0.075) * (x ^ single(5.0)))))); else tmp = sign(x) * abs((single(2.0) * log(sqrt((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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{elif}\;t\_0 \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \log \left(\sqrt{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) < -1Initial program 49.4%
+-commutative49.4%
hypot-1-def98.5%
Simplified98.5%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.0500000007Initial program 22.5%
*-un-lft-identity22.5%
*-commutative22.5%
log-prod22.5%
*-un-lft-identity22.5%
*-un-lft-identity22.5%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt22.9%
+-commutative22.9%
hypot-1-def23.0%
metadata-eval23.0%
Applied egg-rr23.0%
+-rgt-identity23.0%
Simplified23.0%
Taylor expanded in x around 0 100.0%
if 0.0500000007 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 52.4%
add-sqr-sqrt52.3%
pow252.3%
log-pow52.5%
+-commutative52.5%
hypot-1-def98.5%
add-sqr-sqrt98.5%
fabs-sqr98.5%
add-sqr-sqrt98.5%
Applied egg-rr98.5%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (or (<= x -1.0) (not (<= x 0.05000000074505806)))
(copysign (log (+ (fabs x) (hypot 1.0 x))) x)
(copysign
(+ x (+ (* -0.16666666666666666 (pow x 3.0)) (* 0.075 (pow x 5.0))))
x)))
float code(float x) {
float tmp;
if ((x <= -1.0f) || !(x <= 0.05000000074505806f)) {
tmp = copysignf(logf((fabsf(x) + hypotf(1.0f, x))), x);
} else {
tmp = copysignf((x + ((-0.16666666666666666f * powf(x, 3.0f)) + (0.075f * powf(x, 5.0f)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if ((x <= Float32(-1.0)) || !(x <= Float32(0.05000000074505806))) tmp = copysign(log(Float32(abs(x) + hypot(Float32(1.0), x))), x); else tmp = copysign(Float32(x + Float32(Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0))) + Float32(Float32(0.075) * (x ^ Float32(5.0))))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if ((x <= single(-1.0)) || ~((x <= single(0.05000000074505806)))) tmp = sign(x) * abs(log((abs(x) + hypot(single(1.0), x)))); else tmp = sign(x) * abs((x + ((single(-0.16666666666666666) * (x ^ single(3.0))) + (single(0.075) * (x ^ single(5.0)))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 0.05000000074505806\right):\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \mathsf{hypot}\left(1, x\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(x + \left(-0.16666666666666666 \cdot {x}^{3} + 0.075 \cdot {x}^{5}\right), x\right)\\
\end{array}
\end{array}
if x < -1 or 0.0500000007 < x Initial program 50.9%
+-commutative50.9%
hypot-1-def98.5%
Simplified98.5%
if -1 < x < 0.0500000007Initial program 22.5%
*-un-lft-identity22.5%
*-commutative22.5%
log-prod22.5%
*-un-lft-identity22.5%
*-un-lft-identity22.5%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt22.9%
+-commutative22.9%
hypot-1-def23.0%
metadata-eval23.0%
Applied egg-rr23.0%
+-rgt-identity23.0%
Simplified23.0%
Taylor expanded in x around 0 100.0%
Final simplification99.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (+ (- (fabs x) x) (/ -0.5 x))) x)
(if (<= x 0.05000000074505806)
(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 tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(((fabsf(x) - x) + (-0.5f / x))), x);
} else if (x <= 0.05000000074505806f) {
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) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(abs(x) - x) + Float32(Float32(-0.5) / x))), x); elseif (x <= Float32(0.05000000074505806)) 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) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log(((abs(x) - x) + (single(-0.5) / x)))); elseif (x <= single(0.05000000074505806)) 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}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.05000000074505806:\\
\;\;\;\;\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 x < -1Initial program 49.4%
Taylor expanded in x around -inf 97.0%
sub-neg97.0%
neg-mul-197.0%
unsub-neg97.0%
associate-*r/97.0%
metadata-eval97.0%
distribute-neg-frac97.0%
metadata-eval97.0%
Simplified97.0%
if -1 < x < 0.0500000007Initial program 22.5%
*-un-lft-identity22.5%
*-commutative22.5%
log-prod22.5%
*-un-lft-identity22.5%
*-un-lft-identity22.5%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt22.9%
+-commutative22.9%
hypot-1-def23.0%
metadata-eval23.0%
Applied egg-rr23.0%
+-rgt-identity23.0%
Simplified23.0%
Taylor expanded in x around 0 100.0%
if 0.0500000007 < x Initial program 52.4%
*-un-lft-identity52.4%
*-commutative52.4%
log-prod52.4%
*-un-lft-identity52.4%
*-un-lft-identity52.4%
add-sqr-sqrt52.4%
fabs-sqr52.4%
add-sqr-sqrt52.4%
+-commutative52.4%
hypot-1-def98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
Final simplification98.9%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 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 <= -1.0f) {
tmp = copysignf(logf((-0.5f / 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(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / 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(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{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 < -1Initial program 49.4%
*-un-lft-identity49.4%
*-commutative49.4%
log-prod49.4%
*-un-lft-identity49.4%
*-un-lft-identity49.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.0%
+-commutative13.0%
hypot-1-def12.5%
metadata-eval12.5%
Applied egg-rr12.5%
+-rgt-identity12.5%
Simplified12.5%
Taylor expanded in x around -inf 96.8%
if -1 < x < 0.0500000007Initial program 22.5%
*-un-lft-identity22.5%
*-commutative22.5%
log-prod22.5%
*-un-lft-identity22.5%
*-un-lft-identity22.5%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt22.9%
+-commutative22.9%
hypot-1-def23.0%
metadata-eval23.0%
Applied egg-rr23.0%
+-rgt-identity23.0%
Simplified23.0%
Taylor expanded in x around 0 99.8%
if 0.0500000007 < x Initial program 52.4%
*-un-lft-identity52.4%
*-commutative52.4%
log-prod52.4%
*-un-lft-identity52.4%
*-un-lft-identity52.4%
add-sqr-sqrt52.4%
fabs-sqr52.4%
add-sqr-sqrt52.4%
+-commutative52.4%
hypot-1-def98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (+ (- (fabs x) x) (/ -0.5 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 <= -1.0f) {
tmp = copysignf(logf(((fabsf(x) - x) + (-0.5f / 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(-1.0)) tmp = copysign(log(Float32(Float32(abs(x) - x) + Float32(Float32(-0.5) / 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(-1.0)) tmp = sign(x) * abs(log(((abs(x) - x) + (single(-0.5) / 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 -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) + \frac{-0.5}{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 < -1Initial program 49.4%
Taylor expanded in x around -inf 97.0%
sub-neg97.0%
neg-mul-197.0%
unsub-neg97.0%
associate-*r/97.0%
metadata-eval97.0%
distribute-neg-frac97.0%
metadata-eval97.0%
Simplified97.0%
if -1 < x < 0.0500000007Initial program 22.5%
*-un-lft-identity22.5%
*-commutative22.5%
log-prod22.5%
*-un-lft-identity22.5%
*-un-lft-identity22.5%
add-sqr-sqrt10.0%
fabs-sqr10.0%
add-sqr-sqrt22.9%
+-commutative22.9%
hypot-1-def23.0%
metadata-eval23.0%
Applied egg-rr23.0%
+-rgt-identity23.0%
Simplified23.0%
Taylor expanded in x around 0 99.8%
if 0.0500000007 < x Initial program 52.4%
*-un-lft-identity52.4%
*-commutative52.4%
log-prod52.4%
*-un-lft-identity52.4%
*-un-lft-identity52.4%
add-sqr-sqrt52.4%
fabs-sqr52.4%
add-sqr-sqrt52.4%
+-commutative52.4%
hypot-1-def98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
Final simplification98.8%
(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 2.0) (log 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(2.0f) + logf(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(Float32(log(Float32(2.0)) + log(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(2.0)) + log(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 2 + \log x, x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
*-un-lft-identity49.4%
*-commutative49.4%
log-prod49.4%
*-un-lft-identity49.4%
*-un-lft-identity49.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.0%
+-commutative13.0%
hypot-1-def12.5%
metadata-eval12.5%
Applied egg-rr12.5%
+-rgt-identity12.5%
Simplified12.5%
Taylor expanded in x around -inf 96.8%
if -1 < x < 1Initial program 24.2%
*-un-lft-identity24.2%
*-commutative24.2%
log-prod24.2%
*-un-lft-identity24.2%
*-un-lft-identity24.2%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt24.6%
+-commutative24.6%
hypot-1-def24.7%
metadata-eval24.7%
Applied egg-rr24.7%
+-rgt-identity24.7%
Simplified24.7%
Taylor expanded in x around 0 98.5%
if 1 < x Initial program 50.2%
*-un-lft-identity50.2%
*-commutative50.2%
log-prod50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
add-sqr-sqrt50.2%
fabs-sqr50.2%
add-sqr-sqrt50.2%
+-commutative50.2%
hypot-1-def98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
Taylor expanded in x around inf 98.1%
mul-1-neg98.1%
log-rec98.1%
remove-double-neg98.1%
Simplified98.1%
Final simplification98.0%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.8999999761581421)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (+ (* x 2.0) (* 0.5 (/ 1.0 x)))) x))))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.8999999761581421f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf(((x * 2.0f) + (0.5f * (1.0f / x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-1.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.8999999761581421)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(Float32(x * Float32(2.0)) + Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(0.8999999761581421)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log(((x * single(2.0)) + (single(0.5) * (single(1.0) / x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.8999999761581421:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2 + 0.5 \cdot \frac{1}{x}\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
*-un-lft-identity49.4%
*-commutative49.4%
log-prod49.4%
*-un-lft-identity49.4%
*-un-lft-identity49.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.0%
+-commutative13.0%
hypot-1-def12.5%
metadata-eval12.5%
Applied egg-rr12.5%
+-rgt-identity12.5%
Simplified12.5%
Taylor expanded in x around -inf 96.8%
if -1 < x < 0.899999976Initial program 23.7%
*-un-lft-identity23.7%
*-commutative23.7%
log-prod23.7%
*-un-lft-identity23.7%
*-un-lft-identity23.7%
add-sqr-sqrt11.4%
fabs-sqr11.4%
add-sqr-sqrt24.0%
+-commutative24.0%
hypot-1-def24.1%
metadata-eval24.1%
Applied egg-rr24.1%
+-rgt-identity24.1%
Simplified24.1%
Taylor expanded in x around 0 99.0%
if 0.899999976 < x Initial program 51.0%
*-un-lft-identity51.0%
*-commutative51.0%
log-prod51.0%
*-un-lft-identity51.0%
*-un-lft-identity51.0%
add-sqr-sqrt51.0%
fabs-sqr51.0%
add-sqr-sqrt51.0%
+-commutative51.0%
hypot-1-def98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
Taylor expanded in x around inf 97.1%
Final simplification98.0%
(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 (* x 2.0)) 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((x * 2.0f)), 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(x * Float32(2.0))), 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((x * single(2.0)))); 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(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
*-un-lft-identity49.4%
*-commutative49.4%
log-prod49.4%
*-un-lft-identity49.4%
*-un-lft-identity49.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.0%
+-commutative13.0%
hypot-1-def12.5%
metadata-eval12.5%
Applied egg-rr12.5%
+-rgt-identity12.5%
Simplified12.5%
Taylor expanded in x around -inf 96.8%
if -1 < x < 1Initial program 24.2%
*-un-lft-identity24.2%
*-commutative24.2%
log-prod24.2%
*-un-lft-identity24.2%
*-un-lft-identity24.2%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt24.6%
+-commutative24.6%
hypot-1-def24.7%
metadata-eval24.7%
Applied egg-rr24.7%
+-rgt-identity24.7%
Simplified24.7%
Taylor expanded in x around 0 98.5%
if 1 < x Initial program 50.2%
*-un-lft-identity50.2%
*-commutative50.2%
log-prod50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
add-sqr-sqrt50.2%
fabs-sqr50.2%
add-sqr-sqrt50.2%
+-commutative50.2%
hypot-1-def98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
Taylor expanded in x around inf 97.3%
*-commutative97.3%
Simplified97.3%
Final simplification97.8%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) 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, x);
} else {
tmp = copysignf(logf((x * 2.0f)), 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(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-1.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 * single(2.0)))); 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, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -1Initial program 49.4%
*-un-lft-identity49.4%
*-commutative49.4%
log-prod49.4%
*-un-lft-identity49.4%
*-un-lft-identity49.4%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt13.0%
+-commutative13.0%
hypot-1-def12.5%
metadata-eval12.5%
Applied egg-rr12.5%
+-rgt-identity12.5%
Simplified12.5%
Taylor expanded in x around -inf 96.8%
if -1 < x < 1Initial program 24.2%
*-un-lft-identity24.2%
*-commutative24.2%
log-prod24.2%
*-un-lft-identity24.2%
*-un-lft-identity24.2%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt24.6%
+-commutative24.6%
hypot-1-def24.7%
metadata-eval24.7%
Applied egg-rr24.7%
+-rgt-identity24.7%
Simplified24.7%
Taylor expanded in x around 0 96.7%
if 1 < x Initial program 50.2%
*-un-lft-identity50.2%
*-commutative50.2%
log-prod50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
add-sqr-sqrt50.2%
fabs-sqr50.2%
add-sqr-sqrt50.2%
+-commutative50.2%
hypot-1-def98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
Taylor expanded in x around inf 97.3%
*-commutative97.3%
Simplified97.3%
Final simplification96.9%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), 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 * Float32(2.0))), 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 * single(2.0)))); 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 \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 32.4%
*-un-lft-identity32.4%
*-commutative32.4%
log-prod32.4%
*-un-lft-identity32.4%
*-un-lft-identity32.4%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt20.8%
+-commutative20.8%
hypot-1-def20.7%
metadata-eval20.7%
Applied egg-rr20.7%
+-rgt-identity20.7%
Simplified20.7%
Taylor expanded in x around 0 68.9%
if 1 < x Initial program 50.2%
*-un-lft-identity50.2%
*-commutative50.2%
log-prod50.2%
*-un-lft-identity50.2%
*-un-lft-identity50.2%
add-sqr-sqrt50.2%
fabs-sqr50.2%
add-sqr-sqrt50.2%
+-commutative50.2%
hypot-1-def98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-rgt-identity98.5%
Simplified98.5%
Taylor expanded in x around inf 97.3%
*-commutative97.3%
Simplified97.3%
Final simplification75.8%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign x x) (copysign (log x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.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(1.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 1:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log x, x\right)\\
\end{array}
\end{array}
if x < 1Initial program 32.4%
*-un-lft-identity32.4%
*-commutative32.4%
log-prod32.4%
*-un-lft-identity32.4%
*-un-lft-identity32.4%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt20.8%
+-commutative20.8%
hypot-1-def20.7%
metadata-eval20.7%
Applied egg-rr20.7%
+-rgt-identity20.7%
Simplified20.7%
Taylor expanded in x around 0 68.9%
if 1 < x Initial program 50.2%
Taylor expanded in x around inf 44.6%
mul-1-neg44.6%
log-rec44.6%
remove-double-neg44.6%
Simplified44.6%
Final simplification63.0%
(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 32.4%
*-un-lft-identity32.4%
*-commutative32.4%
log-prod32.4%
*-un-lft-identity32.4%
*-un-lft-identity32.4%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt20.8%
+-commutative20.8%
hypot-1-def20.7%
metadata-eval20.7%
Applied egg-rr20.7%
+-rgt-identity20.7%
Simplified20.7%
Taylor expanded in x around 0 68.9%
if 1 < x Initial program 50.2%
Taylor expanded in x around 0 44.6%
log1p-def44.6%
Simplified44.6%
expm1-log1p-u44.6%
expm1-udef44.6%
add-sqr-sqrt44.6%
fabs-sqr44.6%
add-sqr-sqrt44.6%
Applied egg-rr44.6%
expm1-def44.6%
expm1-log1p44.6%
Simplified44.6%
Final simplification63.1%
(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 36.7%
*-un-lft-identity36.7%
*-commutative36.7%
log-prod36.7%
*-un-lft-identity36.7%
*-un-lft-identity36.7%
add-sqr-sqrt18.3%
fabs-sqr18.3%
add-sqr-sqrt27.9%
+-commutative27.9%
hypot-1-def39.6%
metadata-eval39.6%
Applied egg-rr39.6%
+-rgt-identity39.6%
Simplified39.6%
Taylor expanded in x around 0 54.8%
Final simplification54.8%
(FPCore (x) :precision binary32 (let* ((t_0 (/ 1.0 (fabs x)))) (copysign (log1p (+ (fabs x) (/ (fabs x) (+ (hypot 1.0 t_0) t_0)))) x)))
float code(float x) {
float t_0 = 1.0f / fabsf(x);
return copysignf(log1pf((fabsf(x) + (fabsf(x) / (hypotf(1.0f, t_0) + t_0)))), x);
}
function code(x) t_0 = Float32(Float32(1.0) / abs(x)) return copysign(log1p(Float32(abs(x) + Float32(abs(x) / Float32(hypot(Float32(1.0), t_0) + t_0)))), x) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
\mathsf{copysign}\left(\mathsf{log1p}\left(\left|x\right| + \frac{\left|x\right|}{\mathsf{hypot}\left(1, t\_0\right) + t\_0}\right), x\right)
\end{array}
\end{array}
herbie shell --seed 2024031
(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))