| Alternative 1 | |
|---|---|
| Error | 10.9 |
| Cost | 976 |
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (/ (* y (- z x)) t))))
(if (<= t_1 (- INFINITY))
(* x (- 1.0 (/ y t)))
(if (<= t_1 5e+234)
(+ x (/ (- (* y z) (* y x)) t))
(+ x (+ (- (/ (* y x) t)) (* z (/ y t))))))))double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
double code(double x, double y, double z, double t) {
double t_1 = x + ((y * (z - x)) / t);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x * (1.0 - (y / t));
} else if (t_1 <= 5e+234) {
tmp = x + (((y * z) - (y * x)) / t);
} else {
tmp = x + (-((y * x) / t) + (z * (y / t)));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((y * (z - x)) / t);
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = x * (1.0 - (y / t));
} else if (t_1 <= 5e+234) {
tmp = x + (((y * z) - (y * x)) / t);
} else {
tmp = x + (-((y * x) / t) + (z * (y / t)));
}
return tmp;
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
def code(x, y, z, t): t_1 = x + ((y * (z - x)) / t) tmp = 0 if t_1 <= -math.inf: tmp = x * (1.0 - (y / t)) elif t_1 <= 5e+234: tmp = x + (((y * z) - (y * x)) / t) else: tmp = x + (-((y * x) / t) + (z * (y / t))) return tmp
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(y * Float64(z - x)) / t)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x * Float64(1.0 - Float64(y / t))); elseif (t_1 <= 5e+234) tmp = Float64(x + Float64(Float64(Float64(y * z) - Float64(y * x)) / t)); else tmp = Float64(x + Float64(Float64(-Float64(Float64(y * x) / t)) + Float64(z * Float64(y / t)))); end return tmp end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
function tmp_2 = code(x, y, z, t) t_1 = x + ((y * (z - x)) / t); tmp = 0.0; if (t_1 <= -Inf) tmp = x * (1.0 - (y / t)); elseif (t_1 <= 5e+234) tmp = x + (((y * z) - (y * x)) / t); else tmp = x + (-((y * x) / t) + (z * (y / t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x * N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+234], N[(x + N[(N[(N[(y * z), $MachinePrecision] - N[(y * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[((-N[(N[(y * x), $MachinePrecision] / t), $MachinePrecision]) + N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+234}:\\
\;\;\;\;x + \frac{y \cdot z - y \cdot x}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \frac{y}{t}\right)\\
\end{array}
Results
| Original | 6.6 |
|---|---|
| Target | 2.0 |
| Herbie | 4.0 |
if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -inf.0Initial program 64.0
Taylor expanded in z around 0 62.3
Simplified62.3
[Start]62.3 | \[ x + \frac{-1 \cdot \left(y \cdot x\right)}{t}
\] |
|---|---|
rational.json-simplify-43 [=>]62.3 | \[ x + \frac{\color{blue}{y \cdot \left(x \cdot -1\right)}}{t}
\] |
rational.json-simplify-9 [=>]62.3 | \[ x + \frac{y \cdot \color{blue}{\left(-x\right)}}{t}
\] |
Taylor expanded in x around -inf 27.9
Simplified27.9
[Start]27.9 | \[ -1 \cdot \left(\left(\frac{y}{t} - 1\right) \cdot x\right)
\] |
|---|---|
rational.json-simplify-43 [=>]27.9 | \[ \color{blue}{\left(\frac{y}{t} - 1\right) \cdot \left(x \cdot -1\right)}
\] |
rational.json-simplify-16 [=>]27.9 | \[ \color{blue}{\left(\frac{y}{t} + -1\right)} \cdot \left(x \cdot -1\right)
\] |
rational.json-simplify-8 [<=]27.9 | \[ \left(\frac{y}{t} + -1\right) \cdot \color{blue}{\left(-x\right)}
\] |
rational.json-simplify-12 [=>]27.9 | \[ \left(\frac{y}{t} + -1\right) \cdot \color{blue}{\left(0 - x\right)}
\] |
rational.json-simplify-51 [=>]27.9 | \[ \color{blue}{\left(x - 0\right) \cdot \left(1 - \frac{y}{t}\right)}
\] |
rational.json-simplify-5 [=>]27.9 | \[ \color{blue}{x} \cdot \left(1 - \frac{y}{t}\right)
\] |
if -inf.0 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 5.0000000000000003e234Initial program 0.9
Taylor expanded in z around 0 0.9
Applied egg-rr0.9
if 5.0000000000000003e234 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) Initial program 24.6
Taylor expanded in z around 0 24.6
Applied egg-rr24.6
Applied egg-rr56.2
Simplified55.2
[Start]56.2 | \[ x + \frac{\left(y \cdot \left(y \cdot \left(\left(z - x\right) \cdot \left(z - x\right)\right)\right)\right) \cdot \frac{-1}{y \cdot \left(x - z\right)}}{t}
\] |
|---|---|
rational.json-simplify-2 [=>]56.2 | \[ x + \frac{\color{blue}{\frac{-1}{y \cdot \left(x - z\right)} \cdot \left(y \cdot \left(y \cdot \left(\left(z - x\right) \cdot \left(z - x\right)\right)\right)\right)}}{t}
\] |
rational.json-simplify-43 [<=]57.1 | \[ x + \frac{\frac{-1}{y \cdot \left(x - z\right)} \cdot \color{blue}{\left(\left(\left(z - x\right) \cdot \left(z - x\right)\right) \cdot \left(y \cdot y\right)\right)}}{t}
\] |
rational.json-simplify-43 [=>]55.2 | \[ x + \frac{\color{blue}{\left(\left(z - x\right) \cdot \left(z - x\right)\right) \cdot \left(\left(y \cdot y\right) \cdot \frac{-1}{y \cdot \left(x - z\right)}\right)}}{t}
\] |
Taylor expanded in z around 0 17.3
Simplified17.2
[Start]17.3 | \[ x + \left(-1 \cdot \left(z \cdot \left(-2 \cdot \frac{y}{t} - -1 \cdot \frac{y}{t}\right)\right) + -1 \cdot \frac{y \cdot x}{t}\right)
\] |
|---|---|
rational.json-simplify-1 [=>]17.3 | \[ x + \color{blue}{\left(-1 \cdot \frac{y \cdot x}{t} + -1 \cdot \left(z \cdot \left(-2 \cdot \frac{y}{t} - -1 \cdot \frac{y}{t}\right)\right)\right)}
\] |
rational.json-simplify-2 [=>]17.3 | \[ x + \left(\color{blue}{\frac{y \cdot x}{t} \cdot -1} + -1 \cdot \left(z \cdot \left(-2 \cdot \frac{y}{t} - -1 \cdot \frac{y}{t}\right)\right)\right)
\] |
rational.json-simplify-9 [=>]17.3 | \[ x + \left(\color{blue}{\left(-\frac{y \cdot x}{t}\right)} + -1 \cdot \left(z \cdot \left(-2 \cdot \frac{y}{t} - -1 \cdot \frac{y}{t}\right)\right)\right)
\] |
rational.json-simplify-43 [=>]17.3 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + \color{blue}{z \cdot \left(\left(-2 \cdot \frac{y}{t} - -1 \cdot \frac{y}{t}\right) \cdot -1\right)}\right)
\] |
rational.json-simplify-9 [=>]17.3 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \color{blue}{\left(-\left(-2 \cdot \frac{y}{t} - -1 \cdot \frac{y}{t}\right)\right)}\right)
\] |
rational.json-simplify-12 [=>]17.3 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \color{blue}{\left(0 - \left(-2 \cdot \frac{y}{t} - -1 \cdot \frac{y}{t}\right)\right)}\right)
\] |
rational.json-simplify-2 [=>]17.3 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \left(0 - \left(\color{blue}{\frac{y}{t} \cdot -2} - -1 \cdot \frac{y}{t}\right)\right)\right)
\] |
rational.json-simplify-48 [=>]17.2 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \left(0 - \color{blue}{\frac{y}{t} \cdot \left(-2 - -1\right)}\right)\right)
\] |
metadata-eval [=>]17.2 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \left(0 - \frac{y}{t} \cdot \color{blue}{-1}\right)\right)
\] |
rational.json-simplify-9 [=>]17.2 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \left(0 - \color{blue}{\left(-\frac{y}{t}\right)}\right)\right)
\] |
rational.json-simplify-12 [=>]17.2 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \left(0 - \color{blue}{\left(0 - \frac{y}{t}\right)}\right)\right)
\] |
rational.json-simplify-44 [=>]17.2 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \color{blue}{\left(\frac{y}{t} - \left(0 - 0\right)\right)}\right)
\] |
metadata-eval [=>]17.2 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \left(\frac{y}{t} - \color{blue}{0}\right)\right)
\] |
rational.json-simplify-5 [=>]17.2 | \[ x + \left(\left(-\frac{y \cdot x}{t}\right) + z \cdot \color{blue}{\frac{y}{t}}\right)
\] |
Final simplification4.0
| Alternative 1 | |
|---|---|
| Error | 10.9 |
| Cost | 976 |
| Alternative 2 | |
|---|---|
| Error | 6.0 |
| Cost | 836 |
| Alternative 3 | |
|---|---|
| Error | 10.5 |
| Cost | 712 |
| Alternative 4 | |
|---|---|
| Error | 6.0 |
| Cost | 708 |
| Alternative 5 | |
|---|---|
| Error | 30.3 |
| Cost | 648 |
| Alternative 6 | |
|---|---|
| Error | 21.7 |
| Cost | 448 |
| Alternative 7 | |
|---|---|
| Error | 32.1 |
| Cost | 64 |
herbie shell --seed 2023077
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:herbie-target
(- x (+ (* x (/ y t)) (* (- z) (/ y t))))
(+ x (/ (* y (- z x)) t)))