| Alternative 1 | |
|---|---|
| Error | 0.9 |
| Cost | 584 |
(FPCore (x y) :precision binary64 (/ (* x y) (+ y 1.0)))
(FPCore (x y)
:precision binary64
(let* ((t_0 (- x (/ x y))))
(if (<= y -33000000.0)
t_0
(if (<= y 155000000.0) (/ (* x y) (+ y 1.0)) t_0))))double code(double x, double y) {
return (x * y) / (y + 1.0);
}
double code(double x, double y) {
double t_0 = x - (x / y);
double tmp;
if (y <= -33000000.0) {
tmp = t_0;
} else if (y <= 155000000.0) {
tmp = (x * y) / (y + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (y + 1.0d0)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x - (x / y)
if (y <= (-33000000.0d0)) then
tmp = t_0
else if (y <= 155000000.0d0) then
tmp = (x * y) / (y + 1.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
return (x * y) / (y + 1.0);
}
public static double code(double x, double y) {
double t_0 = x - (x / y);
double tmp;
if (y <= -33000000.0) {
tmp = t_0;
} else if (y <= 155000000.0) {
tmp = (x * y) / (y + 1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): return (x * y) / (y + 1.0)
def code(x, y): t_0 = x - (x / y) tmp = 0 if y <= -33000000.0: tmp = t_0 elif y <= 155000000.0: tmp = (x * y) / (y + 1.0) else: tmp = t_0 return tmp
function code(x, y) return Float64(Float64(x * y) / Float64(y + 1.0)) end
function code(x, y) t_0 = Float64(x - Float64(x / y)) tmp = 0.0 if (y <= -33000000.0) tmp = t_0; elseif (y <= 155000000.0) tmp = Float64(Float64(x * y) / Float64(y + 1.0)); else tmp = t_0; end return tmp end
function tmp = code(x, y) tmp = (x * y) / (y + 1.0); end
function tmp_2 = code(x, y) t_0 = x - (x / y); tmp = 0.0; if (y <= -33000000.0) tmp = t_0; elseif (y <= 155000000.0) tmp = (x * y) / (y + 1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -33000000.0], t$95$0, If[LessEqual[y, 155000000.0], N[(N[(x * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{x \cdot y}{y + 1}
\begin{array}{l}
t_0 := x - \frac{x}{y}\\
\mathbf{if}\;y \leq -33000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 155000000:\\
\;\;\;\;\frac{x \cdot y}{y + 1}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
Results
| Original | 8.4 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
if y < -3.3e7 or 1.55e8 < y Initial program 17.2
Taylor expanded in y around inf 0.0
Simplified0.0
[Start]0.0 | \[ -1 \cdot \frac{x}{y} + x
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.0 | \[ \color{blue}{x + -1 \cdot \frac{x}{y}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.0 | \[ x + \color{blue}{\frac{x}{y} \cdot -1}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]0.0 | \[ x + \color{blue}{\left(-\frac{x}{y}\right)}
\] |
Taylor expanded in y around 0 0.0
Simplified0.0
[Start]0.0 | \[ x + -1 \cdot \frac{x}{y}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.0 | \[ x + \color{blue}{\frac{x}{y} \cdot -1}
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]0.0 | \[ x + \color{blue}{\left(-\frac{x}{y}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-97 [=>]0.0 | \[ x + \color{blue}{\left(0 - \frac{x}{y}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-108 [=>]0.0 | \[ \color{blue}{\left(0 + x\right) - \frac{x}{y}}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.0 | \[ \color{blue}{\left(x + 0\right)} - \frac{x}{y}
\] |
rational_best_oopsla_all_46_json_45_simplify-38 [<=]0.0 | \[ \left(x + \color{blue}{\frac{x - \frac{x}{y}}{x - \frac{x}{y}} \cdot 0}\right) - \frac{x}{y}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]0.0 | \[ \left(x + \color{blue}{0 \cdot \frac{x - \frac{x}{y}}{x - \frac{x}{y}}}\right) - \frac{x}{y}
\] |
rational_best_oopsla_all_46_json_45_simplify-108 [<=]0.0 | \[ \color{blue}{0 \cdot \frac{x - \frac{x}{y}}{x - \frac{x}{y}} + \left(x - \frac{x}{y}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.0 | \[ \color{blue}{\left(x - \frac{x}{y}\right) + 0 \cdot \frac{x - \frac{x}{y}}{x - \frac{x}{y}}}
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [<=]0.0 | \[ \color{blue}{\left(x - \frac{x}{y}\right) \cdot 1} + 0 \cdot \frac{x - \frac{x}{y}}{x - \frac{x}{y}}
\] |
rational_best_oopsla_all_46_json_45_simplify-89 [=>]0.0 | \[ \color{blue}{\left(x - \frac{x}{y}\right) \cdot \left(1 \cdot \frac{x - \frac{x}{y}}{x - \frac{x}{y}}\right)} + 0 \cdot \frac{x - \frac{x}{y}}{x - \frac{x}{y}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.0 | \[ \left(x - \frac{x}{y}\right) \cdot \color{blue}{\left(\frac{x - \frac{x}{y}}{x - \frac{x}{y}} \cdot 1\right)} + 0 \cdot \frac{x - \frac{x}{y}}{x - \frac{x}{y}}
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]0.0 | \[ \left(x - \frac{x}{y}\right) \cdot \color{blue}{\frac{x - \frac{x}{y}}{x - \frac{x}{y}}} + 0 \cdot \frac{x - \frac{x}{y}}{x - \frac{x}{y}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.0 | \[ \color{blue}{\frac{x - \frac{x}{y}}{x - \frac{x}{y}} \cdot \left(x - \frac{x}{y}\right)} + 0 \cdot \frac{x - \frac{x}{y}}{x - \frac{x}{y}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.0 | \[ \frac{x - \frac{x}{y}}{x - \frac{x}{y}} \cdot \left(x - \frac{x}{y}\right) + \color{blue}{\frac{x - \frac{x}{y}}{x - \frac{x}{y}} \cdot 0}
\] |
rational_best_oopsla_all_46_json_45_simplify-38 [=>]0.0 | \[ \frac{x - \frac{x}{y}}{x - \frac{x}{y}} \cdot \left(x - \frac{x}{y}\right) + \color{blue}{0}
\] |
rational_best_oopsla_all_46_json_45_simplify-38 [<=]0.0 | \[ \frac{x - \frac{x}{y}}{x - \frac{x}{y}} \cdot \left(x - \frac{x}{y}\right) + \color{blue}{\left(x - \frac{x}{y}\right) \cdot 0}
\] |
rational_best_oopsla_all_46_json_45_simplify-37 [<=]0.0 | \[ \color{blue}{\left(x - \frac{x}{y}\right) \cdot \left(\frac{x - \frac{x}{y}}{x - \frac{x}{y}} + 0\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-85 [=>]0.0 | \[ \left(x - \frac{x}{y}\right) \cdot \color{blue}{\frac{x - \frac{x}{y}}{x - \frac{x}{y}}}
\] |
if -3.3e7 < y < 1.55e8Initial program 0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.9 |
| Cost | 584 |
| Alternative 2 | |
|---|---|
| Error | 1.3 |
| Cost | 456 |
| Alternative 3 | |
|---|---|
| Error | 31.2 |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, B"
:precision binary64
:herbie-target
(if (< y -3693.8482788297247) (- (/ x (* y y)) (- (/ x y) x)) (if (< y 6799310503.41891) (/ (* x y) (+ y 1.0)) (- (/ x (* y y)) (- (/ x y) x))))
(/ (* x y) (+ y 1.0)))