Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5

Percentage Accurate: 100.0% → 100.0%
Time: 4.1s
Alternatives: 6
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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, 2.0× 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. Taylor expanded in x around -inf 100.0%

    \[\leadsto \color{blue}{\frac{\left|-\left(y + -1 \cdot x\right)\right|}{\left|y\right|}} \]
  3. Step-by-step derivation
    1. fabs-neg100.0%

      \[\leadsto \frac{\color{blue}{\left|y + -1 \cdot x\right|}}{\left|y\right|} \]
    2. mul-1-neg100.0%

      \[\leadsto \frac{\left|y + \color{blue}{\left(-x\right)}\right|}{\left|y\right|} \]
    3. sub-neg100.0%

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

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

      \[\leadsto \left|\color{blue}{\frac{y}{y} - \frac{x}{y}}\right| \]
    6. *-inverses100.0%

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

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

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

Alternative 2: 58.7% accurate, 13.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x + y}\\ \mathbf{if}\;y \leq -1.3 \cdot 10^{-22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.4 \cdot 10^{-267}:\\ \;\;\;\;\frac{x}{y} + -1\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{-112}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y - x}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-79}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (+ x y))))
   (if (<= y -1.3e-22)
     t_0
     (if (<= y -4.4e-267)
       (+ (/ x y) -1.0)
       (if (<= y 4.1e-112)
         (* (/ x y) (/ x (- y x)))
         (if (<= y 1.1e-79) (/ x y) t_0))))))
double code(double x, double y) {
	double t_0 = y / (x + y);
	double tmp;
	if (y <= -1.3e-22) {
		tmp = t_0;
	} else if (y <= -4.4e-267) {
		tmp = (x / y) + -1.0;
	} else if (y <= 4.1e-112) {
		tmp = (x / y) * (x / (y - x));
	} else if (y <= 1.1e-79) {
		tmp = x / y;
	} else {
		tmp = t_0;
	}
	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 = y / (x + y)
    if (y <= (-1.3d-22)) then
        tmp = t_0
    else if (y <= (-4.4d-267)) then
        tmp = (x / y) + (-1.0d0)
    else if (y <= 4.1d-112) then
        tmp = (x / y) * (x / (y - x))
    else if (y <= 1.1d-79) then
        tmp = x / y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = y / (x + y);
	double tmp;
	if (y <= -1.3e-22) {
		tmp = t_0;
	} else if (y <= -4.4e-267) {
		tmp = (x / y) + -1.0;
	} else if (y <= 4.1e-112) {
		tmp = (x / y) * (x / (y - x));
	} else if (y <= 1.1e-79) {
		tmp = x / y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (x + y)
	tmp = 0
	if y <= -1.3e-22:
		tmp = t_0
	elif y <= -4.4e-267:
		tmp = (x / y) + -1.0
	elif y <= 4.1e-112:
		tmp = (x / y) * (x / (y - x))
	elif y <= 1.1e-79:
		tmp = x / y
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(y / Float64(x + y))
	tmp = 0.0
	if (y <= -1.3e-22)
		tmp = t_0;
	elseif (y <= -4.4e-267)
		tmp = Float64(Float64(x / y) + -1.0);
	elseif (y <= 4.1e-112)
		tmp = Float64(Float64(x / y) * Float64(x / Float64(y - x)));
	elseif (y <= 1.1e-79)
		tmp = Float64(x / y);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y / (x + y);
	tmp = 0.0;
	if (y <= -1.3e-22)
		tmp = t_0;
	elseif (y <= -4.4e-267)
		tmp = (x / y) + -1.0;
	elseif (y <= 4.1e-112)
		tmp = (x / y) * (x / (y - x));
	elseif (y <= 1.1e-79)
		tmp = x / y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.3e-22], t$95$0, If[LessEqual[y, -4.4e-267], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, 4.1e-112], N[(N[(x / y), $MachinePrecision] * N[(x / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e-79], N[(x / y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{x + y}\\
\mathbf{if}\;y \leq -1.3 \cdot 10^{-22}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -4.4 \cdot 10^{-267}:\\
\;\;\;\;\frac{x}{y} + -1\\

\mathbf{elif}\;y \leq 4.1 \cdot 10^{-112}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y - x}\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-79}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.3e-22 or 1.0999999999999999e-79 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(x - y\right)} \]
    4. Step-by-step derivation
      1. flip--4.6%

        \[\leadsto \frac{1}{y} \cdot \color{blue}{\frac{x \cdot x - y \cdot y}{x + y}} \]
      2. associate-*r/4.6%

        \[\leadsto \color{blue}{\frac{\frac{1}{y} \cdot \left(x \cdot x - y \cdot y\right)}{x + y}} \]
      3. +-commutative4.6%

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot y}}{y + x} \]
    7. Step-by-step derivation
      1. neg-mul-12.0%

        \[\leadsto \frac{\color{blue}{-y}}{y + x} \]
    8. Simplified2.0%

      \[\leadsto \frac{\color{blue}{-y}}{y + x} \]
    9. Step-by-step derivation
      1. *-un-lft-identity2.0%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-y\right)}}{y + x} \]
      2. lft-mult-inverse2.0%

        \[\leadsto \frac{\color{blue}{\left(\frac{1}{y} \cdot y\right)} \cdot \left(-y\right)}{y + x} \]
      3. associate-*r*1.5%

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

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

        \[\leadsto \frac{\color{blue}{\frac{1}{y} \cdot \left(y \cdot \left(-y\right)\right)}}{y + x} \]
      6. associate-/l*1.5%

        \[\leadsto \color{blue}{\frac{\frac{1}{y}}{\frac{y + x}{y \cdot \left(-y\right)}}} \]
      7. div-inv1.5%

        \[\leadsto \color{blue}{\frac{1}{y} \cdot \frac{1}{\frac{y + x}{y \cdot \left(-y\right)}}} \]
      8. div-inv1.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\color{blue}{\left(y + x\right) \cdot \frac{1}{y \cdot \left(-y\right)}}} \]
      9. metadata-eval1.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{\color{blue}{1 \cdot 1}}{y \cdot \left(-y\right)}} \]
      10. add-sqr-sqrt0.7%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)}}} \]
      11. sqrt-unprod17.3%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}} \]
      12. sqr-neg17.3%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \sqrt{\color{blue}{y \cdot y}}}} \]
      13. sqrt-unprod16.6%

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

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \color{blue}{y}}} \]
      15. frac-times37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \color{blue}{\left(\frac{1}{y} \cdot \frac{1}{y}\right)}} \]
      16. inv-pow37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \left(\color{blue}{{y}^{-1}} \cdot \frac{1}{y}\right)} \]
      17. inv-pow37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \left({y}^{-1} \cdot \color{blue}{{y}^{-1}}\right)} \]
      18. pow-prod-up37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \color{blue}{{y}^{\left(-1 + -1\right)}}} \]
      19. metadata-eval37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot {y}^{\color{blue}{-2}}} \]
    10. Applied egg-rr37.5%

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot {y}^{-2}}} \]
    11. Step-by-step derivation
      1. *-commutative37.5%

        \[\leadsto \color{blue}{\frac{1}{\left(y + x\right) \cdot {y}^{-2}} \cdot \frac{1}{y}} \]
      2. *-commutative37.5%

        \[\leadsto \frac{1}{\color{blue}{{y}^{-2} \cdot \left(y + x\right)}} \cdot \frac{1}{y} \]
      3. associate-/r*35.8%

        \[\leadsto \color{blue}{\frac{\frac{1}{{y}^{-2}}}{y + x}} \cdot \frac{1}{y} \]
      4. metadata-eval35.8%

        \[\leadsto \frac{\frac{1}{{y}^{\color{blue}{\left(2 \cdot -1\right)}}}}{y + x} \cdot \frac{1}{y} \]
      5. pow-sqr35.7%

        \[\leadsto \frac{\frac{1}{\color{blue}{{y}^{-1} \cdot {y}^{-1}}}}{y + x} \cdot \frac{1}{y} \]
      6. unpow-135.7%

        \[\leadsto \frac{\frac{1}{\color{blue}{\frac{1}{y}} \cdot {y}^{-1}}}{y + x} \cdot \frac{1}{y} \]
      7. unpow-135.7%

        \[\leadsto \frac{\frac{1}{\frac{1}{y} \cdot \color{blue}{\frac{1}{y}}}}{y + x} \cdot \frac{1}{y} \]
      8. associate-/l/35.8%

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\frac{1}{y}}}{\frac{1}{y}}}}{y + x} \cdot \frac{1}{y} \]
      9. remove-double-div35.9%

        \[\leadsto \frac{\frac{\color{blue}{y}}{\frac{1}{y}}}{y + x} \cdot \frac{1}{y} \]
      10. associate-/l*35.9%

        \[\leadsto \frac{\color{blue}{\frac{y \cdot y}{1}}}{y + x} \cdot \frac{1}{y} \]
      11. /-rgt-identity35.9%

        \[\leadsto \frac{\color{blue}{y \cdot y}}{y + x} \cdot \frac{1}{y} \]
      12. associate-/l*71.9%

        \[\leadsto \color{blue}{\frac{y}{\frac{y + x}{y}}} \cdot \frac{1}{y} \]
      13. associate-*l/71.9%

        \[\leadsto \color{blue}{\frac{y \cdot \frac{1}{y}}{\frac{y + x}{y}}} \]
      14. /-rgt-identity71.9%

        \[\leadsto \frac{\color{blue}{\frac{y}{1}} \cdot \frac{1}{y}}{\frac{y + x}{y}} \]
      15. associate-/r/71.9%

        \[\leadsto \frac{\color{blue}{\frac{y}{\frac{1}{\frac{1}{y}}}}}{\frac{y + x}{y}} \]
      16. remove-double-div72.0%

        \[\leadsto \frac{\frac{y}{\color{blue}{y}}}{\frac{y + x}{y}} \]
      17. *-inverses72.0%

        \[\leadsto \frac{\color{blue}{1}}{\frac{y + x}{y}} \]
      18. associate-/l*72.0%

        \[\leadsto \color{blue}{\frac{1 \cdot y}{y + x}} \]
      19. *-lft-identity72.0%

        \[\leadsto \frac{\color{blue}{y}}{y + x} \]
    12. Simplified72.0%

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

    if -1.3e-22 < y < -4.39999999999999976e-267

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{\left|-\left(y + -1 \cdot x\right)\right|}{\left|y\right|}} \]
    3. Step-by-step derivation
      1. fabs-neg100.0%

        \[\leadsto \frac{\color{blue}{\left|y + -1 \cdot x\right|}}{\left|y\right|} \]
      2. mul-1-neg100.0%

        \[\leadsto \frac{\left|y + \color{blue}{\left(-x\right)}\right|}{\left|y\right|} \]
      3. sub-neg100.0%

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

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

        \[\leadsto \color{blue}{\left|\frac{x - y}{y}\right|} \]
      6. rem-square-sqrt55.4%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x - y}{y}} \cdot \sqrt{\frac{x - y}{y}}} \]
      8. rem-square-sqrt56.0%

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      9. div-sub56.0%

        \[\leadsto \color{blue}{\frac{x}{y} - \frac{y}{y}} \]
      10. sub-neg56.0%

        \[\leadsto \color{blue}{\frac{x}{y} + \left(-\frac{y}{y}\right)} \]
      11. *-inverses56.0%

        \[\leadsto \frac{x}{y} + \left(-\color{blue}{1}\right) \]
      12. metadata-eval56.0%

        \[\leadsto \frac{x}{y} + \color{blue}{-1} \]
      13. +-commutative56.0%

        \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    4. Simplified56.0%

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

    if -4.39999999999999976e-267 < y < 4.09999999999999996e-112

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{y}} \cdot \left(x - y\right) \]
    3. Applied egg-rr37.2%

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(x - y\right)} \]
    4. Step-by-step derivation
      1. flip--30.9%

        \[\leadsto \frac{1}{y} \cdot \color{blue}{\frac{x \cdot x - y \cdot y}{x + y}} \]
      2. associate-*r/26.9%

        \[\leadsto \color{blue}{\frac{\frac{1}{y} \cdot \left(x \cdot x - y \cdot y\right)}{x + y}} \]
      3. +-commutative26.9%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{y} \cdot \left(x \cdot x - y \cdot y\right)}{y + x}} \]
    6. Taylor expanded in y around 0 27.1%

      \[\leadsto \frac{\color{blue}{\frac{{x}^{2}}{y}}}{y + x} \]
    7. Step-by-step derivation
      1. unpow227.1%

        \[\leadsto \frac{\frac{\color{blue}{x \cdot x}}{y}}{y + x} \]
      2. associate-/l*33.5%

        \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y}{x}}}}{y + x} \]
      3. associate-/r/33.5%

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{y + x} \]
    8. Simplified33.5%

      \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{y + x} \]
    9. Step-by-step derivation
      1. associate-/r/33.5%

        \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y}{x}}}}{y + x} \]
      2. expm1-log1p-u32.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{x}{\frac{y}{x}}}{y + x}\right)\right)} \]
      3. expm1-udef32.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{x}{\frac{y}{x}}}{y + x}\right)} - 1} \]
    10. Applied egg-rr44.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{x \cdot x}{y}}{y - x}\right)} - 1} \]
    11. Step-by-step derivation
      1. expm1-def44.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{x \cdot x}{y}}{y - x}\right)\right)} \]
      2. expm1-log1p46.9%

        \[\leadsto \color{blue}{\frac{\frac{x \cdot x}{y}}{y - x}} \]
      3. associate-/l/44.1%

        \[\leadsto \color{blue}{\frac{x \cdot x}{\left(y - x\right) \cdot y}} \]
      4. times-frac52.9%

        \[\leadsto \color{blue}{\frac{x}{y - x} \cdot \frac{x}{y}} \]
    12. Simplified52.9%

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

    if 4.09999999999999996e-112 < y < 1.0999999999999999e-79

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{y}} \cdot \left(x - y\right) \]
    3. Applied egg-rr74.6%

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

      \[\leadsto \color{blue}{\frac{x}{y}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification65.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{-22}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq -4.4 \cdot 10^{-267}:\\ \;\;\;\;\frac{x}{y} + -1\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{-112}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y - x}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-79}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x + y}\\ \end{array} \]

Alternative 3: 57.5% accurate, 15.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x + y}\\ \mathbf{if}\;y \leq -2.7 \cdot 10^{-23}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6 \cdot 10^{-302}:\\ \;\;\;\;\frac{x}{y} + -1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-116}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-79}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (+ x y))))
   (if (<= y -2.7e-23)
     t_0
     (if (<= y -6e-302)
       (+ (/ x y) -1.0)
       (if (<= y 7e-116)
         (* (/ x y) (/ x y))
         (if (<= y 1.05e-79) (/ x y) t_0))))))
double code(double x, double y) {
	double t_0 = y / (x + y);
	double tmp;
	if (y <= -2.7e-23) {
		tmp = t_0;
	} else if (y <= -6e-302) {
		tmp = (x / y) + -1.0;
	} else if (y <= 7e-116) {
		tmp = (x / y) * (x / y);
	} else if (y <= 1.05e-79) {
		tmp = x / y;
	} else {
		tmp = t_0;
	}
	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 = y / (x + y)
    if (y <= (-2.7d-23)) then
        tmp = t_0
    else if (y <= (-6d-302)) then
        tmp = (x / y) + (-1.0d0)
    else if (y <= 7d-116) then
        tmp = (x / y) * (x / y)
    else if (y <= 1.05d-79) then
        tmp = x / y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = y / (x + y);
	double tmp;
	if (y <= -2.7e-23) {
		tmp = t_0;
	} else if (y <= -6e-302) {
		tmp = (x / y) + -1.0;
	} else if (y <= 7e-116) {
		tmp = (x / y) * (x / y);
	} else if (y <= 1.05e-79) {
		tmp = x / y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (x + y)
	tmp = 0
	if y <= -2.7e-23:
		tmp = t_0
	elif y <= -6e-302:
		tmp = (x / y) + -1.0
	elif y <= 7e-116:
		tmp = (x / y) * (x / y)
	elif y <= 1.05e-79:
		tmp = x / y
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(y / Float64(x + y))
	tmp = 0.0
	if (y <= -2.7e-23)
		tmp = t_0;
	elseif (y <= -6e-302)
		tmp = Float64(Float64(x / y) + -1.0);
	elseif (y <= 7e-116)
		tmp = Float64(Float64(x / y) * Float64(x / y));
	elseif (y <= 1.05e-79)
		tmp = Float64(x / y);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y / (x + y);
	tmp = 0.0;
	if (y <= -2.7e-23)
		tmp = t_0;
	elseif (y <= -6e-302)
		tmp = (x / y) + -1.0;
	elseif (y <= 7e-116)
		tmp = (x / y) * (x / y);
	elseif (y <= 1.05e-79)
		tmp = x / y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.7e-23], t$95$0, If[LessEqual[y, -6e-302], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, 7e-116], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.05e-79], N[(x / y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{x + y}\\
\mathbf{if}\;y \leq -2.7 \cdot 10^{-23}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -6 \cdot 10^{-302}:\\
\;\;\;\;\frac{x}{y} + -1\\

\mathbf{elif}\;y \leq 7 \cdot 10^{-116}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\

\mathbf{elif}\;y \leq 1.05 \cdot 10^{-79}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2.69999999999999985e-23 or 1.05e-79 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(x - y\right)} \]
    4. Step-by-step derivation
      1. flip--4.6%

        \[\leadsto \frac{1}{y} \cdot \color{blue}{\frac{x \cdot x - y \cdot y}{x + y}} \]
      2. associate-*r/4.6%

        \[\leadsto \color{blue}{\frac{\frac{1}{y} \cdot \left(x \cdot x - y \cdot y\right)}{x + y}} \]
      3. +-commutative4.6%

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot y}}{y + x} \]
    7. Step-by-step derivation
      1. neg-mul-12.0%

        \[\leadsto \frac{\color{blue}{-y}}{y + x} \]
    8. Simplified2.0%

      \[\leadsto \frac{\color{blue}{-y}}{y + x} \]
    9. Step-by-step derivation
      1. *-un-lft-identity2.0%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-y\right)}}{y + x} \]
      2. lft-mult-inverse2.0%

        \[\leadsto \frac{\color{blue}{\left(\frac{1}{y} \cdot y\right)} \cdot \left(-y\right)}{y + x} \]
      3. associate-*r*1.5%

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

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

        \[\leadsto \frac{\color{blue}{\frac{1}{y} \cdot \left(y \cdot \left(-y\right)\right)}}{y + x} \]
      6. associate-/l*1.5%

        \[\leadsto \color{blue}{\frac{\frac{1}{y}}{\frac{y + x}{y \cdot \left(-y\right)}}} \]
      7. div-inv1.5%

        \[\leadsto \color{blue}{\frac{1}{y} \cdot \frac{1}{\frac{y + x}{y \cdot \left(-y\right)}}} \]
      8. div-inv1.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\color{blue}{\left(y + x\right) \cdot \frac{1}{y \cdot \left(-y\right)}}} \]
      9. metadata-eval1.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{\color{blue}{1 \cdot 1}}{y \cdot \left(-y\right)}} \]
      10. add-sqr-sqrt0.7%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)}}} \]
      11. sqrt-unprod17.3%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}} \]
      12. sqr-neg17.3%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \sqrt{\color{blue}{y \cdot y}}}} \]
      13. sqrt-unprod16.6%

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

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \color{blue}{y}}} \]
      15. frac-times37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \color{blue}{\left(\frac{1}{y} \cdot \frac{1}{y}\right)}} \]
      16. inv-pow37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \left(\color{blue}{{y}^{-1}} \cdot \frac{1}{y}\right)} \]
      17. inv-pow37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \left({y}^{-1} \cdot \color{blue}{{y}^{-1}}\right)} \]
      18. pow-prod-up37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \color{blue}{{y}^{\left(-1 + -1\right)}}} \]
      19. metadata-eval37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot {y}^{\color{blue}{-2}}} \]
    10. Applied egg-rr37.5%

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot {y}^{-2}}} \]
    11. Step-by-step derivation
      1. *-commutative37.5%

        \[\leadsto \color{blue}{\frac{1}{\left(y + x\right) \cdot {y}^{-2}} \cdot \frac{1}{y}} \]
      2. *-commutative37.5%

        \[\leadsto \frac{1}{\color{blue}{{y}^{-2} \cdot \left(y + x\right)}} \cdot \frac{1}{y} \]
      3. associate-/r*35.8%

        \[\leadsto \color{blue}{\frac{\frac{1}{{y}^{-2}}}{y + x}} \cdot \frac{1}{y} \]
      4. metadata-eval35.8%

        \[\leadsto \frac{\frac{1}{{y}^{\color{blue}{\left(2 \cdot -1\right)}}}}{y + x} \cdot \frac{1}{y} \]
      5. pow-sqr35.7%

        \[\leadsto \frac{\frac{1}{\color{blue}{{y}^{-1} \cdot {y}^{-1}}}}{y + x} \cdot \frac{1}{y} \]
      6. unpow-135.7%

        \[\leadsto \frac{\frac{1}{\color{blue}{\frac{1}{y}} \cdot {y}^{-1}}}{y + x} \cdot \frac{1}{y} \]
      7. unpow-135.7%

        \[\leadsto \frac{\frac{1}{\frac{1}{y} \cdot \color{blue}{\frac{1}{y}}}}{y + x} \cdot \frac{1}{y} \]
      8. associate-/l/35.8%

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\frac{1}{y}}}{\frac{1}{y}}}}{y + x} \cdot \frac{1}{y} \]
      9. remove-double-div35.9%

        \[\leadsto \frac{\frac{\color{blue}{y}}{\frac{1}{y}}}{y + x} \cdot \frac{1}{y} \]
      10. associate-/l*35.9%

        \[\leadsto \frac{\color{blue}{\frac{y \cdot y}{1}}}{y + x} \cdot \frac{1}{y} \]
      11. /-rgt-identity35.9%

        \[\leadsto \frac{\color{blue}{y \cdot y}}{y + x} \cdot \frac{1}{y} \]
      12. associate-/l*71.9%

        \[\leadsto \color{blue}{\frac{y}{\frac{y + x}{y}}} \cdot \frac{1}{y} \]
      13. associate-*l/71.9%

        \[\leadsto \color{blue}{\frac{y \cdot \frac{1}{y}}{\frac{y + x}{y}}} \]
      14. /-rgt-identity71.9%

        \[\leadsto \frac{\color{blue}{\frac{y}{1}} \cdot \frac{1}{y}}{\frac{y + x}{y}} \]
      15. associate-/r/71.9%

        \[\leadsto \frac{\color{blue}{\frac{y}{\frac{1}{\frac{1}{y}}}}}{\frac{y + x}{y}} \]
      16. remove-double-div72.0%

        \[\leadsto \frac{\frac{y}{\color{blue}{y}}}{\frac{y + x}{y}} \]
      17. *-inverses72.0%

        \[\leadsto \frac{\color{blue}{1}}{\frac{y + x}{y}} \]
      18. associate-/l*72.0%

        \[\leadsto \color{blue}{\frac{1 \cdot y}{y + x}} \]
      19. *-lft-identity72.0%

        \[\leadsto \frac{\color{blue}{y}}{y + x} \]
    12. Simplified72.0%

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

    if -2.69999999999999985e-23 < y < -5.99999999999999978e-302

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{\left|-\left(y + -1 \cdot x\right)\right|}{\left|y\right|}} \]
    3. Step-by-step derivation
      1. fabs-neg100.0%

        \[\leadsto \frac{\color{blue}{\left|y + -1 \cdot x\right|}}{\left|y\right|} \]
      2. mul-1-neg100.0%

        \[\leadsto \frac{\left|y + \color{blue}{\left(-x\right)}\right|}{\left|y\right|} \]
      3. sub-neg100.0%

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

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

        \[\leadsto \color{blue}{\left|\frac{x - y}{y}\right|} \]
      6. rem-square-sqrt53.2%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x - y}{y}} \cdot \sqrt{\frac{x - y}{y}}} \]
      8. rem-square-sqrt53.7%

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      9. div-sub53.7%

        \[\leadsto \color{blue}{\frac{x}{y} - \frac{y}{y}} \]
      10. sub-neg53.7%

        \[\leadsto \color{blue}{\frac{x}{y} + \left(-\frac{y}{y}\right)} \]
      11. *-inverses53.7%

        \[\leadsto \frac{x}{y} + \left(-\color{blue}{1}\right) \]
      12. metadata-eval53.7%

        \[\leadsto \frac{x}{y} + \color{blue}{-1} \]
      13. +-commutative53.7%

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

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

    if -5.99999999999999978e-302 < y < 6.99999999999999968e-116

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{y}} \cdot \left(x - y\right) \]
    3. Applied egg-rr37.8%

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(x - y\right)} \]
    4. Step-by-step derivation
      1. flip--35.4%

        \[\leadsto \frac{1}{y} \cdot \color{blue}{\frac{x \cdot x - y \cdot y}{x + y}} \]
      2. associate-*r/30.8%

        \[\leadsto \color{blue}{\frac{\frac{1}{y} \cdot \left(x \cdot x - y \cdot y\right)}{x + y}} \]
      3. +-commutative30.8%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{y} \cdot \left(x \cdot x - y \cdot y\right)}{y + x}} \]
    6. Taylor expanded in y around 0 31.0%

      \[\leadsto \frac{\color{blue}{\frac{{x}^{2}}{y}}}{y + x} \]
    7. Step-by-step derivation
      1. unpow231.0%

        \[\leadsto \frac{\frac{\color{blue}{x \cdot x}}{y}}{y + x} \]
      2. associate-/l*33.5%

        \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y}{x}}}}{y + x} \]
      3. associate-/r/33.5%

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{y + x} \]
    8. Simplified33.5%

      \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{y + x} \]
    9. Taylor expanded in x around 0 48.0%

      \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
    10. Step-by-step derivation
      1. unpow248.0%

        \[\leadsto \frac{\color{blue}{x \cdot x}}{{y}^{2}} \]
      2. unpow248.0%

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} \]
      3. times-frac48.5%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} \]
    11. Simplified48.5%

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

    if 6.99999999999999968e-116 < y < 1.05e-79

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{y}} \cdot \left(x - y\right) \]
    3. Applied egg-rr74.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-23}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq -6 \cdot 10^{-302}:\\ \;\;\;\;\frac{x}{y} + -1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-116}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-79}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x + y}\\ \end{array} \]

Alternative 4: 57.9% accurate, 22.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{-28} \lor \neg \left(y \leq 9.8 \cdot 10^{-80}\right):\\
\;\;\;\;\frac{y}{x + y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + -1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.80000000000000026e-28 or 9.79999999999999981e-80 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(x - y\right)} \]
    4. Step-by-step derivation
      1. flip--4.6%

        \[\leadsto \frac{1}{y} \cdot \color{blue}{\frac{x \cdot x - y \cdot y}{x + y}} \]
      2. associate-*r/4.6%

        \[\leadsto \color{blue}{\frac{\frac{1}{y} \cdot \left(x \cdot x - y \cdot y\right)}{x + y}} \]
      3. +-commutative4.6%

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot y}}{y + x} \]
    7. Step-by-step derivation
      1. neg-mul-12.0%

        \[\leadsto \frac{\color{blue}{-y}}{y + x} \]
    8. Simplified2.0%

      \[\leadsto \frac{\color{blue}{-y}}{y + x} \]
    9. Step-by-step derivation
      1. *-un-lft-identity2.0%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-y\right)}}{y + x} \]
      2. lft-mult-inverse2.0%

        \[\leadsto \frac{\color{blue}{\left(\frac{1}{y} \cdot y\right)} \cdot \left(-y\right)}{y + x} \]
      3. associate-*r*1.5%

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

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

        \[\leadsto \frac{\color{blue}{\frac{1}{y} \cdot \left(y \cdot \left(-y\right)\right)}}{y + x} \]
      6. associate-/l*1.5%

        \[\leadsto \color{blue}{\frac{\frac{1}{y}}{\frac{y + x}{y \cdot \left(-y\right)}}} \]
      7. div-inv1.5%

        \[\leadsto \color{blue}{\frac{1}{y} \cdot \frac{1}{\frac{y + x}{y \cdot \left(-y\right)}}} \]
      8. div-inv1.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\color{blue}{\left(y + x\right) \cdot \frac{1}{y \cdot \left(-y\right)}}} \]
      9. metadata-eval1.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{\color{blue}{1 \cdot 1}}{y \cdot \left(-y\right)}} \]
      10. add-sqr-sqrt0.7%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)}}} \]
      11. sqrt-unprod17.3%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}} \]
      12. sqr-neg17.3%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \sqrt{\color{blue}{y \cdot y}}}} \]
      13. sqrt-unprod16.6%

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

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \frac{1 \cdot 1}{y \cdot \color{blue}{y}}} \]
      15. frac-times37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \color{blue}{\left(\frac{1}{y} \cdot \frac{1}{y}\right)}} \]
      16. inv-pow37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \left(\color{blue}{{y}^{-1}} \cdot \frac{1}{y}\right)} \]
      17. inv-pow37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \left({y}^{-1} \cdot \color{blue}{{y}^{-1}}\right)} \]
      18. pow-prod-up37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot \color{blue}{{y}^{\left(-1 + -1\right)}}} \]
      19. metadata-eval37.5%

        \[\leadsto \frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot {y}^{\color{blue}{-2}}} \]
    10. Applied egg-rr37.5%

      \[\leadsto \color{blue}{\frac{1}{y} \cdot \frac{1}{\left(y + x\right) \cdot {y}^{-2}}} \]
    11. Step-by-step derivation
      1. *-commutative37.5%

        \[\leadsto \color{blue}{\frac{1}{\left(y + x\right) \cdot {y}^{-2}} \cdot \frac{1}{y}} \]
      2. *-commutative37.5%

        \[\leadsto \frac{1}{\color{blue}{{y}^{-2} \cdot \left(y + x\right)}} \cdot \frac{1}{y} \]
      3. associate-/r*35.8%

        \[\leadsto \color{blue}{\frac{\frac{1}{{y}^{-2}}}{y + x}} \cdot \frac{1}{y} \]
      4. metadata-eval35.8%

        \[\leadsto \frac{\frac{1}{{y}^{\color{blue}{\left(2 \cdot -1\right)}}}}{y + x} \cdot \frac{1}{y} \]
      5. pow-sqr35.7%

        \[\leadsto \frac{\frac{1}{\color{blue}{{y}^{-1} \cdot {y}^{-1}}}}{y + x} \cdot \frac{1}{y} \]
      6. unpow-135.7%

        \[\leadsto \frac{\frac{1}{\color{blue}{\frac{1}{y}} \cdot {y}^{-1}}}{y + x} \cdot \frac{1}{y} \]
      7. unpow-135.7%

        \[\leadsto \frac{\frac{1}{\frac{1}{y} \cdot \color{blue}{\frac{1}{y}}}}{y + x} \cdot \frac{1}{y} \]
      8. associate-/l/35.8%

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\frac{1}{y}}}{\frac{1}{y}}}}{y + x} \cdot \frac{1}{y} \]
      9. remove-double-div35.9%

        \[\leadsto \frac{\frac{\color{blue}{y}}{\frac{1}{y}}}{y + x} \cdot \frac{1}{y} \]
      10. associate-/l*35.9%

        \[\leadsto \frac{\color{blue}{\frac{y \cdot y}{1}}}{y + x} \cdot \frac{1}{y} \]
      11. /-rgt-identity35.9%

        \[\leadsto \frac{\color{blue}{y \cdot y}}{y + x} \cdot \frac{1}{y} \]
      12. associate-/l*71.9%

        \[\leadsto \color{blue}{\frac{y}{\frac{y + x}{y}}} \cdot \frac{1}{y} \]
      13. associate-*l/71.9%

        \[\leadsto \color{blue}{\frac{y \cdot \frac{1}{y}}{\frac{y + x}{y}}} \]
      14. /-rgt-identity71.9%

        \[\leadsto \frac{\color{blue}{\frac{y}{1}} \cdot \frac{1}{y}}{\frac{y + x}{y}} \]
      15. associate-/r/71.9%

        \[\leadsto \frac{\color{blue}{\frac{y}{\frac{1}{\frac{1}{y}}}}}{\frac{y + x}{y}} \]
      16. remove-double-div72.0%

        \[\leadsto \frac{\frac{y}{\color{blue}{y}}}{\frac{y + x}{y}} \]
      17. *-inverses72.0%

        \[\leadsto \frac{\color{blue}{1}}{\frac{y + x}{y}} \]
      18. associate-/l*72.0%

        \[\leadsto \color{blue}{\frac{1 \cdot y}{y + x}} \]
      19. *-lft-identity72.0%

        \[\leadsto \frac{\color{blue}{y}}{y + x} \]
    12. Simplified72.0%

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

    if -5.80000000000000026e-28 < y < 9.79999999999999981e-80

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{\left|-\left(y + -1 \cdot x\right)\right|}{\left|y\right|}} \]
    3. Step-by-step derivation
      1. fabs-neg100.0%

        \[\leadsto \frac{\color{blue}{\left|y + -1 \cdot x\right|}}{\left|y\right|} \]
      2. mul-1-neg100.0%

        \[\leadsto \frac{\left|y + \color{blue}{\left(-x\right)}\right|}{\left|y\right|} \]
      3. sub-neg100.0%

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

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

        \[\leadsto \color{blue}{\left|\frac{x - y}{y}\right|} \]
      6. rem-square-sqrt48.9%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x - y}{y}} \cdot \sqrt{\frac{x - y}{y}}} \]
      8. rem-square-sqrt49.4%

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      9. div-sub49.4%

        \[\leadsto \color{blue}{\frac{x}{y} - \frac{y}{y}} \]
      10. sub-neg49.4%

        \[\leadsto \color{blue}{\frac{x}{y} + \left(-\frac{y}{y}\right)} \]
      11. *-inverses49.4%

        \[\leadsto \frac{x}{y} + \left(-\color{blue}{1}\right) \]
      12. metadata-eval49.4%

        \[\leadsto \frac{x}{y} + \color{blue}{-1} \]
      13. +-commutative49.4%

        \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    4. Simplified49.4%

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{-28} \lor \neg \left(y \leq 9.8 \cdot 10^{-80}\right):\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} + -1\\ \end{array} \]

Alternative 5: 25.7% accurate, 68.3× speedup?

\[\begin{array}{l} \\ \frac{x}{y} \end{array} \]
(FPCore (x y) :precision binary64 (/ x y))
double code(double x, double y) {
	return x / y;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x / y
end function
public static double code(double x, double y) {
	return x / y;
}
def code(x, y):
	return x / y
function code(x, y)
	return Float64(x / y)
end
function tmp = code(x, y)
	tmp = x / y;
end
code[x_, y_] := N[(x / y), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{y}} \cdot \left(x - y\right) \]
  3. Applied egg-rr29.7%

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

    \[\leadsto \color{blue}{\frac{x}{y}} \]
  5. Final simplification30.4%

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

Alternative 6: 1.3% accurate, 205.0× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{y}} \cdot \left(x - y\right) \]
  3. Applied egg-rr29.7%

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

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification1.3%

    \[\leadsto -1 \]

Reproduce

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