| Alternative 1 | |
|---|---|
| Error | 12.3 |
| Cost | 1488 |
(FPCore (x y z t) :precision binary64 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ (/ x (+ x 1.0)) (- (/ (- (/ y (+ x 1.0))) t))))
(t_2 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0))))
(if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 5e+279) t_2 t_1))))double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
double code(double x, double y, double z, double t) {
double t_1 = (x / (x + 1.0)) + -(-(y / (x + 1.0)) / t);
double t_2 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 5e+279) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
public static double code(double x, double y, double z, double t) {
double t_1 = (x / (x + 1.0)) + -(-(y / (x + 1.0)) / t);
double t_2 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 5e+279) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
def code(x, y, z, t): t_1 = (x / (x + 1.0)) + -(-(y / (x + 1.0)) / t) t_2 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 5e+279: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t) return Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) end
function code(x, y, z, t) t_1 = Float64(Float64(x / Float64(x + 1.0)) + Float64(-Float64(Float64(-Float64(y / Float64(x + 1.0))) / t))) t_2 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 5e+279) tmp = t_2; else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t) tmp = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); end
function tmp_2 = code(x, y, z, t) t_1 = (x / (x + 1.0)) + -(-(y / (x + 1.0)) / t); t_2 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 5e+279) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + (-N[((-N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]) / t), $MachinePrecision])), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+279], t$95$2, t$95$1]]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := \frac{x}{x + 1} + \left(-\frac{-\frac{y}{x + 1}}{t}\right)\\
t_2 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+279}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 7.1 |
|---|---|
| Target | 0.3 |
| Herbie | 1.9 |
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < -inf.0 or 5.0000000000000002e279 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) Initial program 62.0
Simplified62.0
[Start]62.0 | \[ \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\] |
|---|---|
rational_best.json-simplify-2 [=>]62.0 | \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1}
\] |
Applied egg-rr62.1
Taylor expanded in t around -inf 13.0
Simplified13.0
[Start]13.0 | \[ -1 \cdot \frac{-1 \cdot \frac{y}{1 + x} - -1 \cdot \frac{x}{\left(1 + x\right) \cdot z}}{t} + \frac{x}{1 + x}
\] |
|---|---|
rational_best.json-simplify-1 [=>]13.0 | \[ \color{blue}{\frac{x}{1 + x} + -1 \cdot \frac{-1 \cdot \frac{y}{1 + x} - -1 \cdot \frac{x}{\left(1 + x\right) \cdot z}}{t}}
\] |
rational_best.json-simplify-1 [=>]13.0 | \[ \frac{x}{\color{blue}{x + 1}} + -1 \cdot \frac{-1 \cdot \frac{y}{1 + x} - -1 \cdot \frac{x}{\left(1 + x\right) \cdot z}}{t}
\] |
rational_best.json-simplify-2 [=>]13.0 | \[ \frac{x}{x + 1} + \color{blue}{\frac{-1 \cdot \frac{y}{1 + x} - -1 \cdot \frac{x}{\left(1 + x\right) \cdot z}}{t} \cdot -1}
\] |
rational_best.json-simplify-12 [=>]13.0 | \[ \frac{x}{x + 1} + \color{blue}{\left(-\frac{-1 \cdot \frac{y}{1 + x} - -1 \cdot \frac{x}{\left(1 + x\right) \cdot z}}{t}\right)}
\] |
rational_best.json-simplify-2 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{-1 \cdot \frac{y}{1 + x} - \color{blue}{\frac{x}{\left(1 + x\right) \cdot z} \cdot -1}}{t}\right)
\] |
rational_best.json-simplify-12 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{-1 \cdot \frac{y}{1 + x} - \color{blue}{\left(-\frac{x}{\left(1 + x\right) \cdot z}\right)}}{t}\right)
\] |
rational_best.json-simplify-11 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{-1 \cdot \frac{y}{1 + x} - \color{blue}{\left(0 - \frac{x}{\left(1 + x\right) \cdot z}\right)}}{t}\right)
\] |
rational_best.json-simplify-46 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{\color{blue}{\frac{x}{\left(1 + x\right) \cdot z} + \left(-1 \cdot \frac{y}{1 + x} - 0\right)}}{t}\right)
\] |
rational_best.json-simplify-2 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{\frac{x}{\color{blue}{z \cdot \left(1 + x\right)}} + \left(-1 \cdot \frac{y}{1 + x} - 0\right)}{t}\right)
\] |
rational_best.json-simplify-1 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{\frac{x}{z \cdot \color{blue}{\left(x + 1\right)}} + \left(-1 \cdot \frac{y}{1 + x} - 0\right)}{t}\right)
\] |
rational_best.json-simplify-6 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{\frac{x}{z \cdot \left(x + 1\right)} + \color{blue}{-1 \cdot \frac{y}{1 + x}}}{t}\right)
\] |
rational_best.json-simplify-2 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{\frac{x}{z \cdot \left(x + 1\right)} + \color{blue}{\frac{y}{1 + x} \cdot -1}}{t}\right)
\] |
rational_best.json-simplify-12 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{\frac{x}{z \cdot \left(x + 1\right)} + \color{blue}{\left(-\frac{y}{1 + x}\right)}}{t}\right)
\] |
rational_best.json-simplify-1 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{\frac{x}{z \cdot \left(x + 1\right)} + \left(-\frac{y}{\color{blue}{x + 1}}\right)}{t}\right)
\] |
Taylor expanded in z around inf 13.0
Simplified13.0
[Start]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{-1 \cdot \frac{y}{1 + x}}{t}\right)
\] |
|---|---|
rational_best.json-simplify-2 [=>]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{\color{blue}{\frac{y}{1 + x} \cdot -1}}{t}\right)
\] |
rational_best.json-simplify-1 [<=]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{\frac{y}{\color{blue}{x + 1}} \cdot -1}{t}\right)
\] |
rational_best.json-simplify-13 [<=]13.0 | \[ \frac{x}{x + 1} + \left(-\frac{\color{blue}{-\frac{y}{x + 1}}}{t}\right)
\] |
if -inf.0 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 5.0000000000000002e279Initial program 0.6
Final simplification1.9
| Alternative 1 | |
|---|---|
| Error | 12.3 |
| Cost | 1488 |
| Alternative 2 | |
|---|---|
| Error | 12.2 |
| Cost | 1424 |
| Alternative 3 | |
|---|---|
| Error | 12.3 |
| Cost | 1424 |
| Alternative 4 | |
|---|---|
| Error | 12.3 |
| Cost | 1296 |
| Alternative 5 | |
|---|---|
| Error | 12.4 |
| Cost | 1032 |
| Alternative 6 | |
|---|---|
| Error | 14.9 |
| Cost | 840 |
| Alternative 7 | |
|---|---|
| Error | 21.6 |
| Cost | 780 |
| Alternative 8 | |
|---|---|
| Error | 21.2 |
| Cost | 588 |
| Alternative 9 | |
|---|---|
| Error | 21.2 |
| Cost | 456 |
| Alternative 10 | |
|---|---|
| Error | 27.6 |
| Cost | 328 |
| Alternative 11 | |
|---|---|
| Error | 29.0 |
| Cost | 64 |
herbie shell --seed 2023089
(FPCore (x y z t)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, A"
:precision binary64
:herbie-target
(/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1.0))
(/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))