| Alternative 1 | |
|---|---|
| Error | 19.7 |
| Cost | 1496 |
(FPCore (x y z t a) :precision binary64 (/ (- x (* y z)) (- t (* a z))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- x (* y z)) (- t (* a z)))))
(if (<= t_1 (- INFINITY))
(/ y a)
(if (<= t_1 5e+267) t_1 (- (/ (- (/ x z) y) a))))))double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = (x - (y * z)) / (t - (a * z));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = y / a;
} else if (t_1 <= 5e+267) {
tmp = t_1;
} else {
tmp = -(((x / z) - y) / a);
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (x - (y * z)) / (t - (a * z));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = y / a;
} else if (t_1 <= 5e+267) {
tmp = t_1;
} else {
tmp = -(((x / z) - y) / a);
}
return tmp;
}
def code(x, y, z, t, a): return (x - (y * z)) / (t - (a * z))
def code(x, y, z, t, a): t_1 = (x - (y * z)) / (t - (a * z)) tmp = 0 if t_1 <= -math.inf: tmp = y / a elif t_1 <= 5e+267: tmp = t_1 else: tmp = -(((x / z) - y) / a) return tmp
function code(x, y, z, t, a) return Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(a * z))) end
function code(x, y, z, t, a) t_1 = Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(a * z))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(y / a); elseif (t_1 <= 5e+267) tmp = t_1; else tmp = Float64(-Float64(Float64(Float64(x / z) - y) / a)); end return tmp end
function tmp = code(x, y, z, t, a) tmp = (x - (y * z)) / (t - (a * z)); end
function tmp_2 = code(x, y, z, t, a) t_1 = (x - (y * z)) / (t - (a * z)); tmp = 0.0; if (t_1 <= -Inf) tmp = y / a; elseif (t_1 <= 5e+267) tmp = t_1; else tmp = -(((x / z) - y) / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(y / a), $MachinePrecision], If[LessEqual[t$95$1, 5e+267], t$95$1, (-N[(N[(N[(x / z), $MachinePrecision] - y), $MachinePrecision] / a), $MachinePrecision])]]]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
t_1 := \frac{x - y \cdot z}{t - a \cdot z}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+267}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-\frac{\frac{x}{z} - y}{a}\\
\end{array}
Results
| Original | 10.3 |
|---|---|
| Target | 1.7 |
| Herbie | 5.7 |
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -inf.0Initial program 64.0
Simplified64.0
[Start]64.0 | \[ \frac{x - y \cdot z}{t - a \cdot z}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]64.0 | \[ \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}}
\] |
Taylor expanded in z around inf 22.4
if -inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 4.9999999999999999e267Initial program 4.2
if 4.9999999999999999e267 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 53.2
Simplified53.2
[Start]53.2 | \[ \frac{x - y \cdot z}{t - a \cdot z}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]53.2 | \[ \frac{x - y \cdot z}{t - \color{blue}{z \cdot a}}
\] |
Taylor expanded in x around 0 53.2
Simplified53.2
[Start]53.2 | \[ \frac{x}{t - a \cdot z} + -1 \cdot \frac{y \cdot z}{t - a \cdot z}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]53.2 | \[ \color{blue}{-1 \cdot \frac{y \cdot z}{t - a \cdot z} + \frac{x}{t - a \cdot z}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]53.2 | \[ \color{blue}{\frac{y \cdot z}{t - a \cdot z} \cdot -1} + \frac{x}{t - a \cdot z}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]53.2 | \[ \color{blue}{\left(-\frac{y \cdot z}{t - a \cdot z}\right)} + \frac{x}{t - a \cdot z}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]53.2 | \[ \left(-\frac{y \cdot z}{t - \color{blue}{z \cdot a}}\right) + \frac{x}{t - a \cdot z}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]53.2 | \[ \left(-\frac{y \cdot z}{t - z \cdot a}\right) + \frac{x}{t - \color{blue}{z \cdot a}}
\] |
Taylor expanded in a around -inf 15.2
Simplified15.2
[Start]15.2 | \[ -1 \cdot \frac{\frac{x}{z} - y}{a}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]15.2 | \[ \color{blue}{\frac{\frac{x}{z} - y}{a} \cdot -1}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]15.2 | \[ \color{blue}{-\frac{\frac{x}{z} - y}{a}}
\] |
Final simplification5.7
| Alternative 1 | |
|---|---|
| Error | 19.7 |
| Cost | 1496 |
| Alternative 2 | |
|---|---|
| Error | 20.1 |
| Cost | 1304 |
| Alternative 3 | |
|---|---|
| Error | 20.3 |
| Cost | 1040 |
| Alternative 4 | |
|---|---|
| Error | 23.1 |
| Cost | 844 |
| Alternative 5 | |
|---|---|
| Error | 31.3 |
| Cost | 780 |
| Alternative 6 | |
|---|---|
| Error | 22.9 |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 31.0 |
| Cost | 456 |
| Alternative 8 | |
|---|---|
| Error | 41.8 |
| Cost | 192 |
herbie shell --seed 2023090
(FPCore (x y z t a)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, A"
:precision binary64
:herbie-target
(if (< z -32113435955957344.0) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))) (if (< z 3.5139522372978296e-86) (* (- x (* y z)) (/ 1.0 (- t (* a z)))) (- (/ x (- t (* a z))) (/ y (- (/ t z) a)))))
(/ (- x (* y z)) (- t (* a z))))