| Alternative 1 | |
|---|---|
| Error | 14.5 |
| Cost | 1236 |
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
(FPCore (x y z t a)
:precision binary64
(if (<= t -1.12e+185)
(+ x (/ (/ y t) (/ -1.0 (- a z))))
(if (<= t 1.8e+84)
(+ x (- y (* y (/ (- z t) (- a t)))))
(+ x (* y (/ (- z a) t))))))double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.12e+185) {
tmp = x + ((y / t) / (-1.0 / (a - z)));
} else if (t <= 1.8e+84) {
tmp = x + (y - (y * ((z - t) / (a - t))));
} else {
tmp = x + (y * ((z - a) / t));
}
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) * y) / (a - t))
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) :: tmp
if (t <= (-1.12d+185)) then
tmp = x + ((y / t) / ((-1.0d0) / (a - z)))
else if (t <= 1.8d+84) then
tmp = x + (y - (y * ((z - t) / (a - t))))
else
tmp = x + (y * ((z - a) / t))
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) * y) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.12e+185) {
tmp = x + ((y / t) / (-1.0 / (a - z)));
} else if (t <= 1.8e+84) {
tmp = x + (y - (y * ((z - t) / (a - t))));
} else {
tmp = x + (y * ((z - a) / t));
}
return tmp;
}
def code(x, y, z, t, a): return (x + y) - (((z - t) * y) / (a - t))
def code(x, y, z, t, a): tmp = 0 if t <= -1.12e+185: tmp = x + ((y / t) / (-1.0 / (a - z))) elif t <= 1.8e+84: tmp = x + (y - (y * ((z - t) / (a - t)))) else: tmp = x + (y * ((z - a) / t)) return tmp
function code(x, y, z, t, a) return Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) end
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.12e+185) tmp = Float64(x + Float64(Float64(y / t) / Float64(-1.0 / Float64(a - z)))); elseif (t <= 1.8e+84) tmp = Float64(x + Float64(y - Float64(y * Float64(Float64(z - t) / Float64(a - t))))); else tmp = Float64(x + Float64(y * Float64(Float64(z - a) / t))); end return tmp end
function tmp = code(x, y, z, t, a) tmp = (x + y) - (((z - t) * y) / (a - t)); end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -1.12e+185) tmp = x + ((y / t) / (-1.0 / (a - z))); elseif (t <= 1.8e+84) tmp = x + (y - (y * ((z - t) / (a - t)))); else tmp = x + (y * ((z - a) / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.12e+185], N[(x + N[(N[(y / t), $MachinePrecision] / N[(-1.0 / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.8e+84], N[(x + N[(y - N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(N[(z - a), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -1.12 \cdot 10^{+185}:\\
\;\;\;\;x + \frac{\frac{y}{t}}{\frac{-1}{a - z}}\\
\mathbf{elif}\;t \leq 1.8 \cdot 10^{+84}:\\
\;\;\;\;x + \left(y - y \cdot \frac{z - t}{a - t}\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z - a}{t}\\
\end{array}
Results
| Original | 16.3 |
|---|---|
| Target | 8.4 |
| Herbie | 5.9 |
if t < -1.11999999999999996e185Initial program 34.8
Simplified30.3
[Start]34.8 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
rational.json-simplify-1 [=>]34.8 | \[ \color{blue}{\left(y + x\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
rational.json-simplify-48 [=>]30.3 | \[ \color{blue}{x + \left(y - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
rational.json-simplify-2 [=>]30.3 | \[ x + \left(y - \frac{\color{blue}{y \cdot \left(z - t\right)}}{a - t}\right)
\] |
Taylor expanded in t around inf 13.9
Simplified4.4
[Start]13.9 | \[ x + \frac{-1 \cdot \left(a \cdot y\right) - -1 \cdot \left(y \cdot z\right)}{t}
\] |
|---|---|
rational.json-simplify-2 [<=]13.9 | \[ x + \frac{-1 \cdot \color{blue}{\left(y \cdot a\right)} - -1 \cdot \left(y \cdot z\right)}{t}
\] |
rational.json-simplify-43 [=>]13.9 | \[ x + \frac{\color{blue}{y \cdot \left(a \cdot -1\right)} - -1 \cdot \left(y \cdot z\right)}{t}
\] |
rational.json-simplify-43 [=>]13.9 | \[ x + \frac{y \cdot \left(a \cdot -1\right) - \color{blue}{y \cdot \left(z \cdot -1\right)}}{t}
\] |
rational.json-simplify-2 [=>]13.9 | \[ x + \frac{y \cdot \left(a \cdot -1\right) - \color{blue}{\left(z \cdot -1\right) \cdot y}}{t}
\] |
rational.json-simplify-52 [=>]13.9 | \[ x + \frac{\color{blue}{y \cdot \left(a \cdot -1 - z \cdot -1\right)}}{t}
\] |
rational.json-simplify-9 [=>]13.9 | \[ x + \frac{y \cdot \left(\color{blue}{\left(-a\right)} - z \cdot -1\right)}{t}
\] |
rational.json-simplify-12 [=>]13.9 | \[ x + \frac{y \cdot \left(\color{blue}{\left(0 - a\right)} - z \cdot -1\right)}{t}
\] |
rational.json-simplify-42 [=>]13.9 | \[ x + \frac{y \cdot \color{blue}{\left(\left(0 - z \cdot -1\right) - a\right)}}{t}
\] |
rational.json-simplify-8 [<=]13.9 | \[ x + \frac{y \cdot \left(\left(0 - \color{blue}{\left(-z\right)}\right) - a\right)}{t}
\] |
rational.json-simplify-12 [=>]13.9 | \[ x + \frac{y \cdot \left(\left(0 - \color{blue}{\left(0 - z\right)}\right) - a\right)}{t}
\] |
rational.json-simplify-45 [=>]13.9 | \[ x + \frac{y \cdot \left(\color{blue}{\left(z - \left(0 - 0\right)\right)} - a\right)}{t}
\] |
metadata-eval [=>]13.9 | \[ x + \frac{y \cdot \left(\left(z - \color{blue}{0}\right) - a\right)}{t}
\] |
rational.json-simplify-5 [=>]13.9 | \[ x + \frac{y \cdot \left(\color{blue}{z} - a\right)}{t}
\] |
rational.json-simplify-2 [=>]13.9 | \[ x + \frac{\color{blue}{\left(z - a\right) \cdot y}}{t}
\] |
rational.json-simplify-49 [=>]4.4 | \[ x + \color{blue}{y \cdot \frac{z - a}{t}}
\] |
Applied egg-rr4.7
if -1.11999999999999996e185 < t < 1.8e84Initial program 9.5
Simplified5.4
[Start]9.5 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
rational.json-simplify-1 [=>]9.5 | \[ \color{blue}{\left(y + x\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
rational.json-simplify-48 [=>]8.4 | \[ \color{blue}{x + \left(y - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
rational.json-simplify-49 [=>]5.4 | \[ x + \left(y - \color{blue}{y \cdot \frac{z - t}{a - t}}\right)
\] |
if 1.8e84 < t Initial program 29.8
Simplified26.0
[Start]29.8 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
rational.json-simplify-1 [=>]29.8 | \[ \color{blue}{\left(y + x\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
rational.json-simplify-48 [=>]26.0 | \[ \color{blue}{x + \left(y - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
rational.json-simplify-2 [=>]26.0 | \[ x + \left(y - \frac{\color{blue}{y \cdot \left(z - t\right)}}{a - t}\right)
\] |
Taylor expanded in t around inf 15.9
Simplified8.3
[Start]15.9 | \[ x + \frac{-1 \cdot \left(a \cdot y\right) - -1 \cdot \left(y \cdot z\right)}{t}
\] |
|---|---|
rational.json-simplify-2 [<=]15.9 | \[ x + \frac{-1 \cdot \color{blue}{\left(y \cdot a\right)} - -1 \cdot \left(y \cdot z\right)}{t}
\] |
rational.json-simplify-43 [=>]15.9 | \[ x + \frac{\color{blue}{y \cdot \left(a \cdot -1\right)} - -1 \cdot \left(y \cdot z\right)}{t}
\] |
rational.json-simplify-43 [=>]15.9 | \[ x + \frac{y \cdot \left(a \cdot -1\right) - \color{blue}{y \cdot \left(z \cdot -1\right)}}{t}
\] |
rational.json-simplify-2 [=>]15.9 | \[ x + \frac{y \cdot \left(a \cdot -1\right) - \color{blue}{\left(z \cdot -1\right) \cdot y}}{t}
\] |
rational.json-simplify-52 [=>]15.9 | \[ x + \frac{\color{blue}{y \cdot \left(a \cdot -1 - z \cdot -1\right)}}{t}
\] |
rational.json-simplify-9 [=>]15.9 | \[ x + \frac{y \cdot \left(\color{blue}{\left(-a\right)} - z \cdot -1\right)}{t}
\] |
rational.json-simplify-12 [=>]15.9 | \[ x + \frac{y \cdot \left(\color{blue}{\left(0 - a\right)} - z \cdot -1\right)}{t}
\] |
rational.json-simplify-42 [=>]15.9 | \[ x + \frac{y \cdot \color{blue}{\left(\left(0 - z \cdot -1\right) - a\right)}}{t}
\] |
rational.json-simplify-8 [<=]15.9 | \[ x + \frac{y \cdot \left(\left(0 - \color{blue}{\left(-z\right)}\right) - a\right)}{t}
\] |
rational.json-simplify-12 [=>]15.9 | \[ x + \frac{y \cdot \left(\left(0 - \color{blue}{\left(0 - z\right)}\right) - a\right)}{t}
\] |
rational.json-simplify-45 [=>]15.9 | \[ x + \frac{y \cdot \left(\color{blue}{\left(z - \left(0 - 0\right)\right)} - a\right)}{t}
\] |
metadata-eval [=>]15.9 | \[ x + \frac{y \cdot \left(\left(z - \color{blue}{0}\right) - a\right)}{t}
\] |
rational.json-simplify-5 [=>]15.9 | \[ x + \frac{y \cdot \left(\color{blue}{z} - a\right)}{t}
\] |
rational.json-simplify-2 [=>]15.9 | \[ x + \frac{\color{blue}{\left(z - a\right) \cdot y}}{t}
\] |
rational.json-simplify-49 [=>]8.3 | \[ x + \color{blue}{y \cdot \frac{z - a}{t}}
\] |
Final simplification5.9
| Alternative 1 | |
|---|---|
| Error | 14.5 |
| Cost | 1236 |
| Alternative 2 | |
|---|---|
| Error | 15.0 |
| Cost | 1104 |
| Alternative 3 | |
|---|---|
| Error | 13.4 |
| Cost | 840 |
| Alternative 4 | |
|---|---|
| Error | 11.2 |
| Cost | 840 |
| Alternative 5 | |
|---|---|
| Error | 22.7 |
| Cost | 712 |
| Alternative 6 | |
|---|---|
| Error | 22.9 |
| Cost | 712 |
| Alternative 7 | |
|---|---|
| Error | 14.8 |
| Cost | 712 |
| Alternative 8 | |
|---|---|
| Error | 20.2 |
| Cost | 456 |
| Alternative 9 | |
|---|---|
| Error | 29.0 |
| Cost | 64 |
herbie shell --seed 2023074
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
:precision binary64
:herbie-target
(if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-7) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))
(- (+ x y) (/ (* (- z t) y) (- a t))))