\[\frac{\left|x - y\right|}{\left|y\right|}
\]
↓
\[\left|1 - \frac{x}{y}\right|
\]
(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|
Alternatives
| Alternative 1 |
|---|
| Error | 17.7 |
|---|
| Cost | 7516 |
|---|
\[\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.1329364809276365 \cdot 10^{+34}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.5555939960240409 \cdot 10^{-25}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.615185901717486 \cdot 10^{-41}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.427075381726709 \cdot 10^{-154}:\\
\;\;\;\;\left(1 + \frac{y}{x + y}\right) + -1\\
\mathbf{elif}\;x \leq 9.712446762991152 \cdot 10^{-68}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.628969437061893 \cdot 10^{-47}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.0303605066907297 \cdot 10^{+44}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 25.4 |
|---|
| Cost | 976 |
|---|
\[\begin{array}{l}
t_0 := y \cdot \frac{1}{y - x}\\
t_1 := \frac{x}{y} + -1\\
\mathbf{if}\;y \leq -6.2 \cdot 10^{-233}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-158}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.716480590929634 \cdot 10^{-31}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.8135517851873296 \cdot 10^{-16}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 24.9 |
|---|
| Cost | 848 |
|---|
\[\begin{array}{l}
t_0 := \frac{y}{x + y}\\
t_1 := \frac{x}{y} + -1\\
\mathbf{if}\;y \leq -6.2 \cdot 10^{-233}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-158}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.716480590929634 \cdot 10^{-31}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.8135517851873296 \cdot 10^{-16}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 24.7 |
|---|
| Cost | 848 |
|---|
\[\begin{array}{l}
t_0 := \frac{x}{y} + -1\\
\mathbf{if}\;y \leq -6.2 \cdot 10^{-233}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-158}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.716480590929634 \cdot 10^{-31}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.8135517851873296 \cdot 10^{-16}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 49.2 |
|---|
| Cost | 192 |
|---|
\[\frac{x}{y}
\]
| Alternative 6 |
|---|
| Error | 63.1 |
|---|
| Cost | 64 |
|---|
\[-1
\]