| Alternative 1 | |
|---|---|
| Error | 7.9 |
| Cost | 3404 |
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ (- (/ (* y (- a z)) t)) x)))
(if (<= t -6.6e+206)
t_1
(if (<= t -5e-289)
(+ y (+ x (* y (- (/ (- z t) (- a t))))))
(if (<= t 1.8e+76) (+ x (- y (/ (* y (- z t)) (- a t)))) t_1)))))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 t_1 = -((y * (a - z)) / t) + x;
double tmp;
if (t <= -6.6e+206) {
tmp = t_1;
} else if (t <= -5e-289) {
tmp = y + (x + (y * -((z - t) / (a - t))));
} else if (t <= 1.8e+76) {
tmp = x + (y - ((y * (z - t)) / (a - t)));
} 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) * 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) :: t_1
real(8) :: tmp
t_1 = -((y * (a - z)) / t) + x
if (t <= (-6.6d+206)) then
tmp = t_1
else if (t <= (-5d-289)) then
tmp = y + (x + (y * -((z - t) / (a - t))))
else if (t <= 1.8d+76) then
tmp = x + (y - ((y * (z - t)) / (a - t)))
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) * y) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = -((y * (a - z)) / t) + x;
double tmp;
if (t <= -6.6e+206) {
tmp = t_1;
} else if (t <= -5e-289) {
tmp = y + (x + (y * -((z - t) / (a - t))));
} else if (t <= 1.8e+76) {
tmp = x + (y - ((y * (z - t)) / (a - t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): return (x + y) - (((z - t) * y) / (a - t))
def code(x, y, z, t, a): t_1 = -((y * (a - z)) / t) + x tmp = 0 if t <= -6.6e+206: tmp = t_1 elif t <= -5e-289: tmp = y + (x + (y * -((z - t) / (a - t)))) elif t <= 1.8e+76: tmp = x + (y - ((y * (z - t)) / (a - t))) else: tmp = t_1 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) t_1 = Float64(Float64(-Float64(Float64(y * Float64(a - z)) / t)) + x) tmp = 0.0 if (t <= -6.6e+206) tmp = t_1; elseif (t <= -5e-289) tmp = Float64(y + Float64(x + Float64(y * Float64(-Float64(Float64(z - t) / Float64(a - t)))))); elseif (t <= 1.8e+76) tmp = Float64(x + Float64(y - Float64(Float64(y * Float64(z - t)) / Float64(a - t)))); else tmp = t_1; 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) t_1 = -((y * (a - z)) / t) + x; tmp = 0.0; if (t <= -6.6e+206) tmp = t_1; elseif (t <= -5e-289) tmp = y + (x + (y * -((z - t) / (a - t)))); elseif (t <= 1.8e+76) tmp = x + (y - ((y * (z - t)) / (a - t))); else tmp = t_1; 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_] := Block[{t$95$1 = N[((-N[(N[(y * N[(a - z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]) + x), $MachinePrecision]}, If[LessEqual[t, -6.6e+206], t$95$1, If[LessEqual[t, -5e-289], N[(y + N[(x + N[(y * (-N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.8e+76], N[(x + N[(y - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
t_1 := \left(-\frac{y \cdot \left(a - z\right)}{t}\right) + x\\
\mathbf{if}\;t \leq -6.6 \cdot 10^{+206}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq -5 \cdot 10^{-289}:\\
\;\;\;\;y + \left(x + y \cdot \left(-\frac{z - t}{a - t}\right)\right)\\
\mathbf{elif}\;t \leq 1.8 \cdot 10^{+76}:\\
\;\;\;\;x + \left(y - \frac{y \cdot \left(z - t\right)}{a - t}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 16.1 |
|---|---|
| Target | 8.4 |
| Herbie | 9.7 |
if t < -6.59999999999999969e206 or 1.8000000000000001e76 < t Initial program 30.3
Simplified26.4
[Start]30.3 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]30.3 | \[ \color{blue}{\left(y + x\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
rational_best_oopsla_all_46_json_45_simplify-107 [=>]26.4 | \[ \color{blue}{x + \left(y - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]26.4 | \[ x + \left(y - \frac{\color{blue}{y \cdot \left(z - t\right)}}{a - t}\right)
\] |
Taylor expanded in t around -inf 14.6
Simplified14.6
[Start]14.6 | \[ -1 \cdot \frac{y \cdot a - y \cdot z}{t} + x
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]14.6 | \[ \color{blue}{\frac{y \cdot a - y \cdot z}{t} \cdot -1} + x
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]14.6 | \[ \color{blue}{\left(-\frac{y \cdot a - y \cdot z}{t}\right)} + x
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]14.6 | \[ \left(-\frac{\color{blue}{a \cdot y} - y \cdot z}{t}\right) + x
\] |
rational_best_oopsla_all_46_json_45_simplify-102 [=>]14.6 | \[ \left(-\frac{\color{blue}{y \cdot \left(a - z\right)}}{t}\right) + x
\] |
if -6.59999999999999969e206 < t < -5.00000000000000029e-289Initial program 12.5
Simplified10.7
[Start]12.5 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]12.5 | \[ \color{blue}{\left(y + x\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
rational_best_oopsla_all_46_json_45_simplify-107 [=>]10.7 | \[ \color{blue}{x + \left(y - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]10.7 | \[ x + \left(y - \frac{\color{blue}{y \cdot \left(z - t\right)}}{a - t}\right)
\] |
Taylor expanded in y around -inf 6.2
Simplified8.9
[Start]6.2 | \[ y \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right) + x
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]6.2 | \[ \color{blue}{x + y \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-37 [=>]6.2 | \[ x + \color{blue}{\left(1 \cdot y + y \cdot \left(-1 \cdot \frac{z - t}{a - t}\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]6.2 | \[ x + \left(\color{blue}{y \cdot 1} + y \cdot \left(-1 \cdot \frac{z - t}{a - t}\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]6.2 | \[ x + \left(\color{blue}{y} + y \cdot \left(-1 \cdot \frac{z - t}{a - t}\right)\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-82 [=>]8.9 | \[ \color{blue}{y + \left(x + y \cdot \left(-1 \cdot \frac{z - t}{a - t}\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]8.9 | \[ y + \left(x + y \cdot \color{blue}{\left(\frac{z - t}{a - t} \cdot -1\right)}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]8.9 | \[ y + \left(x + y \cdot \color{blue}{\left(-\frac{z - t}{a - t}\right)}\right)
\] |
if -5.00000000000000029e-289 < t < 1.8000000000000001e76Initial program 7.2
Simplified6.2
[Start]7.2 | \[ \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]7.2 | \[ \color{blue}{\left(y + x\right)} - \frac{\left(z - t\right) \cdot y}{a - t}
\] |
rational_best_oopsla_all_46_json_45_simplify-107 [=>]6.2 | \[ \color{blue}{x + \left(y - \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]6.2 | \[ x + \left(y - \frac{\color{blue}{y \cdot \left(z - t\right)}}{a - t}\right)
\] |
Final simplification9.7
| Alternative 1 | |
|---|---|
| Error | 7.9 |
| Cost | 3404 |
| Alternative 2 | |
|---|---|
| Error | 21.5 |
| Cost | 1304 |
| Alternative 3 | |
|---|---|
| Error | 20.8 |
| Cost | 1172 |
| Alternative 4 | |
|---|---|
| Error | 20.2 |
| Cost | 1104 |
| Alternative 5 | |
|---|---|
| Error | 12.6 |
| Cost | 972 |
| Alternative 6 | |
|---|---|
| Error | 10.6 |
| Cost | 968 |
| Alternative 7 | |
|---|---|
| Error | 15.0 |
| Cost | 908 |
| Alternative 8 | |
|---|---|
| Error | 11.4 |
| Cost | 904 |
| Alternative 9 | |
|---|---|
| Error | 20.5 |
| Cost | 456 |
| Alternative 10 | |
|---|---|
| Error | 27.3 |
| Cost | 328 |
| Alternative 11 | |
|---|---|
| Error | 28.7 |
| Cost | 64 |
herbie shell --seed 2023090
(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))))