| Alternative 1 | |
|---|---|
| Error | 13.3 |
| Cost | 13192 |
(FPCore (x) :precision binary32 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
(FPCore (x)
:precision binary32
(if (<= x -19999999961012896000.0)
(copysign (log (/ -0.5 x)) x)
(if (<= x 1.0)
(copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)
(copysign (log (+ (fabs x) (+ x (/ 0.5 x)))) x))))float code(float x) {
return copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
}
float code(float x) {
float tmp;
if (x <= -19999999961012896000.0f) {
tmp = copysignf(logf((-0.5f / x)), x);
} else if (x <= 1.0f) {
tmp = copysignf(logf((fabsf(x) + sqrtf(((x * x) + 1.0f)))), x);
} else {
tmp = copysignf(logf((fabsf(x) + (x + (0.5f / x)))), x);
}
return tmp;
}
function code(x) return copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x) end
function code(x) tmp = Float32(0.0) if (x <= Float32(-19999999961012896000.0)) tmp = copysign(log(Float32(Float32(-0.5) / x)), x); elseif (x <= Float32(1.0)) tmp = copysign(log(Float32(abs(x) + sqrt(Float32(Float32(x * x) + Float32(1.0))))), x); else tmp = copysign(log(Float32(abs(x) + Float32(x + Float32(Float32(0.5) / x)))), x); end return tmp end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); end
function tmp_2 = code(x) tmp = single(0.0); if (x <= single(-19999999961012896000.0)) tmp = sign(x) * abs(log((single(-0.5) / x))); elseif (x <= single(1.0)) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + single(1.0)))))); else tmp = sign(x) * abs(log((abs(x) + (x + (single(0.5) / x))))); end tmp_2 = tmp; end
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\begin{array}{l}
\mathbf{if}\;x \leq -19999999961012896000:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{x}\right)\right), x\right)\\
\end{array}
| Original | 20.5 |
|---|---|
| Target | 0.2 |
| Herbie | 12.6 |
if x < -2e19Initial program 32.0
Taylor expanded in x around -inf 0.5
Simplified0.5
[Start]0.5 | \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| + -1 \cdot x\right) - 0.5 \cdot \frac{1}{x}\right), x\right)
\] |
|---|---|
rational.json-simplify-2 [=>]0.5 | \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| + \color{blue}{x \cdot -1}\right) - 0.5 \cdot \frac{1}{x}\right), x\right)
\] |
rational.json-simplify-8 [<=]0.5 | \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| + \color{blue}{\left(-x\right)}\right) - 0.5 \cdot \frac{1}{x}\right), x\right)
\] |
Taylor expanded in x around 0 0.0
if -2e19 < x < 1Initial program 19.9
if 1 < x Initial program 15.9
Applied egg-rr15.9
Simplified15.9
[Start]15.9 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\left(x \cdot x\right) \cdot \left(1 + \frac{1}{x \cdot x}\right)}\right), x\right)
\] |
|---|---|
rational.json-simplify-2 [=>]15.9 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{\left(1 + \frac{1}{x \cdot x}\right) \cdot \left(x \cdot x\right)}}\right), x\right)
\] |
rational.json-simplify-43 [=>]15.9 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{\color{blue}{x \cdot \left(x \cdot \left(1 + \frac{1}{x \cdot x}\right)\right)}}\right), x\right)
\] |
Applied egg-rr15.9
Simplified15.9
[Start]15.9 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot \left(x \cdot \left(1 + \frac{2}{x} \cdot \frac{1}{x + x}\right)\right)}\right), x\right)
\] |
|---|---|
metadata-eval [<=]15.9 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot \left(x \cdot \left(1 + \frac{2}{x} \cdot \frac{\color{blue}{0.5 + 0.5}}{x + x}\right)\right)}\right), x\right)
\] |
rational.json-simplify-35 [<=]15.9 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot \left(x \cdot \left(1 + \frac{2}{x} \cdot \color{blue}{\frac{0.5}{x}}\right)\right)}\right), x\right)
\] |
Taylor expanded in x around inf 0.6
Simplified0.6
[Start]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(0.5 \cdot \frac{1}{x} + x\right)\right), x\right)
\] |
|---|---|
rational.json-simplify-1 [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \color{blue}{\left(x + 0.5 \cdot \frac{1}{x}\right)}\right), x\right)
\] |
metadata-eval [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + 0.5 \cdot \frac{\color{blue}{\frac{-1}{-1}}}{x}\right)\right), x\right)
\] |
rational.json-simplify-44 [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + 0.5 \cdot \color{blue}{\frac{\frac{-1}{x}}{-1}}\right)\right), x\right)
\] |
rational.json-simplify-10 [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + 0.5 \cdot \color{blue}{\left(-\frac{-1}{x}\right)}\right)\right), x\right)
\] |
rational.json-simplify-8 [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + 0.5 \cdot \color{blue}{\left(\frac{-1}{x} \cdot -1\right)}\right)\right), x\right)
\] |
rational.json-simplify-43 [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \color{blue}{\frac{-1}{x} \cdot \left(-1 \cdot 0.5\right)}\right)\right), x\right)
\] |
metadata-eval [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{-1}{x} \cdot \color{blue}{-0.5}\right)\right), x\right)
\] |
metadata-eval [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{-1}{x} \cdot \color{blue}{\frac{-1}{2}}\right)\right), x\right)
\] |
rational.json-simplify-49 [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \color{blue}{\frac{-1 \cdot \frac{-1}{x}}{2}}\right)\right), x\right)
\] |
rational.json-simplify-2 [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{\color{blue}{\frac{-1}{x} \cdot -1}}{2}\right)\right), x\right)
\] |
rational.json-simplify-8 [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{\color{blue}{-\frac{-1}{x}}}{2}\right)\right), x\right)
\] |
rational.json-simplify-10 [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{\color{blue}{\frac{\frac{-1}{x}}{-1}}}{2}\right)\right), x\right)
\] |
rational.json-simplify-46 [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{\color{blue}{\frac{-1}{x \cdot -1}}}{2}\right)\right), x\right)
\] |
rational.json-simplify-8 [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{\frac{-1}{\color{blue}{-x}}}{2}\right)\right), x\right)
\] |
rational.json-simplify-46 [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \color{blue}{\frac{-1}{\left(-x\right) \cdot 2}}\right)\right), x\right)
\] |
rational.json-simplify-2 [<=]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{-1}{\color{blue}{2 \cdot \left(-x\right)}}\right)\right), x\right)
\] |
rational.json-simplify-46 [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \color{blue}{\frac{\frac{-1}{2}}{-x}}\right)\right), x\right)
\] |
metadata-eval [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{\color{blue}{-0.5}}{-x}\right)\right), x\right)
\] |
rational.json-simplify-12 [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{-0.5}{\color{blue}{0 - x}}\right)\right), x\right)
\] |
rational.json-simplify-50 [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \color{blue}{\frac{--0.5}{x - 0}}\right)\right), x\right)
\] |
metadata-eval [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{\color{blue}{0.5}}{x - 0}\right)\right), x\right)
\] |
rational.json-simplify-5 [=>]0.6 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| + \left(x + \frac{0.5}{\color{blue}{x}}\right)\right), x\right)
\] |
Final simplification12.6
| Alternative 1 | |
|---|---|
| Error | 13.3 |
| Cost | 13192 |
| Alternative 2 | |
|---|---|
| Error | 13.3 |
| Cost | 9992 |
| Alternative 3 | |
|---|---|
| Error | 13.3 |
| Cost | 9864 |
| Alternative 4 | |
|---|---|
| Error | 18.9 |
| Cost | 6596 |
| Alternative 5 | |
|---|---|
| Error | 14.7 |
| Cost | 6596 |
| Alternative 6 | |
|---|---|
| Error | 23.3 |
| Cost | 6564 |
| Alternative 7 | |
|---|---|
| Error | 27.7 |
| Cost | 6464 |
herbie shell --seed 2023067
(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))