| Alternative 1 | |
|---|---|
| Error | 1.0 |
| Cost | 1480 |
(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y (* z 3.0)))))
(if (<= (* z 3.0) -5e+189)
(+ t_1 (/ (/ t z) (* y 3.0)))
(if (<= (* z 3.0) 5e-153)
(+ (- x (/ (/ y z) 3.0)) (/ (/ (/ t y) z) 3.0))
(+ t_1 (/ t (* (* z 3.0) y)))))))double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if ((z * 3.0) <= -5e+189) {
tmp = t_1 + ((t / z) / (y * 3.0));
} else if ((z * 3.0) <= 5e-153) {
tmp = (x - ((y / z) / 3.0)) + (((t / y) / z) / 3.0);
} else {
tmp = t_1 + (t / ((z * 3.0) * y));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x - (y / (z * 3.0d0))
if ((z * 3.0d0) <= (-5d+189)) then
tmp = t_1 + ((t / z) / (y * 3.0d0))
else if ((z * 3.0d0) <= 5d-153) then
tmp = (x - ((y / z) / 3.0d0)) + (((t / y) / z) / 3.0d0)
else
tmp = t_1 + (t / ((z * 3.0d0) * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
public static double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if ((z * 3.0) <= -5e+189) {
tmp = t_1 + ((t / z) / (y * 3.0));
} else if ((z * 3.0) <= 5e-153) {
tmp = (x - ((y / z) / 3.0)) + (((t / y) / z) / 3.0);
} else {
tmp = t_1 + (t / ((z * 3.0) * y));
}
return tmp;
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
def code(x, y, z, t): t_1 = x - (y / (z * 3.0)) tmp = 0 if (z * 3.0) <= -5e+189: tmp = t_1 + ((t / z) / (y * 3.0)) elif (z * 3.0) <= 5e-153: tmp = (x - ((y / z) / 3.0)) + (((t / y) / z) / 3.0) else: tmp = t_1 + (t / ((z * 3.0) * y)) return tmp
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y))) end
function code(x, y, z, t) t_1 = Float64(x - Float64(y / Float64(z * 3.0))) tmp = 0.0 if (Float64(z * 3.0) <= -5e+189) tmp = Float64(t_1 + Float64(Float64(t / z) / Float64(y * 3.0))); elseif (Float64(z * 3.0) <= 5e-153) tmp = Float64(Float64(x - Float64(Float64(y / z) / 3.0)) + Float64(Float64(Float64(t / y) / z) / 3.0)); else tmp = Float64(t_1 + Float64(t / Float64(Float64(z * 3.0) * y))); end return tmp end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y)); end
function tmp_2 = code(x, y, z, t) t_1 = x - (y / (z * 3.0)); tmp = 0.0; if ((z * 3.0) <= -5e+189) tmp = t_1 + ((t / z) / (y * 3.0)); elseif ((z * 3.0) <= 5e-153) tmp = (x - ((y / z) / 3.0)) + (((t / y) / z) / 3.0); else tmp = t_1 + (t / ((z * 3.0) * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * 3.0), $MachinePrecision], -5e+189], N[(t$95$1 + N[(N[(t / z), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * 3.0), $MachinePrecision], 5e-153], N[(N[(x - N[(N[(y / z), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t / y), $MachinePrecision] / z), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;z \cdot 3 \leq -5 \cdot 10^{+189}:\\
\;\;\;\;t_1 + \frac{\frac{t}{z}}{y \cdot 3}\\
\mathbf{elif}\;z \cdot 3 \leq 5 \cdot 10^{-153}:\\
\;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{\frac{\frac{t}{y}}{z}}{3}\\
\mathbf{else}:\\
\;\;\;\;t_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\
\end{array}
Results
| Original | 3.8 |
|---|---|
| Target | 1.7 |
| Herbie | 1.9 |
if (*.f64 z 3) < -5.0000000000000004e189Initial program 0.7
Applied egg-rr0.6
Simplified1.6
[Start]0.6 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \left(t \cdot \frac{\frac{0.3333333333333333}{z}}{y} + 0\right)
\] |
|---|---|
rational.json-simplify-4 [=>]0.6 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{t \cdot \frac{\frac{0.3333333333333333}{z}}{y}}
\] |
rational.json-simplify-44 [=>]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + t \cdot \color{blue}{\frac{\frac{0.3333333333333333}{y}}{z}}
\] |
metadata-eval [<=]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{\frac{\color{blue}{\frac{1}{3}}}{y}}{z}
\] |
rational.json-simplify-46 [<=]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{\color{blue}{\frac{1}{3 \cdot y}}}{z}
\] |
rational.json-simplify-47 [=>]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + t \cdot \color{blue}{\frac{1}{\left(3 \cdot y\right) \cdot z}}
\] |
rational.json-simplify-2 [<=]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{1}{\color{blue}{z \cdot \left(3 \cdot y\right)}}
\] |
rational.json-simplify-5 [<=]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{1}{\color{blue}{z \cdot \left(3 \cdot y\right) - 0}}
\] |
rational.json-simplify-50 [=>]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + t \cdot \color{blue}{\frac{-1}{0 - z \cdot \left(3 \cdot y\right)}}
\] |
metadata-eval [=>]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{\color{blue}{-1}}{0 - z \cdot \left(3 \cdot y\right)}
\] |
rational.json-simplify-12 [<=]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + t \cdot \frac{-1}{\color{blue}{-z \cdot \left(3 \cdot y\right)}}
\] |
rational.json-simplify-49 [<=]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{-1 \cdot t}{-z \cdot \left(3 \cdot y\right)}}
\] |
rational.json-simplify-2 [<=]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \frac{\color{blue}{t \cdot -1}}{-z \cdot \left(3 \cdot y\right)}
\] |
rational.json-simplify-8 [<=]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \frac{\color{blue}{-t}}{-z \cdot \left(3 \cdot y\right)}
\] |
rational.json-simplify-12 [=>]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \frac{-t}{\color{blue}{0 - z \cdot \left(3 \cdot y\right)}}
\] |
rational.json-simplify-50 [<=]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{t}{z \cdot \left(3 \cdot y\right) - 0}}
\] |
rational.json-simplify-5 [=>]0.7 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\color{blue}{z \cdot \left(3 \cdot y\right)}}
\] |
rational.json-simplify-46 [=>]1.6 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{\frac{t}{z}}{3 \cdot y}}
\] |
rational.json-simplify-2 [=>]1.6 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z}}{\color{blue}{y \cdot 3}}
\] |
if -5.0000000000000004e189 < (*.f64 z 3) < 5.00000000000000033e-153Initial program 7.5
Simplified2.6
[Start]7.5 | \[ \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\] |
|---|---|
rational.json-simplify-46 [=>]7.5 | \[ \left(x - \color{blue}{\frac{\frac{y}{z}}{3}}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\] |
rational.json-simplify-46 [=>]1.8 | \[ \left(x - \frac{\frac{y}{z}}{3}\right) + \color{blue}{\frac{\frac{t}{z \cdot 3}}{y}}
\] |
rational.json-simplify-44 [=>]2.6 | \[ \left(x - \frac{\frac{y}{z}}{3}\right) + \color{blue}{\frac{\frac{t}{y}}{z \cdot 3}}
\] |
rational.json-simplify-46 [=>]2.6 | \[ \left(x - \frac{\frac{y}{z}}{3}\right) + \color{blue}{\frac{\frac{\frac{t}{y}}{z}}{3}}
\] |
if 5.00000000000000033e-153 < (*.f64 z 3) Initial program 1.3
Final simplification1.9
| Alternative 1 | |
|---|---|
| Error | 1.0 |
| Cost | 1480 |
| Alternative 2 | |
|---|---|
| Error | 1.7 |
| Cost | 1480 |
| Alternative 3 | |
|---|---|
| Error | 1.8 |
| Cost | 1480 |
| Alternative 4 | |
|---|---|
| Error | 30.8 |
| Cost | 1372 |
| Alternative 5 | |
|---|---|
| Error | 29.7 |
| Cost | 1372 |
| Alternative 6 | |
|---|---|
| Error | 29.7 |
| Cost | 1372 |
| Alternative 7 | |
|---|---|
| Error | 30.5 |
| Cost | 1108 |
| Alternative 8 | |
|---|---|
| Error | 12.2 |
| Cost | 1104 |
| Alternative 9 | |
|---|---|
| Error | 12.1 |
| Cost | 1104 |
| Alternative 10 | |
|---|---|
| Error | 8.8 |
| Cost | 1104 |
| Alternative 11 | |
|---|---|
| Error | 9.3 |
| Cost | 1104 |
| Alternative 12 | |
|---|---|
| Error | 1.9 |
| Cost | 1032 |
| Alternative 13 | |
|---|---|
| Error | 17.5 |
| Cost | 976 |
| Alternative 14 | |
|---|---|
| Error | 17.6 |
| Cost | 976 |
| Alternative 15 | |
|---|---|
| Error | 28.0 |
| Cost | 848 |
| Alternative 16 | |
|---|---|
| Error | 28.1 |
| Cost | 848 |
| Alternative 17 | |
|---|---|
| Error | 28.0 |
| Cost | 848 |
| Alternative 18 | |
|---|---|
| Error | 28.1 |
| Cost | 848 |
| Alternative 19 | |
|---|---|
| Error | 6.0 |
| Cost | 840 |
| Alternative 20 | |
|---|---|
| Error | 37.2 |
| Cost | 64 |
herbie shell --seed 2023068
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H"
:precision binary64
:herbie-target
(+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))