
(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 -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 (hypot (sqrt (hypot 1.0 x)) (sqrt 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(hypotf(sqrtf(hypotf(1.0f, x)), sqrtf(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(hypot(sqrt(hypot(Float32(1.0), x)), sqrt(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(hypot(sqrt(hypot(single(1.0), x)), sqrt(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(\mathsf{hypot}\left(\sqrt{\mathsf{hypot}\left(1, x\right)}, \sqrt{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%
add-sqr-sqrt21.9%
pow221.9%
log-pow22.1%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt22.5%
+-commutative22.5%
hypot-1-def22.5%
Applied egg-rr22.5%
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%
add-sqr-sqrt52.5%
fabs-sqr52.5%
add-sqr-sqrt52.5%
+-commutative52.5%
hypot-1-def98.5%
Applied egg-rr98.5%
+-commutative98.5%
add-sqr-sqrt98.4%
add-sqr-sqrt98.4%
hypot-def99.9%
Applied egg-rr99.9%
Final simplification99.6%
(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%
add-sqr-sqrt21.9%
pow221.9%
log-pow22.1%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt22.5%
+-commutative22.5%
hypot-1-def22.5%
Applied egg-rr22.5%
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%
add-sqr-sqrt52.5%
fabs-sqr52.5%
add-sqr-sqrt52.5%
+-commutative52.5%
hypot-1-def98.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%
add-sqr-sqrt21.9%
pow221.9%
log-pow22.1%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt22.5%
+-commutative22.5%
hypot-1-def22.5%
Applied egg-rr22.5%
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%
add-sqr-sqrt21.9%
pow221.9%
log-pow22.1%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt22.5%
+-commutative22.5%
hypot-1-def22.5%
Applied egg-rr22.5%
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 (* 2.0 (+ (* (pow x 3.0) -0.08333333333333333) (* x 0.5))) 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((2.0f * ((powf(x, 3.0f) * -0.08333333333333333f) + (x * 0.5f))), 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(Float32(2.0) * Float32(Float32((x ^ Float32(3.0)) * Float32(-0.08333333333333333)) + Float32(x * Float32(0.5)))), 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((single(2.0) * (((x ^ single(3.0)) * single(-0.08333333333333333)) + (x * single(0.5))))); 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(2 \cdot \left({x}^{3} \cdot -0.08333333333333333 + x \cdot 0.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%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt96.8%
associate-*r/96.8%
metadata-eval96.8%
distribute-neg-frac96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in x around 0 -0.0%
mul-1-neg-0.0%
sub-neg-0.0%
log-div96.8%
Simplified96.8%
if -1 < x < 0.0500000007Initial program 22.5%
add-sqr-sqrt21.9%
pow221.9%
log-pow22.1%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt22.5%
+-commutative22.5%
hypot-1-def22.5%
Applied egg-rr22.5%
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 (* 2.0 (+ (* (pow x 3.0) -0.08333333333333333) (* x 0.5))) 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((2.0f * ((powf(x, 3.0f) * -0.08333333333333333f) + (x * 0.5f))), 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(Float32(2.0) * Float32(Float32((x ^ Float32(3.0)) * Float32(-0.08333333333333333)) + Float32(x * Float32(0.5)))), 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((single(2.0) * (((x ^ single(3.0)) * single(-0.08333333333333333)) + (x * single(0.5))))); 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(2 \cdot \left({x}^{3} \cdot -0.08333333333333333 + x \cdot 0.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%
add-sqr-sqrt21.9%
pow221.9%
log-pow22.1%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt22.5%
+-commutative22.5%
hypot-1-def22.5%
Applied egg-rr22.5%
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 0.8999999761581421)
(copysign (* 2.0 (+ (* (pow x 3.0) -0.08333333333333333) (* x 0.5))) 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 <= 0.8999999761581421f) {
tmp = copysignf((2.0f * ((powf(x, 3.0f) * -0.08333333333333333f) + (x * 0.5f))), 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(0.8999999761581421)) tmp = copysign(Float32(Float32(2.0) * Float32(Float32((x ^ Float32(3.0)) * Float32(-0.08333333333333333)) + Float32(x * Float32(0.5)))), 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(0.8999999761581421)) tmp = sign(x) * abs((single(2.0) * (((x ^ single(3.0)) * single(-0.08333333333333333)) + (x * single(0.5))))); 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 0.8999999761581421:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left({x}^{3} \cdot -0.08333333333333333 + x \cdot 0.5\right), 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.4%
Taylor expanded in x around -inf 97.0%
sub-neg97.0%
neg-mul-197.0%
unsub-neg97.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt96.8%
associate-*r/96.8%
metadata-eval96.8%
distribute-neg-frac96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in x around 0 -0.0%
mul-1-neg-0.0%
sub-neg-0.0%
log-div96.8%
Simplified96.8%
if -1 < x < 0.899999976Initial program 23.7%
add-sqr-sqrt23.1%
pow223.1%
log-pow23.3%
add-sqr-sqrt11.3%
fabs-sqr11.3%
add-sqr-sqrt23.7%
+-commutative23.7%
hypot-1-def23.7%
Applied egg-rr23.7%
Taylor expanded in x around 0 99.0%
if 0.899999976 < x Initial program 51.0%
Taylor expanded in x around inf 97.1%
associate-+r+97.1%
+-commutative97.1%
associate-*r/97.1%
metadata-eval97.1%
rem-square-sqrt97.1%
fabs-sqr97.1%
rem-square-sqrt97.1%
Simplified97.1%
Final simplification98.0%
(FPCore (x)
:precision binary32
(if (<= x -4.0)
(copysign (log (- x)) x)
(if (<= x 0.5)
(copysign (* 2.0 (* x 0.5)) x)
(if (<= x 1.9999999360571385e+38)
(copysign (log (* x E)) x)
(copysign (log1p x) x)))))
float code(float x) {
float tmp;
if (x <= -4.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 0.5f) {
tmp = copysignf((2.0f * (x * 0.5f)), x);
} else if (x <= 1.9999999360571385e+38f) {
tmp = copysignf(logf((x * ((float) M_E))), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-4.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(0.5)) tmp = copysign(Float32(Float32(2.0) * Float32(x * Float32(0.5))), x); elseif (x <= Float32(1.9999999360571385e+38)) tmp = copysign(log(Float32(x * Float32(exp(1)))), x); else tmp = copysign(log1p(x), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 0.5:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left(x \cdot 0.5\right), x\right)\\
\mathbf{elif}\;x \leq 1.9999999360571385 \cdot 10^{+38}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot e\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < -4Initial program 48.7%
Taylor expanded in x around -inf 97.8%
sub-neg97.8%
neg-mul-197.8%
unsub-neg97.8%
associate-*r/97.8%
metadata-eval97.8%
distribute-neg-frac97.8%
metadata-eval97.8%
Simplified97.8%
Taylor expanded in x around inf -0.0%
mul-1-neg-0.0%
log-rec-0.0%
remove-double-neg-0.0%
log-prod44.7%
neg-mul-144.7%
Simplified44.7%
if -4 < x < 0.5Initial program 23.7%
add-sqr-sqrt23.1%
pow223.1%
log-pow23.2%
add-sqr-sqrt10.5%
fabs-sqr10.5%
add-sqr-sqrt23.6%
+-commutative23.6%
hypot-1-def23.7%
Applied egg-rr23.7%
Taylor expanded in x around 0 97.2%
*-commutative97.2%
Simplified97.2%
if 0.5 < x < 1.99999994e38Initial program 52.4%
Taylor expanded in x around inf 48.0%
mul-1-neg48.0%
log-rec48.0%
remove-double-neg48.0%
rem-square-sqrt48.0%
fabs-sqr48.0%
rem-square-sqrt48.0%
Simplified48.0%
add-log-exp48.0%
*-inverses48.0%
+-commutative48.0%
exp-sum48.0%
exp-1-e48.0%
add-exp-log48.0%
Applied egg-rr48.0%
if 1.99999994e38 < x Initial program 6.5%
Taylor expanded in x around 0 48.5%
log1p-def48.5%
rem-square-sqrt48.5%
fabs-sqr48.5%
rem-square-sqrt48.5%
Simplified48.5%
Final simplification72.2%
(FPCore (x)
:precision binary32
(if (<= x -1.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.5)
(copysign (* 2.0 (* x 0.5)) 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 <= 0.5f) {
tmp = copysignf((2.0f * (x * 0.5f)), 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(0.5)) tmp = copysign(Float32(Float32(2.0) * Float32(x * Float32(0.5))), 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(0.5)) tmp = sign(x) * abs((single(2.0) * (x * single(0.5)))); 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 0.5:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left(x \cdot 0.5\right), 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.4%
Taylor expanded in x around -inf 97.0%
sub-neg97.0%
neg-mul-197.0%
unsub-neg97.0%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt96.8%
associate-*r/96.8%
metadata-eval96.8%
distribute-neg-frac96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in x around 0 -0.0%
mul-1-neg-0.0%
sub-neg-0.0%
log-div96.8%
Simplified96.8%
if -1 < x < 0.5Initial program 23.1%
add-sqr-sqrt22.5%
pow222.5%
log-pow22.7%
add-sqr-sqrt10.6%
fabs-sqr10.6%
add-sqr-sqrt23.1%
+-commutative23.1%
hypot-1-def23.1%
Applied egg-rr23.1%
Taylor expanded in x around 0 97.6%
*-commutative97.6%
Simplified97.6%
if 0.5 < x Initial program 51.7%
Taylor expanded in x around inf 96.2%
associate-+r+96.2%
+-commutative96.2%
associate-*r/96.2%
metadata-eval96.2%
rem-square-sqrt96.1%
fabs-sqr96.1%
rem-square-sqrt96.2%
Simplified96.2%
Final simplification97.1%
(FPCore (x) :precision binary32 (if (<= x -4.0) (copysign (log (- x)) x) (if (<= x 1.0) (copysign (* 2.0 (* x 0.5)) x) (copysign (log (+ x x)) x))))
float code(float x) {
float tmp;
if (x <= -4.0f) {
tmp = copysignf(logf(-x), x);
} else if (x <= 1.0f) {
tmp = copysignf((2.0f * (x * 0.5f)), x);
} else {
tmp = copysignf(logf((x + x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-4.0)) tmp = copysign(log(Float32(-x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(Float32(2.0) * Float32(x * Float32(0.5))), 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(-4.0)) tmp = sign(x) * abs(log(-x)); elseif (x <= single(1.0)) tmp = sign(x) * abs((single(2.0) * (x * single(0.5)))); else tmp = sign(x) * abs(log((x + x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(-x\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left(x \cdot 0.5\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\right), x\right)\\
\end{array}
\end{array}
if x < -4Initial program 48.7%
Taylor expanded in x around -inf 97.8%
sub-neg97.8%
neg-mul-197.8%
unsub-neg97.8%
associate-*r/97.8%
metadata-eval97.8%
distribute-neg-frac97.8%
metadata-eval97.8%
Simplified97.8%
Taylor expanded in x around inf -0.0%
mul-1-neg-0.0%
log-rec-0.0%
remove-double-neg-0.0%
log-prod44.7%
neg-mul-144.7%
Simplified44.7%
if -4 < x < 1Initial program 24.8%
add-sqr-sqrt24.2%
pow224.2%
log-pow24.4%
add-sqr-sqrt11.9%
fabs-sqr11.9%
add-sqr-sqrt24.8%
+-commutative24.8%
hypot-1-def24.9%
Applied egg-rr24.9%
Taylor expanded in x around 0 96.2%
*-commutative96.2%
Simplified96.2%
if 1 < x Initial program 50.2%
Taylor expanded in x around inf 97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
Simplified97.3%
Final simplification84.0%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (/ -0.5 x)) x) (if (<= x 1.0) (copysign (* 2.0 (* x 0.5)) 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 <= 1.0f) {
tmp = copysignf((2.0f * (x * 0.5f)), 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(1.0)) tmp = copysign(Float32(Float32(2.0) * Float32(x * Float32(0.5))), 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(1.0)) tmp = sign(x) * abs((single(2.0) * (x * single(0.5)))); 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 1:\\
\;\;\;\;\mathsf{copysign}\left(2 \cdot \left(x \cdot 0.5\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x + x\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%
rem-square-sqrt-0.0%
fabs-sqr-0.0%
rem-square-sqrt96.8%
associate-*r/96.8%
metadata-eval96.8%
distribute-neg-frac96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in x around 0 -0.0%
mul-1-neg-0.0%
sub-neg-0.0%
log-div96.8%
Simplified96.8%
if -1 < x < 1Initial program 24.2%
add-sqr-sqrt23.7%
pow223.7%
log-pow23.9%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt24.3%
+-commutative24.3%
hypot-1-def24.3%
Applied egg-rr24.3%
Taylor expanded in x around 0 96.7%
*-commutative96.7%
Simplified96.7%
if 1 < x Initial program 50.2%
Taylor expanded in x around inf 97.3%
rem-square-sqrt97.3%
fabs-sqr97.3%
rem-square-sqrt97.3%
Simplified97.3%
Final simplification96.9%
(FPCore (x) :precision binary32 (if (<= x -1.0) (copysign (log (- x)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= -1.0f) {
tmp = copysignf(logf(-x), 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(-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(\log \left(-x\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\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%
Taylor expanded in x around inf -0.0%
mul-1-neg-0.0%
log-rec-0.0%
remove-double-neg-0.0%
log-prod44.4%
neg-mul-144.4%
Simplified44.4%
if -1 < x Initial program 32.6%
Taylor expanded in x around 0 28.1%
log1p-def77.1%
rem-square-sqrt44.8%
fabs-sqr44.8%
rem-square-sqrt77.1%
Simplified77.1%
Final simplification69.0%
(FPCore (x) :precision binary32 (if (<= x 1.0) (copysign (* 2.0 (* x 0.5)) x) (copysign (log1p x) x)))
float code(float x) {
float tmp;
if (x <= 1.0f) {
tmp = copysignf((2.0f * (x * 0.5f)), x);
} else {
tmp = copysignf(log1pf(x), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(1.0)) tmp = copysign(Float32(Float32(2.0) * Float32(x * Float32(0.5))), 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(2 \cdot \left(x \cdot 0.5\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(x\right), x\right)\\
\end{array}
\end{array}
if x < 1Initial program 32.4%
add-sqr-sqrt32.0%
pow232.0%
log-pow32.2%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt20.6%
+-commutative20.6%
hypot-1-def20.5%
Applied egg-rr20.5%
Taylor expanded in x around 0 68.9%
*-commutative68.9%
Simplified68.9%
if 1 < x Initial program 50.2%
Taylor expanded in x around 0 44.6%
log1p-def44.6%
rem-square-sqrt44.6%
fabs-sqr44.6%
rem-square-sqrt44.6%
Simplified44.6%
Final simplification63.1%
(FPCore (x) :precision binary32 (copysign (* 2.0 (* x 0.5)) x))
float code(float x) {
return copysignf((2.0f * (x * 0.5f)), x);
}
function code(x) return copysign(Float32(Float32(2.0) * Float32(x * Float32(0.5))), x) end
function tmp = code(x) tmp = sign(x) * abs((single(2.0) * (x * single(0.5)))); end
\begin{array}{l}
\\
\mathsf{copysign}\left(2 \cdot \left(x \cdot 0.5\right), x\right)
\end{array}
Initial program 36.7%
add-sqr-sqrt36.4%
pow236.4%
log-pow36.5%
add-sqr-sqrt18.3%
fabs-sqr18.3%
add-sqr-sqrt27.8%
+-commutative27.8%
hypot-1-def39.4%
Applied egg-rr39.4%
Taylor expanded in x around 0 54.8%
*-commutative54.8%
Simplified54.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))