| Alternative 1 | |
|---|---|
| Accuracy | 60.7% |
| Cost | 585 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{-223} \lor \neg \left(y \leq 6.5 \cdot 10^{-139}\right):\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + -1\\
\end{array}
\]
(FPCore (x y) :precision binary64 (/ (fabs (- x y)) (fabs y)))
(FPCore (x y) :precision binary64 (fabs (- 1.0 (/ x y))))
double code(double x, double y) {
return fabs((x - y)) / fabs(y);
}
double code(double x, double y) {
return fabs((1.0 - (x / y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = abs((x - y)) / abs(y)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = abs((1.0d0 - (x / y)))
end function
public static double code(double x, double y) {
return Math.abs((x - y)) / Math.abs(y);
}
public static double code(double x, double y) {
return Math.abs((1.0 - (x / y)));
}
def code(x, y): return math.fabs((x - y)) / math.fabs(y)
def code(x, y): return math.fabs((1.0 - (x / y)))
function code(x, y) return Float64(abs(Float64(x - y)) / abs(y)) end
function code(x, y) return abs(Float64(1.0 - Float64(x / y))) end
function tmp = code(x, y) tmp = abs((x - y)) / abs(y); end
function tmp = code(x, y) tmp = abs((1.0 - (x / y))); end
code[x_, y_] := N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[Abs[N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\frac{\left|x - y\right|}{\left|y\right|}
\left|1 - \frac{x}{y}\right|
Results
Initial program 100.0%
Taylor expanded in x around -inf 100.0%
Simplified100.0%
[Start]100.0 | \[ \frac{\left|-\left(y + -1 \cdot x\right)\right|}{\left|y\right|}
\] |
|---|---|
fabs-neg [=>]100.0 | \[ \frac{\color{blue}{\left|y + -1 \cdot x\right|}}{\left|y\right|}
\] |
mul-1-neg [=>]100.0 | \[ \frac{\left|y + \color{blue}{\left(-x\right)}\right|}{\left|y\right|}
\] |
sub-neg [<=]100.0 | \[ \frac{\left|\color{blue}{y - x}\right|}{\left|y\right|}
\] |
fabs-div [<=]100.0 | \[ \color{blue}{\left|\frac{y - x}{y}\right|}
\] |
div-sub [=>]100.0 | \[ \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right|
\] |
*-inverses [=>]100.0 | \[ \left|\color{blue}{1} - \frac{x}{y}\right|
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 60.7% |
| Cost | 585 |
| Alternative 2 | |
|---|---|
| Accuracy | 22.7% |
| Cost | 192 |
| Alternative 3 | |
|---|---|
| Accuracy | 1.4% |
| Cost | 64 |
herbie shell --seed 2023147
(FPCore (x y)
:name "Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5"
:precision binary64
(/ (fabs (- x y)) (fabs y)))