| Alternative 1 | |
|---|---|
| Error | 0.8 |
| Cost | 1220 |
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- z a)))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (* y (/ (- z t) (- z a))))))
(if (<= y -8.8e+46)
t_1
(if (<= y 1.2e-161) (+ x (/ (/ (- z t) (/ 1.0 y)) (- z a))) t_1))))double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (y * ((z - t) / (z - a)));
double tmp;
if (y <= -8.8e+46) {
tmp = t_1;
} else if (y <= 1.2e-161) {
tmp = x + (((z - t) / (1.0 / y)) / (z - a));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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
code = x + (y * ((z - t) / (z - a)))
end function
real(8) function code(x, y, z, t, a)
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) :: t_1
real(8) :: tmp
t_1 = x + (y * ((z - t) / (z - a)))
if (y <= (-8.8d+46)) then
tmp = t_1
else if (y <= 1.2d-161) then
tmp = x + (((z - t) / (1.0d0 / y)) / (z - a))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x + (y * ((z - t) / (z - a)));
double tmp;
if (y <= -8.8e+46) {
tmp = t_1;
} else if (y <= 1.2e-161) {
tmp = x + (((z - t) / (1.0 / y)) / (z - a));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): return x + (y * ((z - t) / (z - a)))
def code(x, y, z, t, a): t_1 = x + (y * ((z - t) / (z - a))) tmp = 0 if y <= -8.8e+46: tmp = t_1 elif y <= 1.2e-161: tmp = x + (((z - t) / (1.0 / y)) / (z - a)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(z - a)))) end
function code(x, y, z, t, a) t_1 = Float64(x + Float64(y * Float64(Float64(z - t) / Float64(z - a)))) tmp = 0.0 if (y <= -8.8e+46) tmp = t_1; elseif (y <= 1.2e-161) tmp = Float64(x + Float64(Float64(Float64(z - t) / Float64(1.0 / y)) / Float64(z - a))); else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t, a) tmp = x + (y * ((z - t) / (z - a))); end
function tmp_2 = code(x, y, z, t, a) t_1 = x + (y * ((z - t) / (z - a))); tmp = 0.0; if (y <= -8.8e+46) tmp = t_1; elseif (y <= 1.2e-161) tmp = x + (((z - t) / (1.0 / y)) / (z - a)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.8e+46], t$95$1, If[LessEqual[y, 1.2e-161], N[(x + N[(N[(N[(z - t), $MachinePrecision] / N[(1.0 / y), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x + y \cdot \frac{z - t}{z - a}
\begin{array}{l}
t_1 := x + y \cdot \frac{z - t}{z - a}\\
\mathbf{if}\;y \leq -8.8 \cdot 10^{+46}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-161}:\\
\;\;\;\;x + \frac{\frac{z - t}{\frac{1}{y}}}{z - a}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 1.3 |
|---|---|
| Target | 1.2 |
| Herbie | 0.8 |
if y < -8.8000000000000001e46 or 1.19999999999999999e-161 < y Initial program 0.8
if -8.8000000000000001e46 < y < 1.19999999999999999e-161Initial program 2.1
Simplified2.9
[Start]2.1 | \[ x + y \cdot \frac{z - t}{z - a}
\] |
|---|---|
rational.json-simplify-50 [=>]2.1 | \[ x + y \cdot \color{blue}{\frac{-\left(z - t\right)}{a - z}}
\] |
rational.json-simplify-8 [=>]2.1 | \[ x + y \cdot \frac{\color{blue}{\left(z - t\right) \cdot -1}}{a - z}
\] |
rational.json-simplify-49 [=>]2.1 | \[ x + y \cdot \color{blue}{\left(-1 \cdot \frac{z - t}{a - z}\right)}
\] |
rational.json-simplify-43 [<=]2.1 | \[ x + \color{blue}{\frac{z - t}{a - z} \cdot \left(y \cdot -1\right)}
\] |
rational.json-simplify-2 [=>]2.1 | \[ x + \color{blue}{\left(y \cdot -1\right) \cdot \frac{z - t}{a - z}}
\] |
rational.json-simplify-50 [=>]2.1 | \[ x + \left(y \cdot -1\right) \cdot \color{blue}{\frac{-\left(z - t\right)}{z - a}}
\] |
rational.json-simplify-8 [=>]2.1 | \[ x + \left(y \cdot -1\right) \cdot \frac{\color{blue}{\left(z - t\right) \cdot -1}}{z - a}
\] |
rational.json-simplify-2 [=>]2.1 | \[ x + \left(y \cdot -1\right) \cdot \frac{\color{blue}{-1 \cdot \left(z - t\right)}}{z - a}
\] |
rational.json-simplify-49 [=>]2.1 | \[ x + \left(y \cdot -1\right) \cdot \color{blue}{\left(\left(z - t\right) \cdot \frac{-1}{z - a}\right)}
\] |
rational.json-simplify-43 [=>]2.9 | \[ x + \color{blue}{\left(z - t\right) \cdot \left(\frac{-1}{z - a} \cdot \left(y \cdot -1\right)\right)}
\] |
rational.json-simplify-9 [=>]2.9 | \[ x + \left(z - t\right) \cdot \left(\frac{-1}{z - a} \cdot \color{blue}{\left(-y\right)}\right)
\] |
rational.json-simplify-10 [=>]2.9 | \[ x + \left(z - t\right) \cdot \left(\frac{-1}{z - a} \cdot \color{blue}{\frac{y}{-1}}\right)
\] |
rational.json-simplify-55 [=>]2.9 | \[ x + \left(z - t\right) \cdot \color{blue}{\frac{\frac{y}{-1}}{\frac{z - a}{-1}}}
\] |
rational.json-simplify-10 [<=]2.9 | \[ x + \left(z - t\right) \cdot \frac{\color{blue}{-y}}{\frac{z - a}{-1}}
\] |
rational.json-simplify-9 [<=]2.9 | \[ x + \left(z - t\right) \cdot \frac{\color{blue}{y \cdot -1}}{\frac{z - a}{-1}}
\] |
rational.json-simplify-10 [<=]2.9 | \[ x + \left(z - t\right) \cdot \frac{y \cdot -1}{\color{blue}{-\left(z - a\right)}}
\] |
rational.json-simplify-13 [<=]2.9 | \[ x + \left(z - t\right) \cdot \frac{y \cdot -1}{\color{blue}{0 - \left(z - a\right)}}
\] |
rational.json-simplify-45 [<=]2.9 | \[ x + \left(z - t\right) \cdot \frac{y \cdot -1}{\color{blue}{a - \left(z - 0\right)}}
\] |
rational.json-simplify-5 [=>]2.9 | \[ x + \left(z - t\right) \cdot \frac{y \cdot -1}{a - \color{blue}{z}}
\] |
rational.json-simplify-50 [=>]2.9 | \[ x + \left(z - t\right) \cdot \color{blue}{\frac{-y \cdot -1}{z - a}}
\] |
rational.json-simplify-12 [=>]2.9 | \[ x + \left(z - t\right) \cdot \frac{\color{blue}{0 - y \cdot -1}}{z - a}
\] |
rational.json-simplify-9 [=>]2.9 | \[ x + \left(z - t\right) \cdot \frac{0 - \color{blue}{\left(-y\right)}}{z - a}
\] |
rational.json-simplify-12 [=>]2.9 | \[ x + \left(z - t\right) \cdot \frac{0 - \color{blue}{\left(0 - y\right)}}{z - a}
\] |
rational.json-simplify-45 [=>]2.9 | \[ x + \left(z - t\right) \cdot \frac{\color{blue}{y - \left(0 - 0\right)}}{z - a}
\] |
metadata-eval [=>]2.9 | \[ x + \left(z - t\right) \cdot \frac{y - \color{blue}{0}}{z - a}
\] |
rational.json-simplify-5 [=>]2.9 | \[ x + \left(z - t\right) \cdot \frac{\color{blue}{y}}{z - a}
\] |
Applied egg-rr0.8
Final simplification0.8
| Alternative 1 | |
|---|---|
| Error | 0.8 |
| Cost | 1220 |
| Alternative 2 | |
|---|---|
| Error | 0.8 |
| Cost | 1220 |
| Alternative 3 | |
|---|---|
| Error | 1.3 |
| Cost | 968 |
| Alternative 4 | |
|---|---|
| Error | 0.5 |
| Cost | 968 |
| Alternative 5 | |
|---|---|
| Error | 14.5 |
| Cost | 844 |
| Alternative 6 | |
|---|---|
| Error | 10.6 |
| Cost | 840 |
| Alternative 7 | |
|---|---|
| Error | 10.5 |
| Cost | 840 |
| Alternative 8 | |
|---|---|
| Error | 8.4 |
| Cost | 840 |
| Alternative 9 | |
|---|---|
| Error | 14.4 |
| Cost | 712 |
| Alternative 10 | |
|---|---|
| Error | 20.1 |
| Cost | 456 |
| Alternative 11 | |
|---|---|
| Error | 26.7 |
| Cost | 328 |
| Alternative 12 | |
|---|---|
| Error | 29.0 |
| Cost | 64 |
herbie shell --seed 2023074
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, A"
:precision binary64
:herbie-target
(+ x (/ y (/ (- z a) (- z t))))
(+ x (* y (/ (- z t) (- z a)))))