
(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.10000000149011612)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 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.10000000149011612f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (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.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(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.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((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.10000000149011612:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 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 59.9%
+-commutative59.9%
hypot-1-def100.0%
Simplified100.0%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.100000001Initial program 17.4%
log1p-expm1-u17.4%
expm1-udef17.4%
add-exp-log17.4%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt17.5%
+-commutative17.5%
hypot-1-def17.4%
Applied egg-rr17.4%
sub-neg17.4%
+-commutative17.4%
metadata-eval17.4%
associate-+l+17.5%
Applied egg-rr17.5%
Taylor expanded in x around 0 100.0%
if 0.100000001 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 50.5%
add-sqr-sqrt50.4%
pow250.4%
log-pow50.4%
add-sqr-sqrt50.4%
fabs-sqr50.4%
add-sqr-sqrt50.4%
+-commutative50.4%
hypot-1-def95.8%
Applied egg-rr95.8%
+-commutative95.8%
add-sqr-sqrt95.7%
add-sqr-sqrt95.8%
hypot-def99.7%
Applied egg-rr99.7%
Final simplification99.9%
(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.800000011920929)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (+ (log 2.0) (+ (log x) (/ 0.25 (* x 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.800000011920929f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf((logf(2.0f) + (logf(x) + (0.25f / (x * 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.800000011920929)) 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(Float32(log(Float32(2.0)) + Float32(log(x) + Float32(Float32(0.25) / Float32(x * 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.800000011920929)) 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(single(2.0)) + (log(x) + (single(0.25) / (x * 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.800000011920929:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log 2 + \left(\log x + \frac{0.25}{x \cdot x}\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 59.9%
+-commutative59.9%
hypot-1-def100.0%
Simplified100.0%
if -1 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) < 0.800000012Initial program 18.7%
log1p-expm1-u18.7%
expm1-udef18.7%
add-exp-log18.7%
add-sqr-sqrt11.3%
fabs-sqr11.3%
add-sqr-sqrt18.8%
+-commutative18.8%
hypot-1-def18.7%
Applied egg-rr18.7%
sub-neg18.7%
+-commutative18.7%
metadata-eval18.7%
associate-+l+18.8%
Applied egg-rr18.8%
Taylor expanded in x around 0 99.4%
if 0.800000012 < (copysign.f32 (log.f32 (+.f32 (fabs.f32 x) (sqrt.f32 (+.f32 (*.f32 x x) 1)))) x) Initial program 49.2%
*-un-lft-identity49.2%
*-commutative49.2%
log-prod49.2%
add-sqr-sqrt49.1%
fabs-sqr49.1%
add-sqr-sqrt49.2%
+-commutative49.2%
hypot-1-def95.9%
metadata-eval95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 97.5%
associate-+r+97.5%
+-commutative97.5%
*-lft-identity97.5%
distribute-lft-in97.5%
*-lft-identity97.5%
associate-+l+97.5%
log-rec97.4%
mul-1-neg97.4%
remove-double-neg97.4%
*-lft-identity97.4%
associate-*r/97.4%
metadata-eval97.4%
unpow297.4%
Simplified97.4%
Final simplification99.0%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (- (- (fabs x) x) (* 0.5 (/ 1.0 x)))) x)
(if (<= x 0.10000000149011612)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (log1p (+ (hypot 1.0 x) (+ x -1.0))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf(((fabsf(x) - x) - (0.5f * (1.0f / x)))), x);
} else if (x <= 0.10000000149011612f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf(log1pf((hypotf(1.0f, x) + (x + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(abs(x) - x) - Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x); elseif (x <= 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(log1p(Float32(hypot(Float32(1.0), x) + Float32(x + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\
\mathbf{elif}\;x \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(\mathsf{log1p}\left(\mathsf{hypot}\left(1, x\right) + \left(x + -1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 59.9%
Taylor expanded in x around -inf 99.3%
if -2 < x < 0.100000001Initial program 17.4%
log1p-expm1-u17.4%
expm1-udef17.4%
add-exp-log17.4%
add-sqr-sqrt9.9%
fabs-sqr9.9%
add-sqr-sqrt17.5%
+-commutative17.5%
hypot-1-def17.4%
Applied egg-rr17.4%
sub-neg17.4%
+-commutative17.4%
metadata-eval17.4%
associate-+l+17.5%
Applied egg-rr17.5%
Taylor expanded in x around 0 100.0%
if 0.100000001 < x Initial program 50.5%
log1p-expm1-u50.5%
expm1-udef50.5%
add-exp-log50.5%
add-sqr-sqrt50.5%
fabs-sqr50.5%
add-sqr-sqrt50.5%
+-commutative50.5%
hypot-1-def96.0%
Applied egg-rr96.0%
sub-neg96.0%
+-commutative96.0%
metadata-eval96.0%
associate-+l+96.0%
Applied egg-rr96.0%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (- (- (fabs x) x) (* 0.5 (/ 1.0 x)))) x)
(if (<= x 1.0)
(copysign
(+ (* -0.16666666666666666 (pow x 3.0)) (+ x (* 0.075 (pow x 5.0))))
x)
(copysign (+ (log 2.0) (+ (log x) (/ 0.25 (* x x)))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf(((fabsf(x) - x) - (0.5f * (1.0f / x)))), x);
} else if (x <= 1.0f) {
tmp = copysignf(((-0.16666666666666666f * powf(x, 3.0f)) + (x + (0.075f * powf(x, 5.0f)))), x);
} else {
tmp = copysignf((logf(2.0f) + (logf(x) + (0.25f / (x * x)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(abs(x) - x) - Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x); elseif (x <= Float32(1.0)) 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(Float32(log(Float32(2.0)) + Float32(log(x) + Float32(Float32(0.25) / Float32(x * x)))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log(((abs(x) - x) - (single(0.5) * (single(1.0) / x))))); elseif (x <= single(1.0)) 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(single(2.0)) + (log(x) + (single(0.25) / (x * x))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(-0.16666666666666666 \cdot {x}^{3} + \left(x + 0.075 \cdot {x}^{5}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log 2 + \left(\log x + \frac{0.25}{x \cdot x}\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 59.9%
Taylor expanded in x around -inf 99.3%
if -2 < x < 1Initial program 18.7%
log1p-expm1-u18.7%
expm1-udef18.7%
add-exp-log18.7%
add-sqr-sqrt11.3%
fabs-sqr11.3%
add-sqr-sqrt18.8%
+-commutative18.8%
hypot-1-def18.7%
Applied egg-rr18.7%
sub-neg18.7%
+-commutative18.7%
metadata-eval18.7%
associate-+l+18.8%
Applied egg-rr18.8%
Taylor expanded in x around 0 99.4%
if 1 < x Initial program 49.2%
*-un-lft-identity49.2%
*-commutative49.2%
log-prod49.2%
add-sqr-sqrt49.1%
fabs-sqr49.1%
add-sqr-sqrt49.2%
+-commutative49.2%
hypot-1-def95.9%
metadata-eval95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 97.5%
associate-+r+97.5%
+-commutative97.5%
*-lft-identity97.5%
distribute-lft-in97.5%
*-lft-identity97.5%
associate-+l+97.5%
log-rec97.4%
mul-1-neg97.4%
remove-double-neg97.4%
*-lft-identity97.4%
associate-*r/97.4%
metadata-eval97.4%
unpow297.4%
Simplified97.4%
Final simplification98.8%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (- (- (fabs x) x) (* 0.5 (/ 1.0 x)))) x)
(if (<= x 0.004999999888241291)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log1p (+ (hypot 1.0 x) (+ x -1.0))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf(((fabsf(x) - x) - (0.5f * (1.0f / x)))), x);
} else if (x <= 0.004999999888241291f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(log1pf((hypotf(1.0f, x) + (x + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(abs(x) - x) - Float32(Float32(0.5) * Float32(Float32(1.0) / x)))), x); elseif (x <= Float32(0.004999999888241291)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log1p(Float32(hypot(Float32(1.0), x) + Float32(x + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| - x\right) - 0.5 \cdot \frac{1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, x\right) + \left(x + -1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 59.9%
Taylor expanded in x around -inf 99.3%
if -2 < x < 0.00499999989Initial program 16.8%
log1p-expm1-u16.8%
expm1-udef16.8%
add-exp-log16.8%
add-sqr-sqrt9.2%
fabs-sqr9.2%
add-sqr-sqrt16.8%
+-commutative16.8%
hypot-1-def16.8%
Applied egg-rr16.8%
sub-neg16.8%
+-commutative16.8%
metadata-eval16.8%
associate-+l+16.9%
Applied egg-rr16.9%
Taylor expanded in x around 0 100.0%
if 0.00499999989 < x Initial program 51.1%
log1p-expm1-u51.1%
expm1-udef51.1%
add-exp-log51.1%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt51.1%
+-commutative51.1%
hypot-1-def95.9%
Applied egg-rr95.9%
sub-neg95.9%
+-commutative95.9%
metadata-eval95.9%
associate-+l+95.9%
Applied egg-rr95.9%
Final simplification98.7%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 0.004999999888241291)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log1p (+ (hypot 1.0 x) (+ x -1.0))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 0.004999999888241291f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(log1pf((hypotf(1.0f, x) + (x + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(0.004999999888241291)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log1p(Float32(hypot(Float32(1.0), x) + Float32(x + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, x\right) + \left(x + -1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 59.9%
*-un-lft-identity59.9%
*-commutative59.9%
log-prod59.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.6%
+-commutative12.6%
hypot-1-def12.6%
metadata-eval12.6%
Applied egg-rr12.6%
Taylor expanded in x around -inf 97.8%
if -2 < x < 0.00499999989Initial program 16.8%
log1p-expm1-u16.8%
expm1-udef16.8%
add-exp-log16.8%
add-sqr-sqrt9.2%
fabs-sqr9.2%
add-sqr-sqrt16.8%
+-commutative16.8%
hypot-1-def16.8%
Applied egg-rr16.8%
sub-neg16.8%
+-commutative16.8%
metadata-eval16.8%
associate-+l+16.9%
Applied egg-rr16.9%
Taylor expanded in x around 0 100.0%
if 0.00499999989 < x Initial program 51.1%
log1p-expm1-u51.1%
expm1-udef51.1%
add-exp-log51.1%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt51.1%
+-commutative51.1%
hypot-1-def95.9%
Applied egg-rr95.9%
sub-neg95.9%
+-commutative95.9%
metadata-eval95.9%
associate-+l+95.9%
Applied egg-rr95.9%
Final simplification98.3%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (- (/ 0.125 (pow x 3.0)) (/ 0.5 x))) x)
(if (<= x 0.004999999888241291)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log1p (+ (hypot 1.0 x) (+ x -1.0))) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf(((0.125f / powf(x, 3.0f)) - (0.5f / x))), x);
} else if (x <= 0.004999999888241291f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(log1pf((hypotf(1.0f, x) + (x + -1.0f))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(Float32(0.125) / (x ^ Float32(3.0))) - Float32(Float32(0.5) / x))), x); elseif (x <= Float32(0.004999999888241291)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log1p(Float32(hypot(Float32(1.0), x) + Float32(x + Float32(-1.0)))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.125}{{x}^{3}} - \frac{0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 0.004999999888241291:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(\mathsf{hypot}\left(1, x\right) + \left(x + -1\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 59.9%
*-un-lft-identity59.9%
*-commutative59.9%
log-prod59.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.6%
+-commutative12.6%
hypot-1-def12.6%
metadata-eval12.6%
Applied egg-rr12.6%
Taylor expanded in x around -inf 99.2%
associate-*r/99.2%
metadata-eval99.2%
associate-*r/99.2%
metadata-eval99.2%
Simplified99.2%
if -2 < x < 0.00499999989Initial program 16.8%
log1p-expm1-u16.8%
expm1-udef16.8%
add-exp-log16.8%
add-sqr-sqrt9.2%
fabs-sqr9.2%
add-sqr-sqrt16.8%
+-commutative16.8%
hypot-1-def16.8%
Applied egg-rr16.8%
sub-neg16.8%
+-commutative16.8%
metadata-eval16.8%
associate-+l+16.9%
Applied egg-rr16.9%
Taylor expanded in x around 0 100.0%
if 0.00499999989 < x Initial program 51.1%
log1p-expm1-u51.1%
expm1-udef51.1%
add-exp-log51.1%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt51.1%
+-commutative51.1%
hypot-1-def95.9%
Applied egg-rr95.9%
sub-neg95.9%
+-commutative95.9%
metadata-eval95.9%
associate-+l+95.9%
Applied egg-rr95.9%
Final simplification98.6%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 2.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (+ (log 2.0) (log x)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 2.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf((logf(2.0f) + logf(x)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(2.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(Float32(log(Float32(2.0)) + log(x)), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(2.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs((log(single(2.0)) + log(x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log 2 + \log x, x\right)\\
\end{array}
\end{array}
if x < -2Initial program 59.9%
*-un-lft-identity59.9%
*-commutative59.9%
log-prod59.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.6%
+-commutative12.6%
hypot-1-def12.6%
metadata-eval12.6%
Applied egg-rr12.6%
Taylor expanded in x around -inf 97.8%
if -2 < x < 2Initial program 19.4%
log1p-expm1-u19.4%
expm1-udef19.4%
add-exp-log19.4%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt19.4%
+-commutative19.4%
hypot-1-def19.4%
Applied egg-rr19.4%
sub-neg19.4%
+-commutative19.4%
metadata-eval19.4%
associate-+l+19.4%
Applied egg-rr19.4%
Taylor expanded in x around 0 98.6%
if 2 < x Initial program 48.4%
*-un-lft-identity48.4%
*-commutative48.4%
log-prod48.4%
add-sqr-sqrt48.4%
fabs-sqr48.4%
add-sqr-sqrt48.4%
+-commutative48.4%
hypot-1-def95.8%
metadata-eval95.8%
Applied egg-rr95.8%
Taylor expanded in x around inf 97.4%
log-rec97.4%
mul-1-neg97.4%
remove-double-neg97.4%
Simplified97.4%
Final simplification98.1%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log1p (+ -1.0 (+ (* 0.5 (/ 1.0 x)) (* x 2.0)))) x))))
float code(float x) {
float tmp;
if (x <= -2.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(log1pf((-1.0f + ((0.5f * (1.0f / x)) + (x * 2.0f)))), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log1p(Float32(Float32(-1.0) + Float32(Float32(Float32(0.5) * Float32(Float32(1.0) / x)) + Float32(x * Float32(2.0))))), x); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\mathsf{log1p}\left(-1 + \left(0.5 \cdot \frac{1}{x} + x \cdot 2\right)\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 59.9%
*-un-lft-identity59.9%
*-commutative59.9%
log-prod59.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.6%
+-commutative12.6%
hypot-1-def12.6%
metadata-eval12.6%
Applied egg-rr12.6%
Taylor expanded in x around -inf 97.8%
if -2 < x < 1Initial program 18.7%
log1p-expm1-u18.7%
expm1-udef18.7%
add-exp-log18.7%
add-sqr-sqrt11.3%
fabs-sqr11.3%
add-sqr-sqrt18.8%
+-commutative18.8%
hypot-1-def18.7%
Applied egg-rr18.7%
sub-neg18.7%
+-commutative18.7%
metadata-eval18.7%
associate-+l+18.8%
Applied egg-rr18.8%
Taylor expanded in x around 0 99.1%
if 1 < x Initial program 49.2%
log1p-expm1-u49.1%
expm1-udef49.1%
add-exp-log49.2%
add-sqr-sqrt49.1%
fabs-sqr49.1%
add-sqr-sqrt49.2%
+-commutative49.2%
hypot-1-def95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 94.3%
Final simplification97.5%
(FPCore (x)
:precision binary32
(if (<= x -2.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 2.0)
(copysign (+ x (* -0.16666666666666666 (pow x 3.0))) x)
(copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 2.0f) {
tmp = copysignf((x + (-0.16666666666666666f * powf(x, 3.0f))), x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(2.0)) tmp = copysign(Float32(x + Float32(Float32(-0.16666666666666666) * (x ^ Float32(3.0)))), x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(2.0)) tmp = sign(x) * abs((x + (single(-0.16666666666666666) * (x ^ single(3.0))))); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x + -0.16666666666666666 \cdot {x}^{3}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 59.9%
*-un-lft-identity59.9%
*-commutative59.9%
log-prod59.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.6%
+-commutative12.6%
hypot-1-def12.6%
metadata-eval12.6%
Applied egg-rr12.6%
Taylor expanded in x around -inf 97.8%
if -2 < x < 2Initial program 19.4%
log1p-expm1-u19.4%
expm1-udef19.4%
add-exp-log19.4%
add-sqr-sqrt12.0%
fabs-sqr12.0%
add-sqr-sqrt19.4%
+-commutative19.4%
hypot-1-def19.4%
Applied egg-rr19.4%
sub-neg19.4%
+-commutative19.4%
metadata-eval19.4%
associate-+l+19.4%
Applied egg-rr19.4%
Taylor expanded in x around 0 98.6%
if 2 < x Initial program 48.4%
log1p-expm1-u48.4%
expm1-udef48.4%
add-exp-log48.5%
add-sqr-sqrt48.4%
fabs-sqr48.4%
add-sqr-sqrt48.5%
+-commutative48.5%
hypot-1-def95.9%
Applied egg-rr95.9%
sub-neg95.9%
+-commutative95.9%
metadata-eval95.9%
associate-+l+95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 97.4%
+-commutative97.4%
mul-1-neg97.4%
log-rec97.4%
remove-double-neg97.4%
log-prod94.0%
Simplified94.0%
Final simplification97.2%
(FPCore (x) :precision binary32 (if (<= x -10.0) (copysign (- (log (/ -1.0 x))) x) (if (<= x 2.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -10.0f) {
tmp = copysignf(-logf((-1.0f / x)), x);
} else if (x <= 2.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(-10.0)) tmp = copysign(Float32(-log(Float32(Float32(-1.0) / x))), x); elseif (x <= Float32(2.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(-10.0)) tmp = sign(x) * abs(-log((single(-1.0) / x))); elseif (x <= single(2.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 -10:\\
\;\;\;\;\mathsf{copysign}\left(-\log \left(\frac{-1}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\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 < -10Initial program 59.3%
Taylor expanded in x around -inf 44.1%
if -10 < x < 2Initial program 20.0%
add-sqr-sqrt19.5%
pow219.5%
log-pow19.4%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt19.7%
+-commutative19.7%
hypot-1-def19.7%
Applied egg-rr19.7%
Taylor expanded in x around 0 16.7%
Taylor expanded in x around 0 97.3%
if 2 < x Initial program 48.4%
log1p-expm1-u48.4%
expm1-udef48.4%
add-exp-log48.5%
add-sqr-sqrt48.4%
fabs-sqr48.4%
add-sqr-sqrt48.5%
+-commutative48.5%
hypot-1-def95.9%
Applied egg-rr95.9%
sub-neg95.9%
+-commutative95.9%
metadata-eval95.9%
associate-+l+95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 97.4%
+-commutative97.4%
mul-1-neg97.4%
log-rec97.4%
remove-double-neg97.4%
log-prod94.0%
Simplified94.0%
Final simplification83.5%
(FPCore (x) :precision binary32 (if (<= x -2.0) (copysign (log (/ -0.5 x)) x) (if (<= x 2.0) (copysign x x) (copysign (log (* x 2.0)) x))))
float code(float x) {
float tmp;
if (x <= -2.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 2.0f) {
tmp = copysignf(x, x);
} else {
tmp = copysignf(logf((x * 2.0f)), x);
}
return tmp;
}
function code(x) tmp = Float32(0.0) if (x <= Float32(-2.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(2.0)) tmp = copysign(x, x); else tmp = copysign(log(Float32(x * Float32(2.0))), x); end return tmp end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-2.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(2.0)) tmp = sign(x) * abs(x); else tmp = sign(x) * abs(log((x * single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;\mathsf{copysign}\left(x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(x \cdot 2\right), x\right)\\
\end{array}
\end{array}
if x < -2Initial program 59.9%
*-un-lft-identity59.9%
*-commutative59.9%
log-prod59.9%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt12.6%
+-commutative12.6%
hypot-1-def12.6%
metadata-eval12.6%
Applied egg-rr12.6%
Taylor expanded in x around -inf 97.8%
if -2 < x < 2Initial program 19.4%
add-sqr-sqrt18.9%
pow218.9%
log-pow18.8%
add-sqr-sqrt11.7%
fabs-sqr11.7%
add-sqr-sqrt19.1%
+-commutative19.1%
hypot-1-def19.1%
Applied egg-rr19.1%
Taylor expanded in x around 0 16.8%
Taylor expanded in x around 0 97.9%
if 2 < x Initial program 48.4%
log1p-expm1-u48.4%
expm1-udef48.4%
add-exp-log48.5%
add-sqr-sqrt48.4%
fabs-sqr48.4%
add-sqr-sqrt48.5%
+-commutative48.5%
hypot-1-def95.9%
Applied egg-rr95.9%
sub-neg95.9%
+-commutative95.9%
metadata-eval95.9%
associate-+l+95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 97.4%
+-commutative97.4%
mul-1-neg97.4%
log-rec97.4%
remove-double-neg97.4%
log-prod94.0%
Simplified94.0%
Final simplification96.8%
(FPCore (x) :precision binary32 (if (<= x 2.0) (copysign x x) (copysign (log (* x 2.0)) x)))
float code(float x) {
float tmp;
if (x <= 2.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(2.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(2.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 2:\\
\;\;\;\;\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 < 2Initial program 33.0%
add-sqr-sqrt32.7%
pow232.7%
log-pow32.6%
add-sqr-sqrt7.8%
fabs-sqr7.8%
add-sqr-sqrt16.9%
+-commutative16.9%
hypot-1-def16.9%
Applied egg-rr16.9%
Taylor expanded in x around 0 11.2%
Taylor expanded in x around 0 68.7%
if 2 < x Initial program 48.4%
log1p-expm1-u48.4%
expm1-udef48.4%
add-exp-log48.5%
add-sqr-sqrt48.4%
fabs-sqr48.4%
add-sqr-sqrt48.5%
+-commutative48.5%
hypot-1-def95.9%
Applied egg-rr95.9%
sub-neg95.9%
+-commutative95.9%
metadata-eval95.9%
associate-+l+95.9%
Applied egg-rr95.9%
Taylor expanded in x around inf 97.4%
+-commutative97.4%
mul-1-neg97.4%
log-rec97.4%
remove-double-neg97.4%
log-prod94.0%
Simplified94.0%
Final simplification75.6%
(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 37.2%
add-sqr-sqrt36.9%
pow236.9%
log-pow36.9%
add-sqr-sqrt18.7%
fabs-sqr18.7%
add-sqr-sqrt25.4%
+-commutative25.4%
hypot-1-def38.1%
Applied egg-rr38.1%
Taylor expanded in x around 0 15.9%
Taylor expanded in x around 0 53.2%
Final simplification53.2%
(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 2023242
(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))