| Alternative 1 | |
|---|---|
| Accuracy | 74.9% |
| Cost | 713 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -6400000000 \lor \neg \left(y \leq 8.6 \cdot 10^{-73}\right):\\
\;\;\;\;-2 \cdot \frac{x}{y} + -1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
(FPCore (x y) :precision binary64 (/ (+ x y) (- x y)))
(FPCore (x y) :precision binary64 (+ (/ y (- x y)) (/ x (- x y))))
double code(double x, double y) {
return (x + y) / (x - y);
}
double code(double x, double y) {
return (y / (x - y)) + (x / (x - y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + y) / (x - y)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y / (x - y)) + (x / (x - y))
end function
public static double code(double x, double y) {
return (x + y) / (x - y);
}
public static double code(double x, double y) {
return (y / (x - y)) + (x / (x - y));
}
def code(x, y): return (x + y) / (x - y)
def code(x, y): return (y / (x - y)) + (x / (x - y))
function code(x, y) return Float64(Float64(x + y) / Float64(x - y)) end
function code(x, y) return Float64(Float64(y / Float64(x - y)) + Float64(x / Float64(x - y))) end
function tmp = code(x, y) tmp = (x + y) / (x - y); end
function tmp = code(x, y) tmp = (y / (x - y)) + (x / (x - y)); end
code[x_, y_] := N[(N[(x + y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(y / N[(x - y), $MachinePrecision]), $MachinePrecision] + N[(x / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x + y}{x - y}
\frac{y}{x - y} + \frac{x}{x - y}
Results
| Original | 100.0% |
|---|---|
| Target | 100.0% |
| Herbie | 100.0% |
Initial program 100.0%
Applied egg-rr99.7%
[Start]100.0 | \[ \frac{x + y}{x - y}
\] |
|---|---|
div-inv [=>]99.7 | \[ \color{blue}{\left(x + y\right) \cdot \frac{1}{x - y}}
\] |
*-commutative [=>]99.7 | \[ \color{blue}{\frac{1}{x - y} \cdot \left(x + y\right)}
\] |
Applied egg-rr100.0%
[Start]99.7 | \[ \frac{1}{x - y} \cdot \left(x + y\right)
\] |
|---|---|
+-commutative [=>]99.7 | \[ \frac{1}{x - y} \cdot \color{blue}{\left(y + x\right)}
\] |
distribute-rgt-in [=>]99.7 | \[ \color{blue}{y \cdot \frac{1}{x - y} + x \cdot \frac{1}{x - y}}
\] |
un-div-inv [=>]99.9 | \[ \color{blue}{\frac{y}{x - y}} + x \cdot \frac{1}{x - y}
\] |
un-div-inv [=>]100.0 | \[ \frac{y}{x - y} + \color{blue}{\frac{x}{x - y}}
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 74.9% |
| Cost | 713 |
| Alternative 2 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 448 |
| Alternative 3 | |
|---|---|
| Accuracy | 74.4% |
| Cost | 328 |
| Alternative 4 | |
|---|---|
| Accuracy | 49.0% |
| Cost | 64 |
herbie shell --seed 2023138
(FPCore (x y)
:name "Linear.Projection:perspective from linear-1.19.1.3, A"
:precision binary64
:herbie-target
(/ 1.0 (- (/ x (+ x y)) (/ y (+ x y))))
(/ (+ x y) (- x y)))