| Alternative 1 | |
|---|---|
| Error | 29.5 |
| Cost | 1772 |
(FPCore (x y z t a b) :precision binary64 (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* y 9.0) z)))
(if (<= t_1 1e+180)
(+ (- (* x 2.0) (* t_1 t)) (* (* a 27.0) b))
(+ (* y (* t (* -9.0 z))) (+ x (- x (* b (* a -27.0))))))))double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (y * 9.0) * z;
double tmp;
if (t_1 <= 1e+180) {
tmp = ((x * 2.0) - (t_1 * t)) + ((a * 27.0) * b);
} else {
tmp = (y * (t * (-9.0 * z))) + (x + (x - (b * (a * -27.0))));
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + ((a * 27.0d0) * b)
end function
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = (y * 9.0d0) * z
if (t_1 <= 1d+180) then
tmp = ((x * 2.0d0) - (t_1 * t)) + ((a * 27.0d0) * b)
else
tmp = (y * (t * ((-9.0d0) * z))) + (x + (x - (b * (a * (-27.0d0)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (y * 9.0) * z;
double tmp;
if (t_1 <= 1e+180) {
tmp = ((x * 2.0) - (t_1 * t)) + ((a * 27.0) * b);
} else {
tmp = (y * (t * (-9.0 * z))) + (x + (x - (b * (a * -27.0))));
}
return tmp;
}
def code(x, y, z, t, a, b): return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
def code(x, y, z, t, a, b): t_1 = (y * 9.0) * z tmp = 0 if t_1 <= 1e+180: tmp = ((x * 2.0) - (t_1 * t)) + ((a * 27.0) * b) else: tmp = (y * (t * (-9.0 * z))) + (x + (x - (b * (a * -27.0)))) return tmp
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(Float64(a * 27.0) * b)) end
function code(x, y, z, t, a, b) t_1 = Float64(Float64(y * 9.0) * z) tmp = 0.0 if (t_1 <= 1e+180) tmp = Float64(Float64(Float64(x * 2.0) - Float64(t_1 * t)) + Float64(Float64(a * 27.0) * b)); else tmp = Float64(Float64(y * Float64(t * Float64(-9.0 * z))) + Float64(x + Float64(x - Float64(b * Float64(a * -27.0))))); end return tmp end
function tmp = code(x, y, z, t, a, b) tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b); end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (y * 9.0) * z; tmp = 0.0; if (t_1 <= 1e+180) tmp = ((x * 2.0) - (t_1 * t)) + ((a * 27.0) * b); else tmp = (y * (t * (-9.0 * z))) + (x + (x - (b * (a * -27.0)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$1, 1e+180], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(t$95$1 * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(t * N[(-9.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x + N[(x - N[(b * N[(a * -27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\begin{array}{l}
t_1 := \left(y \cdot 9\right) \cdot z\\
\mathbf{if}\;t_1 \leq 10^{+180}:\\
\;\;\;\;\left(x \cdot 2 - t_1 \cdot t\right) + \left(a \cdot 27\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(t \cdot \left(-9 \cdot z\right)\right) + \left(x + \left(x - b \cdot \left(a \cdot -27\right)\right)\right)\\
\end{array}
Results
| Original | 3.1 |
|---|---|
| Target | 3.5 |
| Herbie | 0.7 |
if (*.f64 (*.f64 y 9) z) < 1e180Initial program 0.7
if 1e180 < (*.f64 (*.f64 y 9) z) Initial program 25.2
Applied egg-rr25.2
Simplified0.6
[Start]25.2 | \[ \left(\left(x + x\right) + \left(\left(-9 \cdot y\right) \cdot z\right) \cdot t\right) - \left(-27 \cdot a\right) \cdot b
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-107 [=>]25.2 | \[ \color{blue}{\left(\left(-9 \cdot y\right) \cdot z\right) \cdot t + \left(\left(x + x\right) - \left(-27 \cdot a\right) \cdot b\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]25.2 | \[ \color{blue}{t \cdot \left(\left(-9 \cdot y\right) \cdot z\right)} + \left(\left(x + x\right) - \left(-27 \cdot a\right) \cdot b\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]25.2 | \[ t \cdot \color{blue}{\left(z \cdot \left(-9 \cdot y\right)\right)} + \left(\left(x + x\right) - \left(-27 \cdot a\right) \cdot b\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]25.0 | \[ t \cdot \color{blue}{\left(-9 \cdot \left(z \cdot y\right)\right)} + \left(\left(x + x\right) - \left(-27 \cdot a\right) \cdot b\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]25.0 | \[ t \cdot \left(-9 \cdot \color{blue}{\left(y \cdot z\right)}\right) + \left(\left(x + x\right) - \left(-27 \cdot a\right) \cdot b\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]24.7 | \[ \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(\left(x + x\right) - \left(-27 \cdot a\right) \cdot b\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [<=]0.6 | \[ -9 \cdot \color{blue}{\left(y \cdot \left(t \cdot z\right)\right)} + \left(\left(x + x\right) - \left(-27 \cdot a\right) \cdot b\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]0.6 | \[ \color{blue}{y \cdot \left(-9 \cdot \left(t \cdot z\right)\right)} + \left(\left(x + x\right) - \left(-27 \cdot a\right) \cdot b\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [=>]0.6 | \[ y \cdot \color{blue}{\left(t \cdot \left(-9 \cdot z\right)\right)} + \left(\left(x + x\right) - \left(-27 \cdot a\right) \cdot b\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-107 [=>]0.6 | \[ y \cdot \left(t \cdot \left(-9 \cdot z\right)\right) + \color{blue}{\left(x + \left(x - \left(-27 \cdot a\right) \cdot b\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.6 | \[ y \cdot \left(t \cdot \left(-9 \cdot z\right)\right) + \left(x + \left(x - \color{blue}{b \cdot \left(-27 \cdot a\right)}\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.6 | \[ y \cdot \left(t \cdot \left(-9 \cdot z\right)\right) + \left(x + \left(x - b \cdot \color{blue}{\left(a \cdot -27\right)}\right)\right)
\] |
Final simplification0.7
| Alternative 1 | |
|---|---|
| Error | 29.5 |
| Cost | 1772 |
| Alternative 2 | |
|---|---|
| Error | 29.1 |
| Cost | 1376 |
| Alternative 3 | |
|---|---|
| Error | 29.7 |
| Cost | 1376 |
| Alternative 4 | |
|---|---|
| Error | 29.6 |
| Cost | 1376 |
| Alternative 5 | |
|---|---|
| Error | 29.6 |
| Cost | 1376 |
| Alternative 6 | |
|---|---|
| Error | 13.9 |
| Cost | 1364 |
| Alternative 7 | |
|---|---|
| Error | 13.4 |
| Cost | 1232 |
| Alternative 8 | |
|---|---|
| Error | 1.4 |
| Cost | 1220 |
| Alternative 9 | |
|---|---|
| Error | 16.3 |
| Cost | 1104 |
| Alternative 10 | |
|---|---|
| Error | 16.4 |
| Cost | 1104 |
| Alternative 11 | |
|---|---|
| Error | 12.8 |
| Cost | 968 |
| Alternative 12 | |
|---|---|
| Error | 28.0 |
| Cost | 584 |
| Alternative 13 | |
|---|---|
| Error | 28.1 |
| Cost | 584 |
| Alternative 14 | |
|---|---|
| Error | 37.4 |
| Cost | 192 |
herbie shell --seed 2023090
(FPCore (x y z t a b)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, A"
:precision binary64
:herbie-target
(if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))
(+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))