| Alternative 1 | |
|---|---|
| Error | 2.6 |
| Cost | 5840 |
(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 (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
(t_2 (+ (/ y t) x)))
(if (<= t_1 (- INFINITY))
(/ t_2 (+ x 1.0))
(if (<= t_1 -1e+69)
(/ (* z y) (* (- (+ x (* t z)) (* x 2.0)) (+ x 1.0)))
(if (<= t_1 5e-79)
(/ (- t_2 (/ x (* t z))) (+ x 1.0))
(if (<= t_1 2e+268)
t_1
(+
(/ x (+ x 1.0))
(- (/ (- (- (/ y (+ x 1.0)) (/ x (* z (+ x 1.0))))) t)))))))))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 + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double t_2 = (y / t) + x;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2 / (x + 1.0);
} else if (t_1 <= -1e+69) {
tmp = (z * y) / (((x + (t * z)) - (x * 2.0)) * (x + 1.0));
} else if (t_1 <= 5e-79) {
tmp = (t_2 - (x / (t * z))) / (x + 1.0);
} else if (t_1 <= 2e+268) {
tmp = t_1;
} else {
tmp = (x / (x + 1.0)) + -(-((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t);
}
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 + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
double t_2 = (y / t) + x;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = t_2 / (x + 1.0);
} else if (t_1 <= -1e+69) {
tmp = (z * y) / (((x + (t * z)) - (x * 2.0)) * (x + 1.0));
} else if (t_1 <= 5e-79) {
tmp = (t_2 - (x / (t * z))) / (x + 1.0);
} else if (t_1 <= 2e+268) {
tmp = t_1;
} else {
tmp = (x / (x + 1.0)) + -(-((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t);
}
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 + (((y * z) - x) / ((t * z) - x))) / (x + 1.0) t_2 = (y / t) + x tmp = 0 if t_1 <= -math.inf: tmp = t_2 / (x + 1.0) elif t_1 <= -1e+69: tmp = (z * y) / (((x + (t * z)) - (x * 2.0)) * (x + 1.0)) elif t_1 <= 5e-79: tmp = (t_2 - (x / (t * z))) / (x + 1.0) elif t_1 <= 2e+268: tmp = t_1 else: tmp = (x / (x + 1.0)) + -(-((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t) 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(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0)) t_2 = Float64(Float64(y / t) + x) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(t_2 / Float64(x + 1.0)); elseif (t_1 <= -1e+69) tmp = Float64(Float64(z * y) / Float64(Float64(Float64(x + Float64(t * z)) - Float64(x * 2.0)) * Float64(x + 1.0))); elseif (t_1 <= 5e-79) tmp = Float64(Float64(t_2 - Float64(x / Float64(t * z))) / Float64(x + 1.0)); elseif (t_1 <= 2e+268) tmp = t_1; else tmp = Float64(Float64(x / Float64(x + 1.0)) + Float64(-Float64(Float64(-Float64(Float64(y / Float64(x + 1.0)) - Float64(x / Float64(z * Float64(x + 1.0))))) / t))); 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 + (((y * z) - x) / ((t * z) - x))) / (x + 1.0); t_2 = (y / t) + x; tmp = 0.0; if (t_1 <= -Inf) tmp = t_2 / (x + 1.0); elseif (t_1 <= -1e+69) tmp = (z * y) / (((x + (t * z)) - (x * 2.0)) * (x + 1.0)); elseif (t_1 <= 5e-79) tmp = (t_2 - (x / (t * z))) / (x + 1.0); elseif (t_1 <= 2e+268) tmp = t_1; else tmp = (x / (x + 1.0)) + -(-((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t); 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[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(t$95$2 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e+69], N[(N[(z * y), $MachinePrecision] / N[(N[(N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision] - N[(x * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-79], N[(N[(t$95$2 - N[(x / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+268], t$95$1, N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + (-N[((-N[(N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x / N[(z * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) / t), $MachinePrecision])), $MachinePrecision]]]]]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\
t_2 := \frac{y}{t} + x\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{t_2}{x + 1}\\
\mathbf{elif}\;t_1 \leq -1 \cdot 10^{+69}:\\
\;\;\;\;\frac{z \cdot y}{\left(\left(x + t \cdot z\right) - x \cdot 2\right) \cdot \left(x + 1\right)}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-79}:\\
\;\;\;\;\frac{t_2 - \frac{x}{t \cdot z}}{x + 1}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+268}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1} + \left(-\frac{-\left(\frac{y}{x + 1} - \frac{x}{z \cdot \left(x + 1\right)}\right)}{t}\right)\\
\end{array}
Results
| Original | 7.2 |
|---|---|
| Target | 0.3 |
| Herbie | 2.5 |
if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < -inf.0Initial program 64.0
Simplified64.0
[Start]64.0 | \[ \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\] |
|---|---|
rational_best.json-simplify-2 [=>]64.0 | \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1}
\] |
Taylor expanded in z around inf 22.3
if -inf.0 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < -1.0000000000000001e69Initial program 0.4
Simplified0.4
[Start]0.4 | \[ \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\] |
|---|---|
rational_best.json-simplify-2 [=>]0.4 | \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1}
\] |
Applied egg-rr0.4
Taylor expanded in y around inf 0.4
Simplified0.4
[Start]0.4 | \[ \frac{y \cdot z}{\left(1 + x\right) \cdot \left(\left(t \cdot z + x\right) - 2 \cdot x\right)}
\] |
|---|---|
rational_best.json-simplify-2 [=>]0.4 | \[ \frac{\color{blue}{z \cdot y}}{\left(1 + x\right) \cdot \left(\left(t \cdot z + x\right) - 2 \cdot x\right)}
\] |
rational_best.json-simplify-2 [=>]0.4 | \[ \frac{z \cdot y}{\color{blue}{\left(\left(t \cdot z + x\right) - 2 \cdot x\right) \cdot \left(1 + x\right)}}
\] |
rational_best.json-simplify-1 [=>]0.4 | \[ \frac{z \cdot y}{\left(\color{blue}{\left(x + t \cdot z\right)} - 2 \cdot x\right) \cdot \left(1 + x\right)}
\] |
rational_best.json-simplify-2 [=>]0.4 | \[ \frac{z \cdot y}{\left(\left(x + t \cdot z\right) - \color{blue}{x \cdot 2}\right) \cdot \left(1 + x\right)}
\] |
rational_best.json-simplify-1 [=>]0.4 | \[ \frac{z \cdot y}{\left(\left(x + t \cdot z\right) - x \cdot 2\right) \cdot \color{blue}{\left(x + 1\right)}}
\] |
if -1.0000000000000001e69 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 4.99999999999999999e-79Initial program 2.4
Simplified2.4
[Start]2.4 | \[ \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\] |
|---|---|
rational_best.json-simplify-2 [=>]2.4 | \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1}
\] |
Taylor expanded in t around inf 4.7
if 4.99999999999999999e-79 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 1.9999999999999999e268Initial program 0.1
if 1.9999999999999999e268 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) Initial program 58.9
Simplified58.9
[Start]58.9 | \[ \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\] |
|---|---|
rational_best.json-simplify-2 [=>]58.9 | \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1}
\] |
Taylor expanded in t around inf 10.8
Taylor expanded in t around -inf 10.1
Simplified10.1
[Start]10.1 | \[ -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 [=>]10.1 | \[ \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 [<=]10.1 | \[ \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 [=>]10.1 | \[ \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 [=>]10.1 | \[ \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 [=>]10.1 | \[ \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-48 [=>]10.1 | \[ \frac{x}{x + 1} + \left(-\frac{\color{blue}{-1 \cdot \left(\frac{y}{1 + x} - \frac{x}{\left(1 + x\right) \cdot z}\right)}}{t}\right)
\] |
rational_best.json-simplify-2 [=>]10.1 | \[ \frac{x}{x + 1} + \left(-\frac{\color{blue}{\left(\frac{y}{1 + x} - \frac{x}{\left(1 + x\right) \cdot z}\right) \cdot -1}}{t}\right)
\] |
rational_best.json-simplify-12 [=>]10.1 | \[ \frac{x}{x + 1} + \left(-\frac{\color{blue}{-\left(\frac{y}{1 + x} - \frac{x}{\left(1 + x\right) \cdot z}\right)}}{t}\right)
\] |
rational_best.json-simplify-1 [<=]10.1 | \[ \frac{x}{x + 1} + \left(-\frac{-\left(\frac{y}{\color{blue}{x + 1}} - \frac{x}{\left(1 + x\right) \cdot z}\right)}{t}\right)
\] |
rational_best.json-simplify-2 [=>]10.1 | \[ \frac{x}{x + 1} + \left(-\frac{-\left(\frac{y}{x + 1} - \frac{x}{\color{blue}{z \cdot \left(1 + x\right)}}\right)}{t}\right)
\] |
rational_best.json-simplify-1 [<=]10.1 | \[ \frac{x}{x + 1} + \left(-\frac{-\left(\frac{y}{x + 1} - \frac{x}{z \cdot \color{blue}{\left(x + 1\right)}}\right)}{t}\right)
\] |
Final simplification2.5
| Alternative 1 | |
|---|---|
| Error | 2.6 |
| Cost | 5840 |
| Alternative 2 | |
|---|---|
| Error | 2.6 |
| Cost | 5712 |
| Alternative 3 | |
|---|---|
| Error | 25.2 |
| Cost | 1372 |
| Alternative 4 | |
|---|---|
| Error | 24.7 |
| Cost | 1372 |
| Alternative 5 | |
|---|---|
| Error | 12.3 |
| Cost | 1032 |
| Alternative 6 | |
|---|---|
| Error | 15.1 |
| Cost | 840 |
| Alternative 7 | |
|---|---|
| Error | 20.8 |
| Cost | 720 |
| Alternative 8 | |
|---|---|
| Error | 20.6 |
| Cost | 584 |
| Alternative 9 | |
|---|---|
| Error | 27.0 |
| Cost | 328 |
| Alternative 10 | |
|---|---|
| Error | 28.4 |
| Cost | 64 |
herbie shell --seed 2023088
(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)))