Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5

Percentage Accurate: 100.0% → 100.0%
Time: 3.9s
Alternatives: 5
Speedup: 2.0×

Specification

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

\\
\frac{\left|x - y\right|}{\left|y\right|}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 5 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

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

\\
\frac{\left|x - y\right|}{\left|y\right|}
\end{array}

Alternative 1: 100.0% accurate, 2.0× speedup?

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

\\
\left|\frac{x}{y} + -1\right|
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{\left|x - y\right|}{\left|y\right|} \]
  2. Add Preprocessing
  3. Taylor expanded in x around -inf 100.0%

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

    \[\leadsto \color{blue}{\left|\frac{x}{y} + -1\right|} \]
  5. Add Preprocessing

Alternative 2: 74.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{+53}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{+83}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -3.7e+53) 1.0 (if (<= y 6.4e+83) (fabs (/ x y)) 1.0)))
double code(double x, double y) {
	double tmp;
	if (y <= -3.7e+53) {
		tmp = 1.0;
	} else if (y <= 6.4e+83) {
		tmp = fabs((x / y));
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-3.7d+53)) then
        tmp = 1.0d0
    else if (y <= 6.4d+83) then
        tmp = abs((x / y))
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -3.7e+53) {
		tmp = 1.0;
	} else if (y <= 6.4e+83) {
		tmp = Math.abs((x / y));
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -3.7e+53:
		tmp = 1.0
	elif y <= 6.4e+83:
		tmp = math.fabs((x / y))
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -3.7e+53)
		tmp = 1.0;
	elseif (y <= 6.4e+83)
		tmp = abs(Float64(x / y));
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -3.7e+53)
		tmp = 1.0;
	elseif (y <= 6.4e+83)
		tmp = abs((x / y));
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -3.7e+53], 1.0, If[LessEqual[y, 6.4e+83], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], 1.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{+53}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 6.4 \cdot 10^{+83}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.7e53 or 6.3999999999999998e83 < y

    1. Initial program 100.0%

      \[\frac{\left|x - y\right|}{\left|y\right|} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 100.0%

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

      \[\leadsto \color{blue}{\left|\frac{x}{y} + -1\right|} \]
    5. Taylor expanded in x around 0 89.4%

      \[\leadsto \left|\color{blue}{-1}\right| \]
    6. Applied egg-rr89.4%

      \[\leadsto \color{blue}{1} \]

    if -3.7e53 < y < 6.3999999999999998e83

    1. Initial program 100.0%

      \[\frac{\left|x - y\right|}{\left|y\right|} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 100.0%

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

      \[\leadsto \color{blue}{\left|\frac{x}{y} + -1\right|} \]
    5. Taylor expanded in x around inf 72.2%

      \[\leadsto \left|\color{blue}{\frac{x}{y}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 58.9% accurate, 11.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.32 \cdot 10^{+253}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{+145} \lor \neg \left(x \leq 4.1 \cdot 10^{+105}\right):\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.32e+253)
   (* x x)
   (if (or (<= x -1.25e+145) (not (<= x 4.1e+105))) (/ x y) 1.0)))
double code(double x, double y) {
	double tmp;
	if (x <= -1.32e+253) {
		tmp = x * x;
	} else if ((x <= -1.25e+145) || !(x <= 4.1e+105)) {
		tmp = x / y;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-1.32d+253)) then
        tmp = x * x
    else if ((x <= (-1.25d+145)) .or. (.not. (x <= 4.1d+105))) then
        tmp = x / y
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -1.32e+253) {
		tmp = x * x;
	} else if ((x <= -1.25e+145) || !(x <= 4.1e+105)) {
		tmp = x / y;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.32e+253:
		tmp = x * x
	elif (x <= -1.25e+145) or not (x <= 4.1e+105):
		tmp = x / y
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.32e+253)
		tmp = Float64(x * x);
	elseif ((x <= -1.25e+145) || !(x <= 4.1e+105))
		tmp = Float64(x / y);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.32e+253)
		tmp = x * x;
	elseif ((x <= -1.25e+145) || ~((x <= 4.1e+105)))
		tmp = x / y;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.32e+253], N[(x * x), $MachinePrecision], If[Or[LessEqual[x, -1.25e+145], N[Not[LessEqual[x, 4.1e+105]], $MachinePrecision]], N[(x / y), $MachinePrecision], 1.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.32 \cdot 10^{+253}:\\
\;\;\;\;x \cdot x\\

\mathbf{elif}\;x \leq -1.25 \cdot 10^{+145} \lor \neg \left(x \leq 4.1 \cdot 10^{+105}\right):\\
\;\;\;\;\frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.32e253

    1. Initial program 100.0%

      \[\frac{\left|x - y\right|}{\left|y\right|} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp74.8%

        \[\leadsto \color{blue}{\log \left(e^{\frac{\left|x - y\right|}{\left|y\right|}}\right)} \]
      2. *-un-lft-identity74.8%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\frac{\left|x - y\right|}{\left|y\right|}}\right)} \]
      3. log-prod74.8%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\frac{\left|x - y\right|}{\left|y\right|}}\right)} \]
      4. metadata-eval74.8%

        \[\leadsto \color{blue}{0} + \log \left(e^{\frac{\left|x - y\right|}{\left|y\right|}}\right) \]
      5. add-log-exp100.0%

        \[\leadsto 0 + \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
      6. add-sqr-sqrt0.0%

        \[\leadsto 0 + \frac{\left|\color{blue}{\sqrt{x - y} \cdot \sqrt{x - y}}\right|}{\left|y\right|} \]
      7. fabs-sqr0.0%

        \[\leadsto 0 + \frac{\color{blue}{\sqrt{x - y} \cdot \sqrt{x - y}}}{\left|y\right|} \]
      8. add-sqr-sqrt0.0%

        \[\leadsto 0 + \frac{\sqrt{x - y} \cdot \sqrt{x - y}}{\left|\color{blue}{\sqrt{y} \cdot \sqrt{y}}\right|} \]
      9. fabs-sqr0.0%

        \[\leadsto 0 + \frac{\sqrt{x - y} \cdot \sqrt{x - y}}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \]
      10. add-sqr-sqrt0.0%

        \[\leadsto 0 + \frac{\sqrt{x - y} \cdot \sqrt{x - y}}{\color{blue}{y}} \]
      11. add-sqr-sqrt33.4%

        \[\leadsto 0 + \frac{\color{blue}{x - y}}{y} \]
    4. Applied egg-rr33.4%

      \[\leadsto \color{blue}{0 + \frac{x - y}{y}} \]
    5. Taylor expanded in x around inf 33.4%

      \[\leadsto 0 + \frac{\color{blue}{x}}{y} \]
    6. Applied egg-rr74.8%

      \[\leadsto \color{blue}{x \cdot x} \]

    if -1.32e253 < x < -1.24999999999999992e145 or 4.1000000000000002e105 < x

    1. Initial program 99.9%

      \[\frac{\left|x - y\right|}{\left|y\right|} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-inv99.8%

        \[\leadsto \color{blue}{\left|x - y\right| \cdot \frac{1}{\left|y\right|}} \]
      2. add-sqr-sqrt69.0%

        \[\leadsto \left|\color{blue}{\sqrt{x - y} \cdot \sqrt{x - y}}\right| \cdot \frac{1}{\left|y\right|} \]
      3. fabs-sqr69.0%

        \[\leadsto \color{blue}{\left(\sqrt{x - y} \cdot \sqrt{x - y}\right)} \cdot \frac{1}{\left|y\right|} \]
      4. add-sqr-sqrt69.5%

        \[\leadsto \color{blue}{\left(x - y\right)} \cdot \frac{1}{\left|y\right|} \]
      5. *-commutative69.5%

        \[\leadsto \color{blue}{\frac{1}{\left|y\right|} \cdot \left(x - y\right)} \]
      6. add-sqr-sqrt42.7%

        \[\leadsto \frac{1}{\left|\color{blue}{\sqrt{y} \cdot \sqrt{y}}\right|} \cdot \left(x - y\right) \]
      7. fabs-sqr42.7%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \cdot \left(x - y\right) \]
      8. add-sqr-sqrt61.5%

        \[\leadsto \frac{1}{\color{blue}{y}} \cdot \left(x - y\right) \]
    4. Applied egg-rr61.5%

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(x - y\right)} \]
    5. Taylor expanded in x around inf 62.3%

      \[\leadsto \frac{1}{y} \cdot \color{blue}{x} \]
    6. Taylor expanded in y around 0 62.3%

      \[\leadsto \color{blue}{\frac{x}{y}} \]

    if -1.24999999999999992e145 < x < 4.1000000000000002e105

    1. Initial program 100.0%

      \[\frac{\left|x - y\right|}{\left|y\right|} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 100.0%

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

      \[\leadsto \color{blue}{\left|\frac{x}{y} + -1\right|} \]
    5. Taylor expanded in x around 0 66.8%

      \[\leadsto \left|\color{blue}{-1}\right| \]
    6. Applied egg-rr66.8%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification66.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.32 \cdot 10^{+253}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{+145} \lor \neg \left(x \leq 4.1 \cdot 10^{+105}\right):\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 57.9% accurate, 15.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{+172} \lor \neg \left(x \leq 6.5 \cdot 10^{+174}\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -2.9e+172) (not (<= x 6.5e+174))) (* x x) 1.0))
double code(double x, double y) {
	double tmp;
	if ((x <= -2.9e+172) || !(x <= 6.5e+174)) {
		tmp = x * x;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-2.9d+172)) .or. (.not. (x <= 6.5d+174))) then
        tmp = x * x
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -2.9e+172) || !(x <= 6.5e+174)) {
		tmp = x * x;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -2.9e+172) or not (x <= 6.5e+174):
		tmp = x * x
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -2.9e+172) || !(x <= 6.5e+174))
		tmp = Float64(x * x);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -2.9e+172) || ~((x <= 6.5e+174)))
		tmp = x * x;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -2.9e+172], N[Not[LessEqual[x, 6.5e+174]], $MachinePrecision]], N[(x * x), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+172} \lor \neg \left(x \leq 6.5 \cdot 10^{+174}\right):\\
\;\;\;\;x \cdot x\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.8999999999999999e172 or 6.5000000000000001e174 < x

    1. Initial program 99.9%

      \[\frac{\left|x - y\right|}{\left|y\right|} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp49.5%

        \[\leadsto \color{blue}{\log \left(e^{\frac{\left|x - y\right|}{\left|y\right|}}\right)} \]
      2. *-un-lft-identity49.5%

        \[\leadsto \log \color{blue}{\left(1 \cdot e^{\frac{\left|x - y\right|}{\left|y\right|}}\right)} \]
      3. log-prod49.5%

        \[\leadsto \color{blue}{\log 1 + \log \left(e^{\frac{\left|x - y\right|}{\left|y\right|}}\right)} \]
      4. metadata-eval49.5%

        \[\leadsto \color{blue}{0} + \log \left(e^{\frac{\left|x - y\right|}{\left|y\right|}}\right) \]
      5. add-log-exp99.9%

        \[\leadsto 0 + \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
      6. add-sqr-sqrt46.4%

        \[\leadsto 0 + \frac{\left|\color{blue}{\sqrt{x - y} \cdot \sqrt{x - y}}\right|}{\left|y\right|} \]
      7. fabs-sqr46.4%

        \[\leadsto 0 + \frac{\color{blue}{\sqrt{x - y} \cdot \sqrt{x - y}}}{\left|y\right|} \]
      8. add-sqr-sqrt30.8%

        \[\leadsto 0 + \frac{\sqrt{x - y} \cdot \sqrt{x - y}}{\left|\color{blue}{\sqrt{y} \cdot \sqrt{y}}\right|} \]
      9. fabs-sqr30.8%

        \[\leadsto 0 + \frac{\sqrt{x - y} \cdot \sqrt{x - y}}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \]
      10. add-sqr-sqrt31.0%

        \[\leadsto 0 + \frac{\sqrt{x - y} \cdot \sqrt{x - y}}{\color{blue}{y}} \]
      11. add-sqr-sqrt58.0%

        \[\leadsto 0 + \frac{\color{blue}{x - y}}{y} \]
    4. Applied egg-rr58.0%

      \[\leadsto \color{blue}{0 + \frac{x - y}{y}} \]
    5. Taylor expanded in x around inf 58.2%

      \[\leadsto 0 + \frac{\color{blue}{x}}{y} \]
    6. Applied egg-rr45.2%

      \[\leadsto \color{blue}{x \cdot x} \]

    if -2.8999999999999999e172 < x < 6.5000000000000001e174

    1. Initial program 100.0%

      \[\frac{\left|x - y\right|}{\left|y\right|} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 100.0%

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

      \[\leadsto \color{blue}{\left|\frac{x}{y} + -1\right|} \]
    5. Taylor expanded in x around 0 63.9%

      \[\leadsto \left|\color{blue}{-1}\right| \]
    6. Applied egg-rr63.9%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification60.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{+172} \lor \neg \left(x \leq 6.5 \cdot 10^{+174}\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 51.3% accurate, 205.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
	return 1.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0
end function
public static double code(double x, double y) {
	return 1.0;
}
def code(x, y):
	return 1.0
function code(x, y)
	return 1.0
end
function tmp = code(x, y)
	tmp = 1.0;
end
code[x_, y_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{\left|x - y\right|}{\left|y\right|} \]
  2. Add Preprocessing
  3. Taylor expanded in x around -inf 100.0%

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

    \[\leadsto \color{blue}{\left|\frac{x}{y} + -1\right|} \]
  5. Taylor expanded in x around 0 54.0%

    \[\leadsto \left|\color{blue}{-1}\right| \]
  6. Applied egg-rr54.0%

    \[\leadsto \color{blue}{1} \]
  7. Add Preprocessing

Reproduce

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