| Alternative 1 | |
|---|---|
| Accuracy | 74.1% |
| Cost | 456 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{+22}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+90}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
(FPCore (x y) :precision binary64 (/ x (+ y x)))
(FPCore (x y) :precision binary64 (* (/ (- y x) (+ y x)) (/ x (- y x))))
double code(double x, double y) {
return x / (y + x);
}
double code(double x, double y) {
return ((y - x) / (y + x)) * (x / (y - x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / (y + x)
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 - x))
end function
public static double code(double x, double y) {
return x / (y + x);
}
public static double code(double x, double y) {
return ((y - x) / (y + x)) * (x / (y - x));
}
def code(x, y): return x / (y + x)
def code(x, y): return ((y - x) / (y + x)) * (x / (y - x))
function code(x, y) return Float64(x / Float64(y + x)) end
function code(x, y) return Float64(Float64(Float64(y - x) / Float64(y + x)) * Float64(x / Float64(y - x))) end
function tmp = code(x, y) tmp = x / (y + x); end
function tmp = code(x, y) tmp = ((y - x) / (y + x)) * (x / (y - x)); end
code[x_, y_] := N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(N[(y - x), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x}{y + x}
\frac{y - x}{y + x} \cdot \frac{x}{y - x}
Results
Initial program 100.0%
Applied egg-rr55.5%
[Start]100.0 | \[ \frac{x}{y + x}
\] |
|---|---|
flip-+ [=>]58.5 | \[ \frac{x}{\color{blue}{\frac{y \cdot y - x \cdot x}{y - x}}}
\] |
associate-/r/ [=>]55.3 | \[ \color{blue}{\frac{x}{y \cdot y - x \cdot x} \cdot \left(y - x\right)}
\] |
fma-neg [=>]55.5 | \[ \frac{x}{\color{blue}{\mathsf{fma}\left(y, y, -x \cdot x\right)}} \cdot \left(y - x\right)
\] |
Simplified54.6%
[Start]55.5 | \[ \frac{x}{\mathsf{fma}\left(y, y, -x \cdot x\right)} \cdot \left(y - x\right)
\] |
|---|---|
associate-*l/ [=>]54.6 | \[ \color{blue}{\frac{x \cdot \left(y - x\right)}{\mathsf{fma}\left(y, y, -x \cdot x\right)}}
\] |
unpow2 [<=]54.6 | \[ \frac{x \cdot \left(y - x\right)}{\mathsf{fma}\left(y, y, -\color{blue}{{x}^{2}}\right)}
\] |
fma-neg [<=]54.6 | \[ \frac{x \cdot \left(y - x\right)}{\color{blue}{y \cdot y - {x}^{2}}}
\] |
unpow2 [=>]54.6 | \[ \frac{x \cdot \left(y - x\right)}{y \cdot y - \color{blue}{x \cdot x}}
\] |
Applied egg-rr100.0%
[Start]54.6 | \[ \frac{x \cdot \left(y - x\right)}{y \cdot y - x \cdot x}
\] |
|---|---|
*-commutative [=>]54.6 | \[ \frac{\color{blue}{\left(y - x\right) \cdot x}}{y \cdot y - x \cdot x}
\] |
difference-of-squares [=>]54.6 | \[ \frac{\left(y - x\right) \cdot x}{\color{blue}{\left(y + x\right) \cdot \left(y - x\right)}}
\] |
times-frac [=>]100.0 | \[ \color{blue}{\frac{y - x}{y + x} \cdot \frac{x}{y - x}}
\] |
+-commutative [=>]100.0 | \[ \frac{y - x}{\color{blue}{x + y}} \cdot \frac{x}{y - x}
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 74.1% |
| Cost | 456 |
| Alternative 2 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 320 |
| Alternative 3 | |
|---|---|
| Accuracy | 50.9% |
| Cost | 64 |
herbie shell --seed 2023157
(FPCore (x y)
:name "AI.Clustering.Hierarchical.Internal:average from clustering-0.2.1, B"
:precision binary64
(/ x (+ y x)))