| Alternative 1 | |
|---|---|
| Error | 8.8 |
| Cost | 4432 |
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ t (* (- (/ a z) (/ y z)) (+ t (- x)))))
(t_2 (+ x (/ (* (- y z) (- t x)) (- a z)))))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 -2e-287)
t_2
(if (<= t_2 0.0) t_1 (if (<= t_2 2e+299) t_2 t_1))))))double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = t + (((a / z) - (y / z)) * (t + -x));
double t_2 = x + (((y - z) * (t - x)) / (a - z));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= -2e-287) {
tmp = t_2;
} else if (t_2 <= 0.0) {
tmp = t_1;
} else if (t_2 <= 2e+299) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t + (((a / z) - (y / z)) * (t + -x));
double t_2 = x + (((y - z) * (t - x)) / (a - z));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= -2e-287) {
tmp = t_2;
} else if (t_2 <= 0.0) {
tmp = t_1;
} else if (t_2 <= 2e+299) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): return x + (((y - z) * (t - x)) / (a - z))
def code(x, y, z, t, a): t_1 = t + (((a / z) - (y / z)) * (t + -x)) t_2 = x + (((y - z) * (t - x)) / (a - z)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= -2e-287: tmp = t_2 elif t_2 <= 0.0: tmp = t_1 elif t_2 <= 2e+299: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) end
function code(x, y, z, t, a) t_1 = Float64(t + Float64(Float64(Float64(a / z) - Float64(y / z)) * Float64(t + Float64(-x)))) t_2 = Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= -2e-287) tmp = t_2; elseif (t_2 <= 0.0) tmp = t_1; elseif (t_2 <= 2e+299) tmp = t_2; else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * (t - x)) / (a - z)); end
function tmp_2 = code(x, y, z, t, a) t_1 = t + (((a / z) - (y / z)) * (t + -x)); t_2 = x + (((y - z) * (t - x)) / (a - z)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= -2e-287) tmp = t_2; elseif (t_2 <= 0.0) tmp = t_1; elseif (t_2 <= 2e+299) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t + N[(N[(N[(a / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision] * N[(t + (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, -2e-287], t$95$2, If[LessEqual[t$95$2, 0.0], t$95$1, If[LessEqual[t$95$2, 2e+299], t$95$2, t$95$1]]]]]]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
t_1 := t + \left(\frac{a}{z} - \frac{y}{z}\right) \cdot \left(t + \left(-x\right)\right)\\
t_2 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq -2 \cdot 10^{-287}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+299}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 24.7 |
|---|---|
| Target | 12.2 |
| Herbie | 7.3 |
if (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -inf.0 or -2.00000000000000004e-287 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 0.0 or 2.0000000000000001e299 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) Initial program 62.4
Taylor expanded in z around -inf 31.3
Simplified31.3
[Start]31.3 | \[ -1 \cdot \frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z} + t
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]31.3 | \[ \color{blue}{t + -1 \cdot \frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]31.3 | \[ t + \color{blue}{\frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z} \cdot -1}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]31.3 | \[ t + \color{blue}{\left(-\frac{y \cdot \left(t - x\right) - a \cdot \left(t - x\right)}{z}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]31.3 | \[ t + \left(-\frac{y \cdot \left(t - x\right) - \color{blue}{\left(t - x\right) \cdot a}}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-102 [=>]31.3 | \[ t + \left(-\frac{\color{blue}{\left(t - x\right) \cdot \left(y - a\right)}}{z}\right)
\] |
Taylor expanded in x around -inf 25.2
Simplified25.2
[Start]25.2 | \[ \left(t + -1 \cdot \left(\left(\frac{a}{z} - \frac{y}{z}\right) \cdot x\right)\right) - \frac{t \cdot \left(y - a\right)}{z}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]25.2 | \[ \color{blue}{\left(-1 \cdot \left(\left(\frac{a}{z} - \frac{y}{z}\right) \cdot x\right) + t\right)} - \frac{t \cdot \left(y - a\right)}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-107 [=>]25.2 | \[ \color{blue}{t + \left(-1 \cdot \left(\left(\frac{a}{z} - \frac{y}{z}\right) \cdot x\right) - \frac{t \cdot \left(y - a\right)}{z}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]25.2 | \[ t + \left(\color{blue}{\left(\frac{a}{z} - \frac{y}{z}\right) \cdot \left(-1 \cdot x\right)} - \frac{t \cdot \left(y - a\right)}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]25.2 | \[ t + \left(\left(\frac{a}{z} - \frac{y}{z}\right) \cdot \color{blue}{\left(x \cdot -1\right)} - \frac{t \cdot \left(y - a\right)}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]25.2 | \[ t + \left(\left(\frac{a}{z} - \frac{y}{z}\right) \cdot \color{blue}{\left(-x\right)} - \frac{t \cdot \left(y - a\right)}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]25.2 | \[ t + \left(\left(\frac{a}{z} - \frac{y}{z}\right) \cdot \left(-x\right) - \frac{\color{blue}{\left(y - a\right) \cdot t}}{z}\right)
\] |
Taylor expanded in t around 0 16.1
Simplified16.1
[Start]16.1 | \[ t + \left(\left(\frac{a}{z} - \frac{y}{z}\right) \cdot t + -1 \cdot \left(\left(\frac{a}{z} - \frac{y}{z}\right) \cdot x\right)\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]16.1 | \[ t + \left(\color{blue}{t \cdot \left(\frac{a}{z} - \frac{y}{z}\right)} + -1 \cdot \left(\left(\frac{a}{z} - \frac{y}{z}\right) \cdot x\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]16.1 | \[ t + \left(t \cdot \left(\frac{a}{z} - \frac{y}{z}\right) + \color{blue}{\left(\frac{a}{z} - \frac{y}{z}\right) \cdot \left(-1 \cdot x\right)}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [=>]16.1 | \[ t + \color{blue}{\left(\frac{a}{z} - \frac{y}{z}\right) \cdot \left(t + -1 \cdot x\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]16.1 | \[ t + \left(\frac{a}{z} - \frac{y}{z}\right) \cdot \left(t + \color{blue}{x \cdot -1}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]16.1 | \[ t + \left(\frac{a}{z} - \frac{y}{z}\right) \cdot \left(t + \color{blue}{\left(-x\right)}\right)
\] |
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -2.00000000000000004e-287 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 2.0000000000000001e299Initial program 1.9
Final simplification7.3
| Alternative 1 | |
|---|---|
| Error | 8.8 |
| Cost | 4432 |
| Alternative 2 | |
|---|---|
| Error | 35.1 |
| Cost | 2032 |
| Alternative 3 | |
|---|---|
| Error | 40.4 |
| Cost | 1832 |
| Alternative 4 | |
|---|---|
| Error | 32.9 |
| Cost | 1504 |
| Alternative 5 | |
|---|---|
| Error | 36.3 |
| Cost | 1240 |
| Alternative 6 | |
|---|---|
| Error | 34.5 |
| Cost | 1240 |
| Alternative 7 | |
|---|---|
| Error | 19.3 |
| Cost | 1232 |
| Alternative 8 | |
|---|---|
| Error | 18.9 |
| Cost | 1232 |
| Alternative 9 | |
|---|---|
| Error | 36.2 |
| Cost | 1108 |
| Alternative 10 | |
|---|---|
| Error | 31.3 |
| Cost | 1104 |
| Alternative 11 | |
|---|---|
| Error | 23.2 |
| Cost | 1100 |
| Alternative 12 | |
|---|---|
| Error | 31.6 |
| Cost | 1040 |
| Alternative 13 | |
|---|---|
| Error | 27.0 |
| Cost | 972 |
| Alternative 14 | |
|---|---|
| Error | 27.9 |
| Cost | 840 |
| Alternative 15 | |
|---|---|
| Error | 35.7 |
| Cost | 716 |
| Alternative 16 | |
|---|---|
| Error | 35.5 |
| Cost | 328 |
| Alternative 17 | |
|---|---|
| Error | 45.5 |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
:precision binary64
:herbie-target
(if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))
(+ x (/ (* (- y z) (- t x)) (- a z))))