| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 960 |
\[\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t_0} - \frac{y}{t_0}
\end{array}
\]

(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
(FPCore (x y) :precision binary64 (let* ((t_0 (- 2.0 (+ x y)))) (- (/ x t_0) (/ y t_0))))
double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x - y) / (2.0d0 - (x + y))
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 2.0d0 - (x + y)
code = (x / t_0) - (y / t_0)
end function
public static double code(double x, double y) {
return (x - y) / (2.0 - (x + y));
}
public static double code(double x, double y) {
double t_0 = 2.0 - (x + y);
return (x / t_0) - (y / t_0);
}
def code(x, y): return (x - y) / (2.0 - (x + y))
def code(x, y): t_0 = 2.0 - (x + y) return (x / t_0) - (y / t_0)
function code(x, y) return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y))) end
function code(x, y) t_0 = Float64(2.0 - Float64(x + y)) return Float64(Float64(x / t_0) - Float64(y / t_0)) end
function tmp = code(x, y) tmp = (x - y) / (2.0 - (x + y)); end
function tmp = code(x, y) t_0 = 2.0 - (x + y); tmp = (x / t_0) - (y / t_0); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]}, N[(N[(x / t$95$0), $MachinePrecision] - N[(y / t$95$0), $MachinePrecision]), $MachinePrecision]]
\frac{x - y}{2 - \left(x + y\right)}
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 - \left(x + y\right)\\
\frac{x}{t_0} - \frac{y}{t_0}
\end{array}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 100.0% |
|---|---|
| Target | 100.0% |
| Herbie | 100.0% |
Initial program 100.0%
Simplified100.0%
[Start]100.0% | \[ \frac{x - y}{2 - \left(x + y\right)}
\] |
|---|---|
associate--r+ [=>]100.0% | \[ \frac{x - y}{\color{blue}{\left(2 - x\right) - y}}
\] |
Applied egg-rr100.0%
[Start]100.0% | \[ \frac{x - y}{\left(2 - x\right) - y}
\] |
|---|---|
div-sub [=>]100.0% | \[ \color{blue}{\frac{x}{\left(2 - x\right) - y} - \frac{y}{\left(2 - x\right) - y}}
\] |
associate--l- [=>]100.0% | \[ \frac{x}{\color{blue}{2 - \left(x + y\right)}} - \frac{y}{\left(2 - x\right) - y}
\] |
associate--l- [=>]100.0% | \[ \frac{x}{2 - \left(x + y\right)} - \frac{y}{\color{blue}{2 - \left(x + y\right)}}
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 960 |
| Alternative 2 | |
|---|---|
| Accuracy | 59.7% |
| Cost | 988 |
| Alternative 3 | |
|---|---|
| Accuracy | 59.5% |
| Cost | 988 |
| Alternative 4 | |
|---|---|
| Accuracy | 71.5% |
| Cost | 976 |
| Alternative 5 | |
|---|---|
| Accuracy | 71.4% |
| Cost | 848 |
| Alternative 6 | |
|---|---|
| Accuracy | 60.2% |
| Cost | 724 |
| Alternative 7 | |
|---|---|
| Accuracy | 71.7% |
| Cost | 585 |
| Alternative 8 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 576 |
| Alternative 9 | |
|---|---|
| Accuracy | 62.1% |
| Cost | 328 |
| Alternative 10 | |
|---|---|
| Accuracy | 37.7% |
| Cost | 64 |
herbie shell --seed 2023167
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, C"
:precision binary64
:herbie-target
(- (/ x (- 2.0 (+ x y))) (/ y (- 2.0 (+ x y))))
(/ (- x y) (- 2.0 (+ x y))))