| Alternative 1 | |
|---|---|
| Accuracy | 73.8% |
| Cost | 713 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{+70} \lor \neg \left(x \leq 100000000\right):\\
\;\;\;\;1 + 2 \cdot \frac{y}{x}\\
\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.9%
[Start]100.0 | \[ \frac{x + y}{x - y}
\] |
|---|---|
add-log-exp [=>]99.9 | \[ \color{blue}{\log \left(e^{\frac{x + y}{x - y}}\right)}
\] |
Applied egg-rr34.1%
[Start]99.9 | \[ \log \left(e^{\frac{x + y}{x - y}}\right)
\] |
|---|---|
add-log-exp [<=]100.0 | \[ \color{blue}{\frac{x + y}{x - y}}
\] |
flip3-+ [=>]33.8 | \[ \frac{\color{blue}{\frac{{x}^{3} + {y}^{3}}{x \cdot x + \left(y \cdot y - x \cdot y\right)}}}{x - y}
\] |
associate-/r* [<=]33.8 | \[ \color{blue}{\frac{{x}^{3} + {y}^{3}}{\left(x \cdot x + \left(y \cdot y - x \cdot y\right)\right) \cdot \left(x - y\right)}}
\] |
sum-cubes [=>]33.9 | \[ \frac{\color{blue}{\left(x \cdot x + \left(y \cdot y - x \cdot y\right)\right) \cdot \left(x + y\right)}}{\left(x \cdot x + \left(y \cdot y - x \cdot y\right)\right) \cdot \left(x - y\right)}
\] |
associate-/l* [=>]34.1 | \[ \color{blue}{\frac{x \cdot x + \left(y \cdot y - x \cdot y\right)}{\frac{\left(x \cdot x + \left(y \cdot y - x \cdot y\right)\right) \cdot \left(x - y\right)}{x + y}}}
\] |
fma-def [=>]34.1 | \[ \frac{\color{blue}{\mathsf{fma}\left(x, x, y \cdot y - x \cdot y\right)}}{\frac{\left(x \cdot x + \left(y \cdot y - x \cdot y\right)\right) \cdot \left(x - y\right)}{x + y}}
\] |
distribute-rgt-out-- [=>]34.1 | \[ \frac{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y - x\right)}\right)}{\frac{\left(x \cdot x + \left(y \cdot y - x \cdot y\right)\right) \cdot \left(x - y\right)}{x + y}}
\] |
*-commutative [=>]34.1 | \[ \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\frac{\color{blue}{\left(x - y\right) \cdot \left(x \cdot x + \left(y \cdot y - x \cdot y\right)\right)}}{x + y}}
\] |
fma-def [=>]34.1 | \[ \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\frac{\left(x - y\right) \cdot \color{blue}{\mathsf{fma}\left(x, x, y \cdot y - x \cdot y\right)}}{x + y}}
\] |
distribute-rgt-out-- [=>]34.1 | \[ \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\frac{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y - x\right)}\right)}{x + y}}
\] |
Simplified34.0%
[Start]34.1 | \[ \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\frac{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{x + y}}
\] |
|---|---|
associate-/r/ [=>]34.0 | \[ \color{blue}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)} \cdot \left(x + y\right)}
\] |
Applied egg-rr100.0%
[Start]34.0 | \[ \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)} \cdot \left(x + y\right)
\] |
|---|---|
+-commutative [=>]34.0 | \[ \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)} \cdot \color{blue}{\left(y + x\right)}
\] |
distribute-rgt-in [=>]34.0 | \[ \color{blue}{y \cdot \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)} + x \cdot \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}}
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 73.8% |
| Cost | 713 |
| Alternative 2 | |
|---|---|
| Accuracy | 74.5% |
| Cost | 713 |
| Alternative 3 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 448 |
| Alternative 4 | |
|---|---|
| Accuracy | 72.9% |
| Cost | 328 |
| Alternative 5 | |
|---|---|
| Accuracy | 49.3% |
| Cost | 64 |
herbie shell --seed 2023137
(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)))