\[\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 | 18.2 |
|---|
| Cost | 6856 |
|---|
\[\begin{array}{l}
\mathbf{if}\;y \leq -2.6648091360231168 \cdot 10^{-67}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7.533623143703852 \cdot 10^{-28}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 25.1 |
|---|
| Cost | 840 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+126}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 6.0376406963748116 \cdot 10^{+50}:\\
\;\;\;\;\left(1 + \frac{y}{x + y}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 25.4 |
|---|
| Cost | 712 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+126}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 6.0376406963748116 \cdot 10^{+50}:\\
\;\;\;\;y \cdot \frac{1}{y - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 25.2 |
|---|
| Cost | 712 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+126}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 6.0376406963748116 \cdot 10^{+50}:\\
\;\;\;\;y \cdot \frac{1}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 25.1 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+126}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 6.0376406963748116 \cdot 10^{+50}:\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 24.8 |
|---|
| Cost | 456 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -5.6 \cdot 10^{+140}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 6.0376406963748116 \cdot 10^{+50}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 49.3 |
|---|
| Cost | 192 |
|---|
\[\frac{x}{y}
\]
| Alternative 8 |
|---|
| Error | 63.1 |
|---|
| Cost | 64 |
|---|
\[-1
\]