?

Average Error: 0.0 → 0.0
Time: 1.3s
Precision: binary64
Cost: 6720

?

\[\frac{\left|x - y\right|}{\left|y\right|} \]
\[\left|\frac{x}{y} + -1\right| \]
(FPCore (x y) :precision binary64 (/ (fabs (- x y)) (fabs y)))
(FPCore (x y) :precision binary64 (fabs (+ (/ x y) -1.0)))
double code(double x, double y) {
	return fabs((x - y)) / fabs(y);
}
double code(double x, double y) {
	return fabs(((x / y) + -1.0));
}
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(((x / y) + (-1.0d0)))
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(((x / y) + -1.0));
}
def code(x, y):
	return math.fabs((x - y)) / math.fabs(y)
def code(x, y):
	return math.fabs(((x / y) + -1.0))
function code(x, y)
	return Float64(abs(Float64(x - y)) / abs(y))
end
function code(x, y)
	return abs(Float64(Float64(x / y) + -1.0))
end
function tmp = code(x, y)
	tmp = abs((x - y)) / abs(y);
end
function tmp = code(x, y)
	tmp = abs(((x / y) + -1.0));
end
code[x_, y_] := N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[Abs[N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]
\frac{\left|x - y\right|}{\left|y\right|}
\left|\frac{x}{y} + -1\right|

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.0

    \[\frac{\left|x - y\right|}{\left|y\right|} \]
  2. Taylor expanded in x around -inf 0.0

    \[\leadsto \color{blue}{\frac{\left|-\left(y + -1 \cdot x\right)\right|}{\left|y\right|}} \]
  3. Simplified0.0

    \[\leadsto \color{blue}{\left|1 - \frac{x}{y}\right|} \]
    Proof

    [Start]0.0

    \[ \frac{\left|-\left(y + -1 \cdot x\right)\right|}{\left|y\right|} \]

    mul-1-neg [=>]0.0

    \[ \frac{\left|-\left(y + \color{blue}{\left(-x\right)}\right)\right|}{\left|y\right|} \]

    sub-neg [<=]0.0

    \[ \frac{\left|-\color{blue}{\left(y - x\right)}\right|}{\left|y\right|} \]

    fabs-neg [=>]0.0

    \[ \frac{\color{blue}{\left|y - x\right|}}{\left|y\right|} \]

    fabs-div [<=]0.0

    \[ \color{blue}{\left|\frac{y - x}{y}\right|} \]

    div-sub [=>]0.0

    \[ \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]

    *-inverses [=>]0.0

    \[ \left|\color{blue}{1} - \frac{x}{y}\right| \]
  4. Final simplification0.0

    \[\leadsto \left|\frac{x}{y} + -1\right| \]

Alternatives

Alternative 1
Error49.4
Cost320
\[\frac{x}{y} + -1 \]

Error

Reproduce?

herbie shell --seed 2023031 
(FPCore (x y)
  :name "Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5"
  :precision binary64
  (/ (fabs (- x y)) (fabs y)))