| Alternative 1 | |
|---|---|
| Error | 30.0 |
| Cost | 78472 |
(FPCore (x) :precision binary64 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x))
(FPCore (x)
:precision binary64
(let* ((t_0 (copysign (log (+ (fabs x) (sqrt (+ (* x x) 1.0)))) x)))
(if (<= t_0 (- INFINITY))
(copysign (log (/ -0.5 x)) x)
(if (<= t_0 10.0)
(copysign (log (+ (+ (fabs x) 1.0) (+ (sqrt (+ 1.0 (* x x))) -1.0))) x)
(copysign (log (+ (/ 0.5 x) (+ x (fabs x)))) x)))))double code(double x) {
return copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
}
double code(double x) {
double t_0 = copysign(log((fabs(x) + sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = copysign(log((-0.5 / x)), x);
} else if (t_0 <= 10.0) {
tmp = copysign(log(((fabs(x) + 1.0) + (sqrt((1.0 + (x * x))) + -1.0))), x);
} else {
tmp = copysign(log(((0.5 / x) + (x + fabs(x)))), x);
}
return tmp;
}
public static double code(double x) {
return Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
}
public static double code(double x) {
double t_0 = Math.copySign(Math.log((Math.abs(x) + Math.sqrt(((x * x) + 1.0)))), x);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = Math.copySign(Math.log((-0.5 / x)), x);
} else if (t_0 <= 10.0) {
tmp = Math.copySign(Math.log(((Math.abs(x) + 1.0) + (Math.sqrt((1.0 + (x * x))) + -1.0))), x);
} else {
tmp = Math.copySign(Math.log(((0.5 / x) + (x + Math.abs(x)))), x);
}
return tmp;
}
def code(x): return math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x)
def code(x): t_0 = math.copysign(math.log((math.fabs(x) + math.sqrt(((x * x) + 1.0)))), x) tmp = 0 if t_0 <= -math.inf: tmp = math.copysign(math.log((-0.5 / x)), x) elif t_0 <= 10.0: tmp = math.copysign(math.log(((math.fabs(x) + 1.0) + (math.sqrt((1.0 + (x * x))) + -1.0))), x) else: tmp = math.copysign(math.log(((0.5 / x) + (x + math.fabs(x)))), x) return tmp
function code(x) return copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) end
function code(x) t_0 = copysign(log(Float64(abs(x) + sqrt(Float64(Float64(x * x) + 1.0)))), x) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = copysign(log(Float64(-0.5 / x)), x); elseif (t_0 <= 10.0) tmp = copysign(log(Float64(Float64(abs(x) + 1.0) + Float64(sqrt(Float64(1.0 + Float64(x * x))) + -1.0))), x); else tmp = copysign(log(Float64(Float64(0.5 / x) + Float64(x + abs(x)))), x); end return tmp end
function tmp = code(x) tmp = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0))))); end
function tmp_2 = code(x) t_0 = sign(x) * abs(log((abs(x) + sqrt(((x * x) + 1.0))))); tmp = 0.0; if (t_0 <= -Inf) tmp = sign(x) * abs(log((-0.5 / x))); elseif (t_0 <= 10.0) tmp = sign(x) * abs(log(((abs(x) + 1.0) + (sqrt((1.0 + (x * x))) + -1.0)))); else tmp = sign(x) * abs(log(((0.5 / x) + (x + abs(x))))); end tmp_2 = tmp; end
code[x_] := N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x_] := Block[{t$95$0 = N[With[{TMP1 = Abs[N[Log[N[(N[Abs[x], $MachinePrecision] + N[Sqrt[N[(N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[With[{TMP1 = Abs[N[Log[N[(-0.5 / x), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], If[LessEqual[t$95$0, 10.0], N[With[{TMP1 = Abs[N[Log[N[(N[(N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision] + N[(N[Sqrt[N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], N[With[{TMP1 = Abs[N[Log[N[(N[(0.5 / x), $MachinePrecision] + N[(x + N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]]]]
\mathsf{copysign}\left(\log \left(\left|x\right| + \sqrt{x \cdot x + 1}\right), x\right)
\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 -\infty:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{-0.5}{x}\right), x\right)\\
\mathbf{elif}\;t_0 \leq 10:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\left(\left|x\right| + 1\right) + \left(\sqrt{1 + x \cdot x} + -1\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \left(x + \left|x\right|\right)\right), x\right)\\
\end{array}
| Original | 45.6 |
|---|---|
| Target | 0.0 |
| Herbie | 30.0 |
if (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < -inf.0Initial program 64.0
Applied egg-rr64.0
Taylor expanded in x around -inf 0
Simplified0
[Start]0 | \[ \mathsf{copysign}\left(\log \left(\left(-1 \cdot x + 0.5 \cdot \left|x\right|\right) - \left(0.5 \cdot \frac{1}{x} + -0.5 \cdot \left|x\right|\right)\right), x\right)
\] |
|---|---|
rational_best-simplify-3 [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left(-1 \cdot x + 0.5 \cdot \left|x\right|\right) - \color{blue}{\left(-0.5 \cdot \left|x\right| + 0.5 \cdot \frac{1}{x}\right)}\right), x\right)
\] |
rational_best-simplify-57 [=>]0 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(\left(\left(-1 \cdot x + 0.5 \cdot \left|x\right|\right) - -0.5 \cdot \left|x\right|\right) + \left(-0.5 \cdot \frac{1}{x}\right)\right)}, x\right)
\] |
rational_best-simplify-59 [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left(\color{blue}{\left(0.5 \cdot \left|x\right| - \left(--1 \cdot x\right)\right)} - -0.5 \cdot \left|x\right|\right) + \left(-0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
rational_best-simplify-1 [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left(\left(\color{blue}{\left|x\right| \cdot 0.5} - \left(--1 \cdot x\right)\right) - -0.5 \cdot \left|x\right|\right) + \left(-0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
rational_best-simplify-48 [<=]0 | \[ \mathsf{copysign}\left(\log \left(\color{blue}{\left(\left(\left|x\right| \cdot 0.5 - -0.5 \cdot \left|x\right|\right) - \left(--1 \cdot x\right)\right)} + \left(-0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
rational_best-simplify-1 [<=]0 | \[ \mathsf{copysign}\left(\log \left(\left(\left(\color{blue}{0.5 \cdot \left|x\right|} - -0.5 \cdot \left|x\right|\right) - \left(--1 \cdot x\right)\right) + \left(-0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
rational_best-simplify-1 [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left(\left(0.5 \cdot \left|x\right| - \color{blue}{\left|x\right| \cdot -0.5}\right) - \left(--1 \cdot x\right)\right) + \left(-0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
rational_best-simplify-62 [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left(\color{blue}{\left|x\right| \cdot \left(0.5 - -0.5\right)} - \left(--1 \cdot x\right)\right) + \left(-0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
metadata-eval [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| \cdot \color{blue}{1} - \left(--1 \cdot x\right)\right) + \left(-0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
rational_best-simplify-7 [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left(\color{blue}{\left|x\right|} - \left(--1 \cdot x\right)\right) + \left(-0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
rational_best-simplify-56 [=>]0 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(\left|x\right| - \left(\left(--1 \cdot x\right) + 0.5 \cdot \frac{1}{x}\right)\right)}, x\right)
\] |
rational_best-simplify-14 [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\color{blue}{\left(0 - -1 \cdot x\right)} + 0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
metadata-eval [<=]0 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\left(\color{blue}{\frac{0}{-1}} - -1 \cdot x\right) + 0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
rational_best-simplify-37 [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\color{blue}{\frac{x}{\frac{-1}{-1}}} + 0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
metadata-eval [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\frac{x}{\color{blue}{1}} + 0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
rational_best-simplify-8 [=>]0 | \[ \mathsf{copysign}\left(\log \left(\left|x\right| - \left(\color{blue}{x} + 0.5 \cdot \frac{1}{x}\right)\right), x\right)
\] |
Taylor expanded in x around 0 0
if -inf.0 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) < 10Initial program 47.1
Applied egg-rr47.2
Applied egg-rr47.2
Simplified47.1
[Start]47.2 | \[ \mathsf{copysign}\left(\log \left(\left(-1 - \left(-\left|x\right|\right)\right) + \left(1 - \left(-\sqrt{x \cdot x + 1}\right)\right)\right), x\right)
\] |
|---|---|
rational_best-simplify-14 [=>]47.2 | \[ \mathsf{copysign}\left(\log \left(\left(-1 - \color{blue}{\left(0 - \left|x\right|\right)}\right) + \left(1 - \left(-\sqrt{x \cdot x + 1}\right)\right)\right), x\right)
\] |
rational_best-simplify-51 [=>]47.2 | \[ \mathsf{copysign}\left(\log \left(\color{blue}{\left(\left|x\right| - \left(0 - -1\right)\right)} + \left(1 - \left(-\sqrt{x \cdot x + 1}\right)\right)\right), x\right)
\] |
metadata-eval [=>]47.2 | \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| - \color{blue}{1}\right) + \left(1 - \left(-\sqrt{x \cdot x + 1}\right)\right)\right), x\right)
\] |
rational_best-simplify-85 [=>]47.1 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(\left(\left|x\right| + \left|x\right|\right) - \left(\left(-\sqrt{x \cdot x + 1}\right) + \left|x\right|\right)\right)}, x\right)
\] |
rational_best-simplify-85 [<=]47.1 | \[ \mathsf{copysign}\left(\log \color{blue}{\left(\left(\left|x\right| - -1\right) + \left(-1 - \left(-\sqrt{x \cdot x + 1}\right)\right)\right)}, x\right)
\] |
rational_best-simplify-20 [=>]47.1 | \[ \mathsf{copysign}\left(\log \left(\color{blue}{\left(\left|x\right| + 1\right)} + \left(-1 - \left(-\sqrt{x \cdot x + 1}\right)\right)\right), x\right)
\] |
rational_best-simplify-14 [=>]47.1 | \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| + 1\right) + \left(-1 - \color{blue}{\left(0 - \sqrt{x \cdot x + 1}\right)}\right)\right), x\right)
\] |
rational_best-simplify-51 [=>]47.1 | \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| + 1\right) + \color{blue}{\left(\sqrt{x \cdot x + 1} - \left(0 - -1\right)\right)}\right), x\right)
\] |
metadata-eval [=>]47.1 | \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| + 1\right) + \left(\sqrt{x \cdot x + 1} - \color{blue}{1}\right)\right), x\right)
\] |
rational_best-simplify-18 [=>]47.1 | \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| + 1\right) + \color{blue}{\left(\sqrt{x \cdot x + 1} + -1\right)}\right), x\right)
\] |
rational_best-simplify-3 [=>]47.1 | \[ \mathsf{copysign}\left(\log \left(\left(\left|x\right| + 1\right) + \left(\sqrt{\color{blue}{1 + x \cdot x}} + -1\right)\right), x\right)
\] |
if 10 < (copysign.f64 (log.f64 (+.f64 (fabs.f64 x) (sqrt.f64 (+.f64 (*.f64 x x) 1)))) x) Initial program 31.8
Taylor expanded in x around inf 0.1
Simplified0.1
[Start]0.1 | \[ \mathsf{copysign}\left(\log \left(0.5 \cdot \frac{1}{x} + \left(\left|x\right| + x\right)\right), x\right)
\] |
|---|---|
rational_best-simplify-55 [=>]0.1 | \[ \mathsf{copysign}\left(\log \left(\color{blue}{1 \cdot \frac{0.5}{x}} + \left(\left|x\right| + x\right)\right), x\right)
\] |
rational_best-simplify-1 [=>]0.1 | \[ \mathsf{copysign}\left(\log \left(\color{blue}{\frac{0.5}{x} \cdot 1} + \left(\left|x\right| + x\right)\right), x\right)
\] |
rational_best-simplify-7 [=>]0.1 | \[ \mathsf{copysign}\left(\log \left(\color{blue}{\frac{0.5}{x}} + \left(\left|x\right| + x\right)\right), x\right)
\] |
rational_best-simplify-3 [=>]0.1 | \[ \mathsf{copysign}\left(\log \left(\frac{0.5}{x} + \color{blue}{\left(x + \left|x\right|\right)}\right), x\right)
\] |
Final simplification30.0
| Alternative 1 | |
|---|---|
| Error | 30.0 |
| Cost | 78472 |
| Alternative 2 | |
|---|---|
| Error | 31.1 |
| Cost | 20100 |
| Alternative 3 | |
|---|---|
| Error | 31.2 |
| Cost | 19844 |
| Alternative 4 | |
|---|---|
| Error | 31.1 |
| Cost | 19844 |
| Alternative 5 | |
|---|---|
| Error | 41.7 |
| Cost | 13188 |
| Alternative 6 | |
|---|---|
| Error | 31.2 |
| Cost | 13188 |
| Alternative 7 | |
|---|---|
| Error | 52.4 |
| Cost | 13124 |
| Alternative 8 | |
|---|---|
| Error | 58.3 |
| Cost | 12928 |
herbie shell --seed 2023099
(FPCore (x)
:name "Rust f64::asinh"
:precision binary64
: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))