Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5

Percentage Accurate: 100.0% → 100.0%
Time: 6.3s
Alternatives: 6
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 6 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|\frac{x - y}{y}\right| \end{array} \]
(FPCore (x y) :precision binary64 (fabs (/ (- x y) y)))
double code(double x, double y) {
	return fabs(((x - y) / y));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = abs(((x - y) / y))
end function
public static double code(double x, double y) {
	return Math.abs(((x - y) / y));
}
def code(x, y):
	return math.fabs(((x - y) / y))
function code(x, y)
	return abs(Float64(Float64(x - y) / y))
end
function tmp = code(x, y)
	tmp = abs(((x - y) / y));
end
code[x_, y_] := N[Abs[N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\left|\frac{x - y}{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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
    2. lift-fabs.f64N/A

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

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

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

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

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

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

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

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

      \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
    11. 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| \]
    12. remove-double-negN/A

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

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

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

    \[\leadsto \color{blue}{\left|\frac{y - x}{y}\right|} \]
  5. Final simplification100.0%

    \[\leadsto \left|\frac{x - y}{y}\right| \]
  6. Add Preprocessing

Alternative 2: 73.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|\frac{x - y}{y}\right| \leq 2:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (fabs (/ (- x y) y)) 2.0) 1.0 (/ x y)))
double code(double x, double y) {
	double tmp;
	if (fabs(((x - y) / y)) <= 2.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) / y)) <= 2.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) / y)) <= 2.0) {
		tmp = 1.0;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if math.fabs(((x - y) / y)) <= 2.0:
		tmp = 1.0
	else:
		tmp = x / y
	return tmp
function code(x, y)
	tmp = 0.0
	if (abs(Float64(Float64(x - y) / y)) <= 2.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) / y)) <= 2.0)
		tmp = 1.0;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[Abs[N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], 2.0], 1.0, N[(x / y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|\frac{x - y}{y}\right| \leq 2:\\
\;\;\;\;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)) < 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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
      2. lift-fabs.f64N/A

        \[\leadsto \frac{\color{blue}{\left|x - y\right|}}{\left|y\right|} \]
      3. fabs-fabs-revN/A

        \[\leadsto \frac{\color{blue}{\left|\left|x - y\right|\right|}}{\left|y\right|} \]
      4. lift-fabs.f64N/A

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

        \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|y\right|}} \]
      6. fabs-fabs-revN/A

        \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|\left|y\right|\right|}} \]
      7. lift-fabs.f64N/A

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|x - y\right|} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
      15. rem-sqrt-square-revN/A

        \[\leadsto \color{blue}{\sqrt{\left(x - y\right) \cdot \left(x - y\right)}} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
      16. sqrt-prodN/A

        \[\leadsto \color{blue}{\left(\sqrt{x - y} \cdot \sqrt{x - y}\right)} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
      17. rem-square-sqrtN/A

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

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

        \[\leadsto \left(x - y\right) \cdot \color{blue}{\left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right|} \]
      20. neg-mul-1N/A

        \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{\color{blue}{-1 \cdot \left|y\right|}}\right| \]
      21. lift-fabs.f64N/A

        \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left|y\right|}}\right| \]
      22. rem-sqrt-square-revN/A

        \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\sqrt{y \cdot y}}}\right| \]
      23. sqrt-prodN/A

        \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)}}\right| \]
      24. rem-square-sqrtN/A

        \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{y}}\right| \]
    4. Applied rewrites42.8%

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

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

        \[\leadsto x \cdot \color{blue}{\frac{\left|-1\right|}{\left|y\right|}} \]
      2. metadata-evalN/A

        \[\leadsto x \cdot \frac{\color{blue}{1}}{\left|y\right|} \]
      3. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{x \cdot 1}{\left|y\right|}} \]
      4. *-rgt-identityN/A

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

        \[\leadsto \color{blue}{\frac{x}{\left|y\right|}} \]
      6. lower-fabs.f643.5

        \[\leadsto \frac{x}{\color{blue}{\left|y\right|}} \]
    7. Applied rewrites3.5%

      \[\leadsto \color{blue}{\frac{x}{\left|y\right|}} \]
    8. Step-by-step derivation
      1. Applied rewrites3.6%

        \[\leadsto \color{blue}{\frac{x}{y}} \]
      2. Taylor expanded in x around 0

        \[\leadsto \color{blue}{1} \]
      3. Step-by-step derivation
        1. Applied rewrites98.4%

          \[\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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
          2. lift-fabs.f64N/A

            \[\leadsto \frac{\color{blue}{\left|x - y\right|}}{\left|y\right|} \]
          3. fabs-fabs-revN/A

            \[\leadsto \frac{\color{blue}{\left|\left|x - y\right|\right|}}{\left|y\right|} \]
          4. lift-fabs.f64N/A

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

            \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|y\right|}} \]
          6. fabs-fabs-revN/A

            \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|\left|y\right|\right|}} \]
          7. lift-fabs.f64N/A

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\left|x - y\right|} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
          15. rem-sqrt-square-revN/A

            \[\leadsto \color{blue}{\sqrt{\left(x - y\right) \cdot \left(x - y\right)}} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
          16. sqrt-prodN/A

            \[\leadsto \color{blue}{\left(\sqrt{x - y} \cdot \sqrt{x - y}\right)} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
          17. rem-square-sqrtN/A

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

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

            \[\leadsto \left(x - y\right) \cdot \color{blue}{\left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right|} \]
          20. neg-mul-1N/A

            \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{\color{blue}{-1 \cdot \left|y\right|}}\right| \]
          21. lift-fabs.f64N/A

            \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left|y\right|}}\right| \]
          22. rem-sqrt-square-revN/A

            \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\sqrt{y \cdot y}}}\right| \]
          23. sqrt-prodN/A

            \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)}}\right| \]
          24. rem-square-sqrtN/A

            \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{y}}\right| \]
        4. Applied rewrites51.7%

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

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

            \[\leadsto x \cdot \color{blue}{\frac{\left|-1\right|}{\left|y\right|}} \]
          2. metadata-evalN/A

            \[\leadsto x \cdot \frac{\color{blue}{1}}{\left|y\right|} \]
          3. associate-*r/N/A

            \[\leadsto \color{blue}{\frac{x \cdot 1}{\left|y\right|}} \]
          4. *-rgt-identityN/A

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

            \[\leadsto \color{blue}{\frac{x}{\left|y\right|}} \]
          6. lower-fabs.f6450.3

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

          \[\leadsto \color{blue}{\frac{x}{\left|y\right|}} \]
        8. Step-by-step derivation
          1. Applied rewrites51.0%

            \[\leadsto \color{blue}{\frac{x}{y}} \]
        9. Recombined 2 regimes into one program.
        10. Final simplification74.3%

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

        Alternative 3: 78.5% accurate, 0.7× speedup?

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

          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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
            2. lift-fabs.f64N/A

              \[\leadsto \frac{\color{blue}{\left|x - y\right|}}{\left|y\right|} \]
            3. rem-sqrt-square-revN/A

              \[\leadsto \frac{\color{blue}{\sqrt{\left(x - y\right) \cdot \left(x - y\right)}}}{\left|y\right|} \]
            4. sqrt-prodN/A

              \[\leadsto \frac{\color{blue}{\sqrt{x - y} \cdot \sqrt{x - y}}}{\left|y\right|} \]
            5. rem-square-sqrtN/A

              \[\leadsto \frac{\color{blue}{x - y}}{\left|y\right|} \]
            6. lift--.f64N/A

              \[\leadsto \frac{\color{blue}{x - y}}{\left|y\right|} \]
            7. lift-fabs.f64N/A

              \[\leadsto \frac{x - y}{\color{blue}{\left|y\right|}} \]
            8. rem-sqrt-square-revN/A

              \[\leadsto \frac{x - y}{\color{blue}{\sqrt{y \cdot y}}} \]
            9. sqrt-prodN/A

              \[\leadsto \frac{x - y}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \]
            10. rem-square-sqrtN/A

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

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

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

              \[\leadsto \color{blue}{\frac{x}{y} - 1} \]
            14. lower-/.f6469.7

              \[\leadsto \color{blue}{\frac{x}{y}} - 1 \]
          4. Applied rewrites69.7%

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

          if -7.49999999999999977e199 < x < 5.7999999999999998e48

          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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
            2. lift-fabs.f64N/A

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

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

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

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

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

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

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

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

              \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
            11. 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| \]
            12. remove-double-negN/A

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

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

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

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

              \[\leadsto \color{blue}{\left|\frac{y - x}{y}\right|} \]
            2. rem-sqrt-square-revN/A

              \[\leadsto \color{blue}{\sqrt{\frac{y - x}{y} \cdot \frac{y - x}{y}}} \]
            3. sqrt-prodN/A

              \[\leadsto \color{blue}{\sqrt{\frac{y - x}{y}} \cdot \sqrt{\frac{y - x}{y}}} \]
            4. rem-square-sqrt84.6

              \[\leadsto \color{blue}{\frac{y - x}{y}} \]
            5. lift-/.f64N/A

              \[\leadsto \color{blue}{\frac{y - x}{y}} \]
            6. lift--.f64N/A

              \[\leadsto \frac{\color{blue}{y - x}}{y} \]
            7. div-subN/A

              \[\leadsto \color{blue}{\frac{y}{y} - \frac{x}{y}} \]
            8. *-inversesN/A

              \[\leadsto \color{blue}{1} - \frac{x}{y} \]
            9. lift-/.f64N/A

              \[\leadsto 1 - \color{blue}{\frac{x}{y}} \]
            10. lower--.f6484.6

              \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
          6. Applied rewrites84.6%

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

          if 5.7999999999999998e48 < x

          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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
            2. lift-fabs.f64N/A

              \[\leadsto \frac{\color{blue}{\left|x - y\right|}}{\left|y\right|} \]
            3. fabs-fabs-revN/A

              \[\leadsto \frac{\color{blue}{\left|\left|x - y\right|\right|}}{\left|y\right|} \]
            4. lift-fabs.f64N/A

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

              \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|y\right|}} \]
            6. fabs-fabs-revN/A

              \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|\left|y\right|\right|}} \]
            7. lift-fabs.f64N/A

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\left|x - y\right|} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
            15. rem-sqrt-square-revN/A

              \[\leadsto \color{blue}{\sqrt{\left(x - y\right) \cdot \left(x - y\right)}} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
            16. sqrt-prodN/A

              \[\leadsto \color{blue}{\left(\sqrt{x - y} \cdot \sqrt{x - y}\right)} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
            17. rem-square-sqrtN/A

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

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

              \[\leadsto \left(x - y\right) \cdot \color{blue}{\left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right|} \]
            20. neg-mul-1N/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{\color{blue}{-1 \cdot \left|y\right|}}\right| \]
            21. lift-fabs.f64N/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left|y\right|}}\right| \]
            22. rem-sqrt-square-revN/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\sqrt{y \cdot y}}}\right| \]
            23. sqrt-prodN/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)}}\right| \]
            24. rem-square-sqrtN/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{y}}\right| \]
          4. Applied rewrites91.3%

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

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

              \[\leadsto x \cdot \color{blue}{\frac{\left|-1\right|}{\left|y\right|}} \]
            2. metadata-evalN/A

              \[\leadsto x \cdot \frac{\color{blue}{1}}{\left|y\right|} \]
            3. associate-*r/N/A

              \[\leadsto \color{blue}{\frac{x \cdot 1}{\left|y\right|}} \]
            4. *-rgt-identityN/A

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

              \[\leadsto \color{blue}{\frac{x}{\left|y\right|}} \]
            6. lower-fabs.f6487.4

              \[\leadsto \frac{x}{\color{blue}{\left|y\right|}} \]
          7. Applied rewrites87.4%

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

        Alternative 4: 78.5% accurate, 0.7× speedup?

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

          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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
            2. lift-fabs.f64N/A

              \[\leadsto \frac{\color{blue}{\left|x - y\right|}}{\left|y\right|} \]
            3. fabs-fabs-revN/A

              \[\leadsto \frac{\color{blue}{\left|\left|x - y\right|\right|}}{\left|y\right|} \]
            4. lift-fabs.f64N/A

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

              \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|y\right|}} \]
            6. fabs-fabs-revN/A

              \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|\left|y\right|\right|}} \]
            7. lift-fabs.f64N/A

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\left|x - y\right|} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
            15. rem-sqrt-square-revN/A

              \[\leadsto \color{blue}{\sqrt{\left(x - y\right) \cdot \left(x - y\right)}} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
            16. sqrt-prodN/A

              \[\leadsto \color{blue}{\left(\sqrt{x - y} \cdot \sqrt{x - y}\right)} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
            17. rem-square-sqrtN/A

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

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

              \[\leadsto \left(x - y\right) \cdot \color{blue}{\left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right|} \]
            20. neg-mul-1N/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{\color{blue}{-1 \cdot \left|y\right|}}\right| \]
            21. lift-fabs.f64N/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left|y\right|}}\right| \]
            22. rem-sqrt-square-revN/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\sqrt{y \cdot y}}}\right| \]
            23. sqrt-prodN/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)}}\right| \]
            24. rem-square-sqrtN/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{y}}\right| \]
          4. Applied rewrites4.9%

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

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

              \[\leadsto x \cdot \color{blue}{\frac{\left|-1\right|}{\left|y\right|}} \]
            2. metadata-evalN/A

              \[\leadsto x \cdot \frac{\color{blue}{1}}{\left|y\right|} \]
            3. associate-*r/N/A

              \[\leadsto \color{blue}{\frac{x \cdot 1}{\left|y\right|}} \]
            4. *-rgt-identityN/A

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

              \[\leadsto \color{blue}{\frac{x}{\left|y\right|}} \]
            6. lower-fabs.f640.6

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

            \[\leadsto \color{blue}{\frac{x}{\left|y\right|}} \]
          8. Step-by-step derivation
            1. Applied rewrites67.0%

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

            if -7.49999999999999977e199 < x < 5.7999999999999998e48

            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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
              2. lift-fabs.f64N/A

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

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

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

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

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

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

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

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

                \[\leadsto \left|\frac{\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right)}{y}\right| \]
              11. 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| \]
              12. remove-double-negN/A

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

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

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

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

                \[\leadsto \color{blue}{\left|\frac{y - x}{y}\right|} \]
              2. rem-sqrt-square-revN/A

                \[\leadsto \color{blue}{\sqrt{\frac{y - x}{y} \cdot \frac{y - x}{y}}} \]
              3. sqrt-prodN/A

                \[\leadsto \color{blue}{\sqrt{\frac{y - x}{y}} \cdot \sqrt{\frac{y - x}{y}}} \]
              4. rem-square-sqrt84.6

                \[\leadsto \color{blue}{\frac{y - x}{y}} \]
              5. lift-/.f64N/A

                \[\leadsto \color{blue}{\frac{y - x}{y}} \]
              6. lift--.f64N/A

                \[\leadsto \frac{\color{blue}{y - x}}{y} \]
              7. div-subN/A

                \[\leadsto \color{blue}{\frac{y}{y} - \frac{x}{y}} \]
              8. *-inversesN/A

                \[\leadsto \color{blue}{1} - \frac{x}{y} \]
              9. lift-/.f64N/A

                \[\leadsto 1 - \color{blue}{\frac{x}{y}} \]
              10. lower--.f6484.6

                \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
            6. Applied rewrites84.6%

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

            if 5.7999999999999998e48 < x

            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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
              2. lift-fabs.f64N/A

                \[\leadsto \frac{\color{blue}{\left|x - y\right|}}{\left|y\right|} \]
              3. fabs-fabs-revN/A

                \[\leadsto \frac{\color{blue}{\left|\left|x - y\right|\right|}}{\left|y\right|} \]
              4. lift-fabs.f64N/A

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

                \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|y\right|}} \]
              6. fabs-fabs-revN/A

                \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|\left|y\right|\right|}} \]
              7. lift-fabs.f64N/A

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\left|x - y\right|} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
              15. rem-sqrt-square-revN/A

                \[\leadsto \color{blue}{\sqrt{\left(x - y\right) \cdot \left(x - y\right)}} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
              16. sqrt-prodN/A

                \[\leadsto \color{blue}{\left(\sqrt{x - y} \cdot \sqrt{x - y}\right)} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
              17. rem-square-sqrtN/A

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

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

                \[\leadsto \left(x - y\right) \cdot \color{blue}{\left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right|} \]
              20. neg-mul-1N/A

                \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{\color{blue}{-1 \cdot \left|y\right|}}\right| \]
              21. lift-fabs.f64N/A

                \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left|y\right|}}\right| \]
              22. rem-sqrt-square-revN/A

                \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\sqrt{y \cdot y}}}\right| \]
              23. sqrt-prodN/A

                \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)}}\right| \]
              24. rem-square-sqrtN/A

                \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{y}}\right| \]
            4. Applied rewrites91.3%

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

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

                \[\leadsto x \cdot \color{blue}{\frac{\left|-1\right|}{\left|y\right|}} \]
              2. metadata-evalN/A

                \[\leadsto x \cdot \frac{\color{blue}{1}}{\left|y\right|} \]
              3. associate-*r/N/A

                \[\leadsto \color{blue}{\frac{x \cdot 1}{\left|y\right|}} \]
              4. *-rgt-identityN/A

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

                \[\leadsto \color{blue}{\frac{x}{\left|y\right|}} \]
              6. lower-fabs.f6487.4

                \[\leadsto \frac{x}{\color{blue}{\left|y\right|}} \]
            7. Applied rewrites87.4%

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

          Alternative 5: 51.5% 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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
            2. lift-fabs.f64N/A

              \[\leadsto \frac{\color{blue}{\left|x - y\right|}}{\left|y\right|} \]
            3. fabs-fabs-revN/A

              \[\leadsto \frac{\color{blue}{\left|\left|x - y\right|\right|}}{\left|y\right|} \]
            4. lift-fabs.f64N/A

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

              \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|y\right|}} \]
            6. fabs-fabs-revN/A

              \[\leadsto \frac{\left|\left|x - y\right|\right|}{\color{blue}{\left|\left|y\right|\right|}} \]
            7. lift-fabs.f64N/A

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\left|x - y\right|} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
            15. rem-sqrt-square-revN/A

              \[\leadsto \color{blue}{\sqrt{\left(x - y\right) \cdot \left(x - y\right)}} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
            16. sqrt-prodN/A

              \[\leadsto \color{blue}{\left(\sqrt{x - y} \cdot \sqrt{x - y}\right)} \cdot \left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right| \]
            17. rem-square-sqrtN/A

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

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

              \[\leadsto \left(x - y\right) \cdot \color{blue}{\left|\frac{1}{\mathsf{neg}\left(\left|y\right|\right)}\right|} \]
            20. neg-mul-1N/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{\color{blue}{-1 \cdot \left|y\right|}}\right| \]
            21. lift-fabs.f64N/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left|y\right|}}\right| \]
            22. rem-sqrt-square-revN/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\sqrt{y \cdot y}}}\right| \]
            23. sqrt-prodN/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)}}\right| \]
            24. rem-square-sqrtN/A

              \[\leadsto \left(x - y\right) \cdot \left|\frac{1}{-1 \cdot \color{blue}{y}}\right| \]
          4. Applied rewrites47.3%

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

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

              \[\leadsto x \cdot \color{blue}{\frac{\left|-1\right|}{\left|y\right|}} \]
            2. metadata-evalN/A

              \[\leadsto x \cdot \frac{\color{blue}{1}}{\left|y\right|} \]
            3. associate-*r/N/A

              \[\leadsto \color{blue}{\frac{x \cdot 1}{\left|y\right|}} \]
            4. *-rgt-identityN/A

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

              \[\leadsto \color{blue}{\frac{x}{\left|y\right|}} \]
            6. lower-fabs.f6427.2

              \[\leadsto \frac{x}{\color{blue}{\left|y\right|}} \]
          7. Applied rewrites27.2%

            \[\leadsto \color{blue}{\frac{x}{\left|y\right|}} \]
          8. Step-by-step derivation
            1. Applied rewrites27.6%

              \[\leadsto \color{blue}{\frac{x}{y}} \]
            2. Taylor expanded in x around 0

              \[\leadsto \color{blue}{1} \]
            3. Step-by-step derivation
              1. Applied rewrites51.1%

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

              Alternative 6: 1.3% 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 \color{blue}{\frac{\left|x - y\right|}{\left|y\right|}} \]
                2. lift-fabs.f64N/A

                  \[\leadsto \frac{\color{blue}{\left|x - y\right|}}{\left|y\right|} \]
                3. rem-sqrt-square-revN/A

                  \[\leadsto \frac{\color{blue}{\sqrt{\left(x - y\right) \cdot \left(x - y\right)}}}{\left|y\right|} \]
                4. sqrt-prodN/A

                  \[\leadsto \frac{\color{blue}{\sqrt{x - y} \cdot \sqrt{x - y}}}{\left|y\right|} \]
                5. rem-square-sqrtN/A

                  \[\leadsto \frac{\color{blue}{x - y}}{\left|y\right|} \]
                6. lift--.f64N/A

                  \[\leadsto \frac{\color{blue}{x - y}}{\left|y\right|} \]
                7. lift-fabs.f64N/A

                  \[\leadsto \frac{x - y}{\color{blue}{\left|y\right|}} \]
                8. rem-sqrt-square-revN/A

                  \[\leadsto \frac{x - y}{\color{blue}{\sqrt{y \cdot y}}} \]
                9. sqrt-prodN/A

                  \[\leadsto \frac{x - y}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \]
                10. rem-square-sqrtN/A

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

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

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

                  \[\leadsto \color{blue}{\frac{x}{y} - 1} \]
                14. lower-/.f6427.5

                  \[\leadsto \color{blue}{\frac{x}{y}} - 1 \]
              4. Applied rewrites27.5%

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

                \[\leadsto \color{blue}{-1} \]
              6. Step-by-step derivation
                1. Applied rewrites1.3%

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

                Reproduce

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