Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5

Percentage Accurate: 100.0% → 100.0%
Time: 5.0s
Alternatives: 5
Speedup: 1.1×

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, 1.1× speedup?

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

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

    \[\frac{\left|x - y\right|}{\left|y\right|} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \frac{\left|\color{blue}{x - y}\right|}{\left|y\right|} \]
    2. neg-fabsN/A

      \[\leadsto \frac{\color{blue}{\left|\mathsf{neg}\left(\left(x - y\right)\right)\right|}}{\left|y\right|} \]
    3. div-fabsN/A

      \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
    4. lower-fabs.f64N/A

      \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
    5. lift--.f64N/A

      \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x - y\right)}\right)}{y}\right| \]
    6. sub-negN/A

      \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)}\right)}{y}\right| \]
    7. +-commutativeN/A

      \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
    8. distribute-neg-inN/A

      \[\leadsto \left|\frac{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{y}\right| \]
    9. remove-double-negN/A

      \[\leadsto \left|\frac{\color{blue}{y} + \left(\mathsf{neg}\left(x\right)\right)}{y}\right| \]
    10. sub-negN/A

      \[\leadsto \left|\frac{\color{blue}{y - x}}{y}\right| \]
    11. div-subN/A

      \[\leadsto \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]
    12. *-inversesN/A

      \[\leadsto \left|\color{blue}{1} - \frac{x}{y}\right| \]
    13. lower--.f64N/A

      \[\leadsto \left|\color{blue}{1 - \frac{x}{y}}\right| \]
    14. lower-/.f64100.0

      \[\leadsto \left|1 - \color{blue}{\frac{x}{y}}\right| \]
  4. Applied egg-rr100.0%

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

Alternative 2: 73.7% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\left|x - y\right|}{\left|y\right|}\\
\mathbf{if}\;t\_0 \leq 2:\\
\;\;\;\;1\\

\mathbf{elif}\;t\_0 \leq 10^{+258}:\\
\;\;\;\;\frac{-x}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y)) < 2

    1. Initial program 100.0%

      \[\frac{\left|x - y\right|}{\left|y\right|} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{\left|\color{blue}{x - y}\right|}{\left|y\right|} \]
      2. neg-fabsN/A

        \[\leadsto \frac{\color{blue}{\left|\mathsf{neg}\left(\left(x - y\right)\right)\right|}}{\left|y\right|} \]
      3. div-fabsN/A

        \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
      4. lower-fabs.f64N/A

        \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
      5. lift--.f64N/A

        \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x - y\right)}\right)}{y}\right| \]
      6. sub-negN/A

        \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)}\right)}{y}\right| \]
      7. +-commutativeN/A

        \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
      8. distribute-neg-inN/A

        \[\leadsto \left|\frac{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{y}\right| \]
      9. remove-double-negN/A

        \[\leadsto \left|\frac{\color{blue}{y} + \left(\mathsf{neg}\left(x\right)\right)}{y}\right| \]
      10. sub-negN/A

        \[\leadsto \left|\frac{\color{blue}{y - x}}{y}\right| \]
      11. div-subN/A

        \[\leadsto \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]
      12. *-inversesN/A

        \[\leadsto \left|\color{blue}{1} - \frac{x}{y}\right| \]
      13. lower--.f64N/A

        \[\leadsto \left|\color{blue}{1 - \frac{x}{y}}\right| \]
      14. lower-/.f64100.0

        \[\leadsto \left|1 - \color{blue}{\frac{x}{y}}\right| \]
    4. Applied egg-rr100.0%

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

      \[\leadsto \left|\color{blue}{1}\right| \]
    6. Step-by-step derivation
      1. Simplified98.8%

        \[\leadsto \left|\color{blue}{1}\right| \]
      2. Step-by-step derivation
        1. metadata-eval98.8

          \[\leadsto \color{blue}{1} \]
      3. Applied egg-rr98.8%

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

      if 2 < (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y)) < 1.00000000000000006e258

      1. Initial program 100.0%

        \[\frac{\left|x - y\right|}{\left|y\right|} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \frac{\left|\color{blue}{x - y}\right|}{\left|y\right|} \]
        2. neg-fabsN/A

          \[\leadsto \frac{\color{blue}{\left|\mathsf{neg}\left(\left(x - y\right)\right)\right|}}{\left|y\right|} \]
        3. div-fabsN/A

          \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
        4. lower-fabs.f64N/A

          \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
        5. lift--.f64N/A

          \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x - y\right)}\right)}{y}\right| \]
        6. sub-negN/A

          \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)}\right)}{y}\right| \]
        7. +-commutativeN/A

          \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
        8. distribute-neg-inN/A

          \[\leadsto \left|\frac{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{y}\right| \]
        9. remove-double-negN/A

          \[\leadsto \left|\frac{\color{blue}{y} + \left(\mathsf{neg}\left(x\right)\right)}{y}\right| \]
        10. sub-negN/A

          \[\leadsto \left|\frac{\color{blue}{y - x}}{y}\right| \]
        11. div-subN/A

          \[\leadsto \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]
        12. *-inversesN/A

          \[\leadsto \left|\color{blue}{1} - \frac{x}{y}\right| \]
        13. lower--.f64N/A

          \[\leadsto \left|\color{blue}{1 - \frac{x}{y}}\right| \]
        14. lower-/.f64100.0

          \[\leadsto \left|1 - \color{blue}{\frac{x}{y}}\right| \]
      4. Applied egg-rr100.0%

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

        \[\leadsto \left|\color{blue}{-1 \cdot \frac{x}{y}}\right| \]
      6. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \left|\color{blue}{\mathsf{neg}\left(\frac{x}{y}\right)}\right| \]
        2. distribute-neg-frac2N/A

          \[\leadsto \left|\color{blue}{\frac{x}{\mathsf{neg}\left(y\right)}}\right| \]
        3. lower-/.f64N/A

          \[\leadsto \left|\color{blue}{\frac{x}{\mathsf{neg}\left(y\right)}}\right| \]
        4. lower-neg.f6496.6

          \[\leadsto \left|\frac{x}{\color{blue}{-y}}\right| \]
      7. Simplified96.6%

        \[\leadsto \left|\color{blue}{\frac{x}{-y}}\right| \]
      8. Step-by-step derivation
        1. lift-neg.f64N/A

          \[\leadsto \left|\frac{x}{\color{blue}{\mathsf{neg}\left(y\right)}}\right| \]
        2. clear-numN/A

          \[\leadsto \left|\color{blue}{\frac{1}{\frac{\mathsf{neg}\left(y\right)}{x}}}\right| \]
        3. inv-powN/A

          \[\leadsto \left|\color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{-1}}\right| \]
        4. sqr-powN/A

          \[\leadsto \left|\color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)}}\right| \]
        5. fabs-sqrN/A

          \[\leadsto \color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)}} \]
        6. sqr-powN/A

          \[\leadsto \color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{-1}} \]
        7. inv-powN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{neg}\left(y\right)}{x}}} \]
        8. clear-numN/A

          \[\leadsto \color{blue}{\frac{x}{\mathsf{neg}\left(y\right)}} \]
        9. frac-2negN/A

          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}} \]
        10. lift-neg.f64N/A

          \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)} \]
        11. remove-double-negN/A

          \[\leadsto \frac{\mathsf{neg}\left(x\right)}{\color{blue}{y}} \]
        12. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x\right)}{y}} \]
        13. lower-neg.f6456.4

          \[\leadsto \frac{\color{blue}{-x}}{y} \]
      9. Applied egg-rr56.4%

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

      if 1.00000000000000006e258 < (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y))

      1. Initial program 100.0%

        \[\frac{\left|x - y\right|}{\left|y\right|} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \frac{\left|\color{blue}{x - y}\right|}{\left|y\right|} \]
        2. neg-fabsN/A

          \[\leadsto \frac{\color{blue}{\left|\mathsf{neg}\left(\left(x - y\right)\right)\right|}}{\left|y\right|} \]
        3. div-fabsN/A

          \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
        4. lower-fabs.f64N/A

          \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
        5. lift--.f64N/A

          \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x - y\right)}\right)}{y}\right| \]
        6. sub-negN/A

          \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)}\right)}{y}\right| \]
        7. +-commutativeN/A

          \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
        8. distribute-neg-inN/A

          \[\leadsto \left|\frac{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{y}\right| \]
        9. remove-double-negN/A

          \[\leadsto \left|\frac{\color{blue}{y} + \left(\mathsf{neg}\left(x\right)\right)}{y}\right| \]
        10. sub-negN/A

          \[\leadsto \left|\frac{\color{blue}{y - x}}{y}\right| \]
        11. div-subN/A

          \[\leadsto \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]
        12. *-inversesN/A

          \[\leadsto \left|\color{blue}{1} - \frac{x}{y}\right| \]
        13. lower--.f64N/A

          \[\leadsto \left|\color{blue}{1 - \frac{x}{y}}\right| \]
        14. lower-/.f64100.0

          \[\leadsto \left|1 - \color{blue}{\frac{x}{y}}\right| \]
      4. Applied egg-rr100.0%

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

        \[\leadsto \left|\color{blue}{-1 \cdot \frac{x}{y}}\right| \]
      6. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \left|\color{blue}{\mathsf{neg}\left(\frac{x}{y}\right)}\right| \]
        2. distribute-neg-frac2N/A

          \[\leadsto \left|\color{blue}{\frac{x}{\mathsf{neg}\left(y\right)}}\right| \]
        3. lower-/.f64N/A

          \[\leadsto \left|\color{blue}{\frac{x}{\mathsf{neg}\left(y\right)}}\right| \]
        4. lower-neg.f64100.0

          \[\leadsto \left|\frac{x}{\color{blue}{-y}}\right| \]
      7. Simplified100.0%

        \[\leadsto \left|\color{blue}{\frac{x}{-y}}\right| \]
      8. Step-by-step derivation
        1. lift-neg.f64N/A

          \[\leadsto \left|\frac{x}{\color{blue}{\mathsf{neg}\left(y\right)}}\right| \]
        2. clear-numN/A

          \[\leadsto \left|\color{blue}{\frac{1}{\frac{\mathsf{neg}\left(y\right)}{x}}}\right| \]
        3. inv-powN/A

          \[\leadsto \left|\color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{-1}}\right| \]
        4. sqr-powN/A

          \[\leadsto \left|\color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)}}\right| \]
        5. fabs-sqrN/A

          \[\leadsto \color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)}} \]
        6. pow-prod-downN/A

          \[\leadsto \color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x} \cdot \frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)}} \]
        7. sqr-negN/A

          \[\leadsto {\color{blue}{\left(\left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)\right)\right)}}^{\left(\frac{-1}{2}\right)} \]
        8. lift-neg.f64N/A

          \[\leadsto {\left(\left(\mathsf{neg}\left(\frac{\color{blue}{\mathsf{neg}\left(y\right)}}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \]
        9. distribute-frac-negN/A

          \[\leadsto {\left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{y}{x}\right)\right)}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \]
        10. remove-double-negN/A

          \[\leadsto {\left(\color{blue}{\frac{y}{x}} \cdot \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \]
        11. lift-neg.f64N/A

          \[\leadsto {\left(\frac{y}{x} \cdot \left(\mathsf{neg}\left(\frac{\color{blue}{\mathsf{neg}\left(y\right)}}{x}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \]
        12. distribute-frac-negN/A

          \[\leadsto {\left(\frac{y}{x} \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{y}{x}\right)\right)}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \]
        13. remove-double-negN/A

          \[\leadsto {\left(\frac{y}{x} \cdot \color{blue}{\frac{y}{x}}\right)}^{\left(\frac{-1}{2}\right)} \]
        14. pow-prod-downN/A

          \[\leadsto \color{blue}{{\left(\frac{y}{x}\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\frac{y}{x}\right)}^{\left(\frac{-1}{2}\right)}} \]
        15. sqr-powN/A

          \[\leadsto \color{blue}{{\left(\frac{y}{x}\right)}^{-1}} \]
        16. inv-powN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{y}{x}}} \]
        17. clear-numN/A

          \[\leadsto \color{blue}{\frac{x}{y}} \]
        18. lower-/.f6456.8

          \[\leadsto \color{blue}{\frac{x}{y}} \]
      9. Applied egg-rr56.8%

        \[\leadsto \color{blue}{\frac{x}{y}} \]
    7. Recombined 3 regimes into one program.
    8. Add Preprocessing

    Alternative 3: 97.9% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\left|x - y\right|}{\left|y\right|} \leq 2:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (if (<= (/ (fabs (- x y)) (fabs y)) 2.0) 1.0 (fabs (/ x y))))
    double code(double x, double y) {
    	double tmp;
    	if ((fabs((x - y)) / fabs(y)) <= 2.0) {
    		tmp = 1.0;
    	} else {
    		tmp = fabs((x / y));
    	}
    	return tmp;
    }
    
    real(8) function code(x, y)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8) :: tmp
        if ((abs((x - y)) / abs(y)) <= 2.0d0) then
            tmp = 1.0d0
        else
            tmp = abs((x / y))
        end if
        code = tmp
    end function
    
    public static double code(double x, double y) {
    	double tmp;
    	if ((Math.abs((x - y)) / Math.abs(y)) <= 2.0) {
    		tmp = 1.0;
    	} else {
    		tmp = Math.abs((x / y));
    	}
    	return tmp;
    }
    
    def code(x, y):
    	tmp = 0
    	if (math.fabs((x - y)) / math.fabs(y)) <= 2.0:
    		tmp = 1.0
    	else:
    		tmp = math.fabs((x / y))
    	return tmp
    
    function code(x, y)
    	tmp = 0.0
    	if (Float64(abs(Float64(x - y)) / abs(y)) <= 2.0)
    		tmp = 1.0;
    	else
    		tmp = abs(Float64(x / y));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y)
    	tmp = 0.0;
    	if ((abs((x - y)) / abs(y)) <= 2.0)
    		tmp = 1.0;
    	else
    		tmp = abs((x / y));
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_] := If[LessEqual[N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision], 2.0], 1.0, N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;\frac{\left|x - y\right|}{\left|y\right|} \leq 2:\\
    \;\;\;\;1\\
    
    \mathbf{else}:\\
    \;\;\;\;\left|\frac{x}{y}\right|\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y)) < 2

      1. Initial program 100.0%

        \[\frac{\left|x - y\right|}{\left|y\right|} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift--.f64N/A

          \[\leadsto \frac{\left|\color{blue}{x - y}\right|}{\left|y\right|} \]
        2. neg-fabsN/A

          \[\leadsto \frac{\color{blue}{\left|\mathsf{neg}\left(\left(x - y\right)\right)\right|}}{\left|y\right|} \]
        3. div-fabsN/A

          \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
        4. lower-fabs.f64N/A

          \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
        5. lift--.f64N/A

          \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x - y\right)}\right)}{y}\right| \]
        6. sub-negN/A

          \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)}\right)}{y}\right| \]
        7. +-commutativeN/A

          \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
        8. distribute-neg-inN/A

          \[\leadsto \left|\frac{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{y}\right| \]
        9. remove-double-negN/A

          \[\leadsto \left|\frac{\color{blue}{y} + \left(\mathsf{neg}\left(x\right)\right)}{y}\right| \]
        10. sub-negN/A

          \[\leadsto \left|\frac{\color{blue}{y - x}}{y}\right| \]
        11. div-subN/A

          \[\leadsto \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]
        12. *-inversesN/A

          \[\leadsto \left|\color{blue}{1} - \frac{x}{y}\right| \]
        13. lower--.f64N/A

          \[\leadsto \left|\color{blue}{1 - \frac{x}{y}}\right| \]
        14. lower-/.f64100.0

          \[\leadsto \left|1 - \color{blue}{\frac{x}{y}}\right| \]
      4. Applied egg-rr100.0%

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

        \[\leadsto \left|\color{blue}{1}\right| \]
      6. Step-by-step derivation
        1. Simplified98.8%

          \[\leadsto \left|\color{blue}{1}\right| \]
        2. Step-by-step derivation
          1. metadata-eval98.8

            \[\leadsto \color{blue}{1} \]
        3. Applied egg-rr98.8%

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

        if 2 < (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y))

        1. Initial program 100.0%

          \[\frac{\left|x - y\right|}{\left|y\right|} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \frac{\left|\color{blue}{x - y}\right|}{\left|y\right|} \]
          2. neg-fabsN/A

            \[\leadsto \frac{\color{blue}{\left|\mathsf{neg}\left(\left(x - y\right)\right)\right|}}{\left|y\right|} \]
          3. div-fabsN/A

            \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
          4. lower-fabs.f64N/A

            \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
          5. lift--.f64N/A

            \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x - y\right)}\right)}{y}\right| \]
          6. sub-negN/A

            \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)}\right)}{y}\right| \]
          7. +-commutativeN/A

            \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
          8. distribute-neg-inN/A

            \[\leadsto \left|\frac{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{y}\right| \]
          9. remove-double-negN/A

            \[\leadsto \left|\frac{\color{blue}{y} + \left(\mathsf{neg}\left(x\right)\right)}{y}\right| \]
          10. sub-negN/A

            \[\leadsto \left|\frac{\color{blue}{y - x}}{y}\right| \]
          11. div-subN/A

            \[\leadsto \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]
          12. *-inversesN/A

            \[\leadsto \left|\color{blue}{1} - \frac{x}{y}\right| \]
          13. lower--.f64N/A

            \[\leadsto \left|\color{blue}{1 - \frac{x}{y}}\right| \]
          14. lower-/.f64100.0

            \[\leadsto \left|1 - \color{blue}{\frac{x}{y}}\right| \]
        4. Applied egg-rr100.0%

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

          \[\leadsto \left|\color{blue}{-1 \cdot \frac{x}{y}}\right| \]
        6. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \left|\color{blue}{\mathsf{neg}\left(\frac{x}{y}\right)}\right| \]
          2. distribute-neg-frac2N/A

            \[\leadsto \left|\color{blue}{\frac{x}{\mathsf{neg}\left(y\right)}}\right| \]
          3. lower-/.f64N/A

            \[\leadsto \left|\color{blue}{\frac{x}{\mathsf{neg}\left(y\right)}}\right| \]
          4. lower-neg.f6497.6

            \[\leadsto \left|\frac{x}{\color{blue}{-y}}\right| \]
        7. Simplified97.6%

          \[\leadsto \left|\color{blue}{\frac{x}{-y}}\right| \]
      7. Recombined 2 regimes into one program.
      8. Final simplification98.3%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left|x - y\right|}{\left|y\right|} \leq 2:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]
      9. Add Preprocessing

      Alternative 4: 72.8% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\left|x - y\right|}{\left|y\right|} \leq 100000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (if (<= (/ (fabs (- x y)) (fabs y)) 100000.0) 1.0 (/ x y)))
      double code(double x, double y) {
      	double tmp;
      	if ((fabs((x - y)) / fabs(y)) <= 100000.0) {
      		tmp = 1.0;
      	} else {
      		tmp = x / y;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8) :: tmp
          if ((abs((x - y)) / abs(y)) <= 100000.0d0) then
              tmp = 1.0d0
          else
              tmp = x / y
          end if
          code = tmp
      end function
      
      public static double code(double x, double y) {
      	double tmp;
      	if ((Math.abs((x - y)) / Math.abs(y)) <= 100000.0) {
      		tmp = 1.0;
      	} else {
      		tmp = x / y;
      	}
      	return tmp;
      }
      
      def code(x, y):
      	tmp = 0
      	if (math.fabs((x - y)) / math.fabs(y)) <= 100000.0:
      		tmp = 1.0
      	else:
      		tmp = x / y
      	return tmp
      
      function code(x, y)
      	tmp = 0.0
      	if (Float64(abs(Float64(x - y)) / abs(y)) <= 100000.0)
      		tmp = 1.0;
      	else
      		tmp = Float64(x / y);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y)
      	tmp = 0.0;
      	if ((abs((x - y)) / abs(y)) <= 100000.0)
      		tmp = 1.0;
      	else
      		tmp = x / y;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_] := If[LessEqual[N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision], 100000.0], 1.0, N[(x / y), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;\frac{\left|x - y\right|}{\left|y\right|} \leq 100000:\\
      \;\;\;\;1\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{x}{y}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y)) < 1e5

        1. Initial program 100.0%

          \[\frac{\left|x - y\right|}{\left|y\right|} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \frac{\left|\color{blue}{x - y}\right|}{\left|y\right|} \]
          2. neg-fabsN/A

            \[\leadsto \frac{\color{blue}{\left|\mathsf{neg}\left(\left(x - y\right)\right)\right|}}{\left|y\right|} \]
          3. div-fabsN/A

            \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
          4. lower-fabs.f64N/A

            \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
          5. lift--.f64N/A

            \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x - y\right)}\right)}{y}\right| \]
          6. sub-negN/A

            \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)}\right)}{y}\right| \]
          7. +-commutativeN/A

            \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
          8. distribute-neg-inN/A

            \[\leadsto \left|\frac{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{y}\right| \]
          9. remove-double-negN/A

            \[\leadsto \left|\frac{\color{blue}{y} + \left(\mathsf{neg}\left(x\right)\right)}{y}\right| \]
          10. sub-negN/A

            \[\leadsto \left|\frac{\color{blue}{y - x}}{y}\right| \]
          11. div-subN/A

            \[\leadsto \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]
          12. *-inversesN/A

            \[\leadsto \left|\color{blue}{1} - \frac{x}{y}\right| \]
          13. lower--.f64N/A

            \[\leadsto \left|\color{blue}{1 - \frac{x}{y}}\right| \]
          14. lower-/.f64100.0

            \[\leadsto \left|1 - \color{blue}{\frac{x}{y}}\right| \]
        4. Applied egg-rr100.0%

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

          \[\leadsto \left|\color{blue}{1}\right| \]
        6. Step-by-step derivation
          1. Simplified97.0%

            \[\leadsto \left|\color{blue}{1}\right| \]
          2. Step-by-step derivation
            1. metadata-eval97.0

              \[\leadsto \color{blue}{1} \]
          3. Applied egg-rr97.0%

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

          if 1e5 < (/.f64 (fabs.f64 (-.f64 x y)) (fabs.f64 y))

          1. Initial program 100.0%

            \[\frac{\left|x - y\right|}{\left|y\right|} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. lift--.f64N/A

              \[\leadsto \frac{\left|\color{blue}{x - y}\right|}{\left|y\right|} \]
            2. neg-fabsN/A

              \[\leadsto \frac{\color{blue}{\left|\mathsf{neg}\left(\left(x - y\right)\right)\right|}}{\left|y\right|} \]
            3. div-fabsN/A

              \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
            4. lower-fabs.f64N/A

              \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
            5. lift--.f64N/A

              \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x - y\right)}\right)}{y}\right| \]
            6. sub-negN/A

              \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)}\right)}{y}\right| \]
            7. +-commutativeN/A

              \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
            8. distribute-neg-inN/A

              \[\leadsto \left|\frac{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{y}\right| \]
            9. remove-double-negN/A

              \[\leadsto \left|\frac{\color{blue}{y} + \left(\mathsf{neg}\left(x\right)\right)}{y}\right| \]
            10. sub-negN/A

              \[\leadsto \left|\frac{\color{blue}{y - x}}{y}\right| \]
            11. div-subN/A

              \[\leadsto \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]
            12. *-inversesN/A

              \[\leadsto \left|\color{blue}{1} - \frac{x}{y}\right| \]
            13. lower--.f64N/A

              \[\leadsto \left|\color{blue}{1 - \frac{x}{y}}\right| \]
            14. lower-/.f64100.0

              \[\leadsto \left|1 - \color{blue}{\frac{x}{y}}\right| \]
          4. Applied egg-rr100.0%

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

            \[\leadsto \left|\color{blue}{-1 \cdot \frac{x}{y}}\right| \]
          6. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \left|\color{blue}{\mathsf{neg}\left(\frac{x}{y}\right)}\right| \]
            2. distribute-neg-frac2N/A

              \[\leadsto \left|\color{blue}{\frac{x}{\mathsf{neg}\left(y\right)}}\right| \]
            3. lower-/.f64N/A

              \[\leadsto \left|\color{blue}{\frac{x}{\mathsf{neg}\left(y\right)}}\right| \]
            4. lower-neg.f6499.3

              \[\leadsto \left|\frac{x}{\color{blue}{-y}}\right| \]
          7. Simplified99.3%

            \[\leadsto \left|\color{blue}{\frac{x}{-y}}\right| \]
          8. Step-by-step derivation
            1. lift-neg.f64N/A

              \[\leadsto \left|\frac{x}{\color{blue}{\mathsf{neg}\left(y\right)}}\right| \]
            2. clear-numN/A

              \[\leadsto \left|\color{blue}{\frac{1}{\frac{\mathsf{neg}\left(y\right)}{x}}}\right| \]
            3. inv-powN/A

              \[\leadsto \left|\color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{-1}}\right| \]
            4. sqr-powN/A

              \[\leadsto \left|\color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)}}\right| \]
            5. fabs-sqrN/A

              \[\leadsto \color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)}} \]
            6. pow-prod-downN/A

              \[\leadsto \color{blue}{{\left(\frac{\mathsf{neg}\left(y\right)}{x} \cdot \frac{\mathsf{neg}\left(y\right)}{x}\right)}^{\left(\frac{-1}{2}\right)}} \]
            7. sqr-negN/A

              \[\leadsto {\color{blue}{\left(\left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)\right)\right)}}^{\left(\frac{-1}{2}\right)} \]
            8. lift-neg.f64N/A

              \[\leadsto {\left(\left(\mathsf{neg}\left(\frac{\color{blue}{\mathsf{neg}\left(y\right)}}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \]
            9. distribute-frac-negN/A

              \[\leadsto {\left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{y}{x}\right)\right)}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \]
            10. remove-double-negN/A

              \[\leadsto {\left(\color{blue}{\frac{y}{x}} \cdot \left(\mathsf{neg}\left(\frac{\mathsf{neg}\left(y\right)}{x}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \]
            11. lift-neg.f64N/A

              \[\leadsto {\left(\frac{y}{x} \cdot \left(\mathsf{neg}\left(\frac{\color{blue}{\mathsf{neg}\left(y\right)}}{x}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \]
            12. distribute-frac-negN/A

              \[\leadsto {\left(\frac{y}{x} \cdot \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{y}{x}\right)\right)}\right)\right)\right)}^{\left(\frac{-1}{2}\right)} \]
            13. remove-double-negN/A

              \[\leadsto {\left(\frac{y}{x} \cdot \color{blue}{\frac{y}{x}}\right)}^{\left(\frac{-1}{2}\right)} \]
            14. pow-prod-downN/A

              \[\leadsto \color{blue}{{\left(\frac{y}{x}\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(\frac{y}{x}\right)}^{\left(\frac{-1}{2}\right)}} \]
            15. sqr-powN/A

              \[\leadsto \color{blue}{{\left(\frac{y}{x}\right)}^{-1}} \]
            16. inv-powN/A

              \[\leadsto \color{blue}{\frac{1}{\frac{y}{x}}} \]
            17. clear-numN/A

              \[\leadsto \color{blue}{\frac{x}{y}} \]
            18. lower-/.f6447.1

              \[\leadsto \color{blue}{\frac{x}{y}} \]
          9. Applied egg-rr47.1%

            \[\leadsto \color{blue}{\frac{x}{y}} \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 5: 51.0% accurate, 19.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. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \frac{\left|\color{blue}{x - y}\right|}{\left|y\right|} \]
          2. neg-fabsN/A

            \[\leadsto \frac{\color{blue}{\left|\mathsf{neg}\left(\left(x - y\right)\right)\right|}}{\left|y\right|} \]
          3. div-fabsN/A

            \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
          4. lower-fabs.f64N/A

            \[\leadsto \color{blue}{\left|\frac{\mathsf{neg}\left(\left(x - y\right)\right)}{y}\right|} \]
          5. lift--.f64N/A

            \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x - y\right)}\right)}{y}\right| \]
          6. sub-negN/A

            \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)}\right)}{y}\right| \]
          7. +-commutativeN/A

            \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
          8. distribute-neg-inN/A

            \[\leadsto \left|\frac{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}}{y}\right| \]
          9. remove-double-negN/A

            \[\leadsto \left|\frac{\color{blue}{y} + \left(\mathsf{neg}\left(x\right)\right)}{y}\right| \]
          10. sub-negN/A

            \[\leadsto \left|\frac{\color{blue}{y - x}}{y}\right| \]
          11. div-subN/A

            \[\leadsto \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]
          12. *-inversesN/A

            \[\leadsto \left|\color{blue}{1} - \frac{x}{y}\right| \]
          13. lower--.f64N/A

            \[\leadsto \left|\color{blue}{1 - \frac{x}{y}}\right| \]
          14. lower-/.f64100.0

            \[\leadsto \left|1 - \color{blue}{\frac{x}{y}}\right| \]
        4. Applied egg-rr100.0%

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

          \[\leadsto \left|\color{blue}{1}\right| \]
        6. Step-by-step derivation
          1. Simplified56.0%

            \[\leadsto \left|\color{blue}{1}\right| \]
          2. Step-by-step derivation
            1. metadata-eval56.0

              \[\leadsto \color{blue}{1} \]
          3. Applied egg-rr56.0%

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

          Reproduce

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