| Alternative 1 | |
|---|---|
| Error | 17.2 |
| Cost | 712 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-87}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{+51}:\\
\;\;\;\;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 (* 0.5 (/ 2.0 (/ (+ x y) (- x y)))))
double code(double x, double y) {
return (x - y) / (x + y);
}
double code(double x, double y) {
return 0.5 * (2.0 / ((x + y) / (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 = 0.5d0 * (2.0d0 / ((x + y) / (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 0.5 * (2.0 / ((x + y) / (x - y)));
}
def code(x, y): return (x - y) / (x + y)
def code(x, y): return 0.5 * (2.0 / ((x + y) / (x - y)))
function code(x, y) return Float64(Float64(x - y) / Float64(x + y)) end
function code(x, y) return Float64(0.5 * Float64(2.0 / Float64(Float64(x + y) / Float64(x - y)))) end
function tmp = code(x, y) tmp = (x - y) / (x + y); end
function tmp = code(x, y) tmp = 0.5 * (2.0 / ((x + y) / (x - y))); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(0.5 * N[(2.0 / N[(N[(x + y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x - y}{x + y}
0.5 \cdot \frac{2}{\frac{x + y}{x - y}}
Results
| Original | 0.0 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 0.0
Applied egg-rr0.2
Simplified0.0
[Start]0.2 | \[ \left(x - y\right) \cdot \left(\frac{2}{x + y} \cdot 0.5\right)
\] |
|---|---|
rational.json-simplify-43 [<=]0.2 | \[ \color{blue}{0.5 \cdot \left(\left(x - y\right) \cdot \frac{2}{x + y}\right)}
\] |
rational.json-simplify-2 [=>]0.2 | \[ 0.5 \cdot \color{blue}{\left(\frac{2}{x + y} \cdot \left(x - y\right)\right)}
\] |
rational.json-simplify-7 [<=]0.2 | \[ 0.5 \cdot \left(\frac{2}{x + y} \cdot \color{blue}{\frac{x - y}{1}}\right)
\] |
rational.json-simplify-35 [=>]0.2 | \[ 0.5 \cdot \left(\frac{2}{x + y} \cdot \color{blue}{\frac{\left(x - y\right) + \left(x - y\right)}{1 + 1}}\right)
\] |
metadata-eval [=>]0.2 | \[ 0.5 \cdot \left(\frac{2}{x + y} \cdot \frac{\left(x - y\right) + \left(x - y\right)}{\color{blue}{2}}\right)
\] |
rational.json-simplify-55 [=>]0.1 | \[ 0.5 \cdot \color{blue}{\frac{\frac{\left(x - y\right) + \left(x - y\right)}{2}}{\frac{x + y}{2}}}
\] |
metadata-eval [<=]0.1 | \[ 0.5 \cdot \frac{\frac{\left(x - y\right) + \left(x - y\right)}{\color{blue}{1 + 1}}}{\frac{x + y}{2}}
\] |
rational.json-simplify-35 [<=]0.0 | \[ 0.5 \cdot \frac{\color{blue}{\frac{x - y}{1}}}{\frac{x + y}{2}}
\] |
rational.json-simplify-7 [=>]0.0 | \[ 0.5 \cdot \frac{\color{blue}{x - y}}{\frac{x + y}{2}}
\] |
rational.json-simplify-61 [<=]0.0 | \[ 0.5 \cdot \color{blue}{\frac{2}{\frac{x + y}{x - y}}}
\] |
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 17.2 |
| Cost | 712 |
| Alternative 2 | |
|---|---|
| Error | 0.0 |
| Cost | 448 |
| Alternative 3 | |
|---|---|
| Error | 17.7 |
| Cost | 328 |
| Alternative 4 | |
|---|---|
| Error | 32.4 |
| Cost | 64 |
herbie shell --seed 2023064
(FPCore (x y)
:name "Data.Colour.RGB:hslsv from colour-2.3.3, D"
:precision binary64
:herbie-target
(- (/ x (+ x y)) (/ y (+ x y)))
(/ (- x y) (+ x y)))