Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5

Percentage Accurate: 100.0% → 100.0%
Time: 5.5s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 2.0× speedup?

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

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

    \[\frac{\left|x - y\right|}{\left|y\right|} \]
  2. 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|\frac{x}{y} + -1\right| \]

Alternative 2: 74.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-67}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 7 \cdot 10^{-73}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.99999999999999989e-67 or 6.9999999999999995e-73 < y

    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. Taylor expanded in x around 0 75.9%

      \[\leadsto \left|\color{blue}{1}\right| \]

    if -1.99999999999999989e-67 < y < 6.9999999999999995e-73

    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. Taylor expanded in x around inf 85.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-67}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-73}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 3: 59.2% accurate, 10.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{\frac{x}{y}}{y - x}\\ t_1 := \frac{y}{x + y}\\ \mathbf{if}\;y \leq -4.8 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{-168}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{-273}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-296}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-211}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-155}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (/ (/ x y) (- y x)))) (t_1 (/ y (+ x y))))
   (if (<= y -4.8e-65)
     t_1
     (if (<= y -3.2e-168)
       (/ x y)
       (if (<= y -2.8e-273)
         t_0
         (if (<= y 2.9e-296)
           (/ x y)
           (if (<= y 4.4e-211) t_0 (if (<= y 1.3e-155) (/ x y) t_1))))))))
double code(double x, double y) {
	double t_0 = x * ((x / y) / (y - x));
	double t_1 = y / (x + y);
	double tmp;
	if (y <= -4.8e-65) {
		tmp = t_1;
	} else if (y <= -3.2e-168) {
		tmp = x / y;
	} else if (y <= -2.8e-273) {
		tmp = t_0;
	} else if (y <= 2.9e-296) {
		tmp = x / y;
	} else if (y <= 4.4e-211) {
		tmp = t_0;
	} else if (y <= 1.3e-155) {
		tmp = x / y;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * ((x / y) / (y - x))
    t_1 = y / (x + y)
    if (y <= (-4.8d-65)) then
        tmp = t_1
    else if (y <= (-3.2d-168)) then
        tmp = x / y
    else if (y <= (-2.8d-273)) then
        tmp = t_0
    else if (y <= 2.9d-296) then
        tmp = x / y
    else if (y <= 4.4d-211) then
        tmp = t_0
    else if (y <= 1.3d-155) then
        tmp = x / y
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x * ((x / y) / (y - x));
	double t_1 = y / (x + y);
	double tmp;
	if (y <= -4.8e-65) {
		tmp = t_1;
	} else if (y <= -3.2e-168) {
		tmp = x / y;
	} else if (y <= -2.8e-273) {
		tmp = t_0;
	} else if (y <= 2.9e-296) {
		tmp = x / y;
	} else if (y <= 4.4e-211) {
		tmp = t_0;
	} else if (y <= 1.3e-155) {
		tmp = x / y;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = x * ((x / y) / (y - x))
	t_1 = y / (x + y)
	tmp = 0
	if y <= -4.8e-65:
		tmp = t_1
	elif y <= -3.2e-168:
		tmp = x / y
	elif y <= -2.8e-273:
		tmp = t_0
	elif y <= 2.9e-296:
		tmp = x / y
	elif y <= 4.4e-211:
		tmp = t_0
	elif y <= 1.3e-155:
		tmp = x / y
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(x * Float64(Float64(x / y) / Float64(y - x)))
	t_1 = Float64(y / Float64(x + y))
	tmp = 0.0
	if (y <= -4.8e-65)
		tmp = t_1;
	elseif (y <= -3.2e-168)
		tmp = Float64(x / y);
	elseif (y <= -2.8e-273)
		tmp = t_0;
	elseif (y <= 2.9e-296)
		tmp = Float64(x / y);
	elseif (y <= 4.4e-211)
		tmp = t_0;
	elseif (y <= 1.3e-155)
		tmp = Float64(x / y);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x * ((x / y) / (y - x));
	t_1 = y / (x + y);
	tmp = 0.0;
	if (y <= -4.8e-65)
		tmp = t_1;
	elseif (y <= -3.2e-168)
		tmp = x / y;
	elseif (y <= -2.8e-273)
		tmp = t_0;
	elseif (y <= 2.9e-296)
		tmp = x / y;
	elseif (y <= 4.4e-211)
		tmp = t_0;
	elseif (y <= 1.3e-155)
		tmp = x / y;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(N[(x / y), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.8e-65], t$95$1, If[LessEqual[y, -3.2e-168], N[(x / y), $MachinePrecision], If[LessEqual[y, -2.8e-273], t$95$0, If[LessEqual[y, 2.9e-296], N[(x / y), $MachinePrecision], If[LessEqual[y, 4.4e-211], t$95$0, If[LessEqual[y, 1.3e-155], N[(x / y), $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -3.2 \cdot 10^{-168}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;y \leq -2.8 \cdot 10^{-273}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 2.9 \cdot 10^{-296}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;y \leq 4.4 \cdot 10^{-211}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 1.3 \cdot 10^{-155}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.8000000000000003e-65 or 1.30000000000000004e-155 < y

    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-sqrt14.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    5. Step-by-step derivation
      1. +-commutative15.4%

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

        \[\leadsto \frac{x}{y} + \color{blue}{\left(-1\right)} \]
      3. sub-neg15.4%

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

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

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      6. clear-num15.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x - y}}} \]
      7. associate-/r/15.4%

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

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

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

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

      \[\leadsto \frac{\frac{1}{y} \cdot \color{blue}{\left(-1 \cdot {y}^{2}\right)}}{x + y} \]
    8. Step-by-step derivation
      1. unpow21.6%

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

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

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

      \[\leadsto \frac{\frac{1}{y} \cdot \color{blue}{\left(y \cdot \left(-y\right)\right)}}{x + y} \]
    10. Step-by-step derivation
      1. associate-*r*2.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-y\right)}{x + y} \]
      3. *-un-lft-identity2.0%

        \[\leadsto \frac{\color{blue}{-y}}{x + y} \]
      4. add-sqr-sqrt1.0%

        \[\leadsto \frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{x + y} \]
      5. sqrt-unprod23.1%

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

        \[\leadsto \frac{\sqrt{\color{blue}{y \cdot y}}}{x + y} \]
      7. sqrt-unprod32.0%

        \[\leadsto \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{x + y} \]
      8. add-sqr-sqrt71.3%

        \[\leadsto \frac{\color{blue}{y}}{x + y} \]
      9. add-log-exp3.6%

        \[\leadsto \frac{\color{blue}{\log \left(e^{y}\right)}}{x + y} \]
      10. *-un-lft-identity3.6%

        \[\leadsto \frac{\log \color{blue}{\left(1 \cdot e^{y}\right)}}{x + y} \]
      11. log-prod3.6%

        \[\leadsto \frac{\color{blue}{\log 1 + \log \left(e^{y}\right)}}{x + y} \]
      12. add-log-exp71.3%

        \[\leadsto \frac{\log 1 + \color{blue}{y}}{x + y} \]
      13. metadata-eval71.3%

        \[\leadsto \frac{\color{blue}{0} + y}{x + y} \]
    11. Applied egg-rr71.3%

      \[\leadsto \frac{\color{blue}{0 + y}}{x + y} \]
    12. Step-by-step derivation
      1. +-lft-identity71.3%

        \[\leadsto \frac{\color{blue}{y}}{x + y} \]
    13. Simplified71.3%

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

    if -4.8000000000000003e-65 < y < -3.20000000000000006e-168 or -2.79999999999999985e-273 < y < 2.89999999999999983e-296 or 4.39999999999999996e-211 < y < 1.30000000000000004e-155

    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-sqrt68.6%

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

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

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

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

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

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

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

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

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

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

    if -3.20000000000000006e-168 < y < -2.79999999999999985e-273 or 2.89999999999999983e-296 < y < 4.39999999999999996e-211

    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-sqrt31.3%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    5. Step-by-step derivation
      1. +-commutative31.8%

        \[\leadsto \color{blue}{\frac{x}{y} + -1} \]
      2. metadata-eval31.8%

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

        \[\leadsto \color{blue}{\frac{x}{y} - 1} \]
      4. *-inverses31.8%

        \[\leadsto \frac{x}{y} - \color{blue}{\frac{y}{y}} \]
      5. div-sub31.8%

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      6. clear-num31.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x - y}}} \]
      7. associate-/r/31.7%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y}}}{x + y} \]
    9. Simplified29.1%

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

        \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}}}{x + y} \]
      2. *-un-lft-identity29.3%

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

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

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

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

        \[\leadsto \left(-\color{blue}{\frac{1 \cdot \left(x \cdot x\right)}{y}}\right) \cdot \frac{1}{-\left(x + y\right)} \]
      7. *-un-lft-identity29.4%

        \[\leadsto \left(-\frac{\color{blue}{x \cdot x}}{y}\right) \cdot \frac{1}{-\left(x + y\right)} \]
      8. distribute-neg-frac29.4%

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

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

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

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

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

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

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

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

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{-\color{blue}{\left(y + x\right)}} \]
      17. distribute-neg-in63.6%

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\left(-y\right) + \left(-x\right)}} \]
      18. add-sqr-sqrt34.9%

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}} + \left(-x\right)} \]
      19. sqrt-unprod62.4%

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} + \left(-x\right)} \]
      20. sqr-neg62.4%

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\sqrt{\color{blue}{y \cdot y}} + \left(-x\right)} \]
      21. sqrt-unprod28.7%

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\sqrt{y} \cdot \sqrt{y}} + \left(-x\right)} \]
      22. fma-def28.7%

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(\sqrt{y}, \sqrt{y}, -x\right)}} \]
      23. fma-neg28.7%

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

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

      \[\leadsto \color{blue}{\left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{y - x}} \]
    12. Step-by-step derivation
      1. associate-*l*62.4%

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

        \[\leadsto x \cdot \color{blue}{\frac{\frac{x}{y} \cdot 1}{y - x}} \]
      3. *-rgt-identity62.4%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{y}}}{y - x} \]
    13. Simplified62.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{-65}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{-168}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{-273}:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{-296}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-211}:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-155}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x + y}\\ \end{array} \]

Alternative 4: 59.2% accurate, 10.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x + y}\\ \mathbf{if}\;y \leq -1.2 \cdot 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -3.6 \cdot 10^{-168}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-273}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{-x}{x + y}\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-296}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 4.7 \cdot 10^{-211}:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-156}:\\ \;\;\;\;\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.2e-66)
     t_0
     (if (<= y -3.6e-168)
       (/ x y)
       (if (<= y -2.9e-273)
         (* (/ x y) (/ (- x) (+ x y)))
         (if (<= y 9.8e-296)
           (/ x y)
           (if (<= y 4.7e-211)
             (* x (/ (/ x y) (- y x)))
             (if (<= y 1.65e-156) (/ x y) t_0))))))))
double code(double x, double y) {
	double t_0 = y / (x + y);
	double tmp;
	if (y <= -1.2e-66) {
		tmp = t_0;
	} else if (y <= -3.6e-168) {
		tmp = x / y;
	} else if (y <= -2.9e-273) {
		tmp = (x / y) * (-x / (x + y));
	} else if (y <= 9.8e-296) {
		tmp = x / y;
	} else if (y <= 4.7e-211) {
		tmp = x * ((x / y) / (y - x));
	} else if (y <= 1.65e-156) {
		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.2d-66)) then
        tmp = t_0
    else if (y <= (-3.6d-168)) then
        tmp = x / y
    else if (y <= (-2.9d-273)) then
        tmp = (x / y) * (-x / (x + y))
    else if (y <= 9.8d-296) then
        tmp = x / y
    else if (y <= 4.7d-211) then
        tmp = x * ((x / y) / (y - x))
    else if (y <= 1.65d-156) 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.2e-66) {
		tmp = t_0;
	} else if (y <= -3.6e-168) {
		tmp = x / y;
	} else if (y <= -2.9e-273) {
		tmp = (x / y) * (-x / (x + y));
	} else if (y <= 9.8e-296) {
		tmp = x / y;
	} else if (y <= 4.7e-211) {
		tmp = x * ((x / y) / (y - x));
	} else if (y <= 1.65e-156) {
		tmp = x / y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (x + y)
	tmp = 0
	if y <= -1.2e-66:
		tmp = t_0
	elif y <= -3.6e-168:
		tmp = x / y
	elif y <= -2.9e-273:
		tmp = (x / y) * (-x / (x + y))
	elif y <= 9.8e-296:
		tmp = x / y
	elif y <= 4.7e-211:
		tmp = x * ((x / y) / (y - x))
	elif y <= 1.65e-156:
		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.2e-66)
		tmp = t_0;
	elseif (y <= -3.6e-168)
		tmp = Float64(x / y);
	elseif (y <= -2.9e-273)
		tmp = Float64(Float64(x / y) * Float64(Float64(-x) / Float64(x + y)));
	elseif (y <= 9.8e-296)
		tmp = Float64(x / y);
	elseif (y <= 4.7e-211)
		tmp = Float64(x * Float64(Float64(x / y) / Float64(y - x)));
	elseif (y <= 1.65e-156)
		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.2e-66)
		tmp = t_0;
	elseif (y <= -3.6e-168)
		tmp = x / y;
	elseif (y <= -2.9e-273)
		tmp = (x / y) * (-x / (x + y));
	elseif (y <= 9.8e-296)
		tmp = x / y;
	elseif (y <= 4.7e-211)
		tmp = x * ((x / y) / (y - x));
	elseif (y <= 1.65e-156)
		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.2e-66], t$95$0, If[LessEqual[y, -3.6e-168], N[(x / y), $MachinePrecision], If[LessEqual[y, -2.9e-273], N[(N[(x / y), $MachinePrecision] * N[((-x) / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.8e-296], N[(x / y), $MachinePrecision], If[LessEqual[y, 4.7e-211], N[(x * N[(N[(x / y), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.65e-156], N[(x / y), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -3.6 \cdot 10^{-168}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;y \leq -2.9 \cdot 10^{-273}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{-x}{x + y}\\

\mathbf{elif}\;y \leq 9.8 \cdot 10^{-296}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;y \leq 4.7 \cdot 10^{-211}:\\
\;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\

\mathbf{elif}\;y \leq 1.65 \cdot 10^{-156}:\\
\;\;\;\;\frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.20000000000000013e-66 or 1.6499999999999999e-156 < y

    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-sqrt14.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    5. Step-by-step derivation
      1. +-commutative15.4%

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

        \[\leadsto \frac{x}{y} + \color{blue}{\left(-1\right)} \]
      3. sub-neg15.4%

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

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

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      6. clear-num15.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x - y}}} \]
      7. associate-/r/15.4%

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

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

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

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

      \[\leadsto \frac{\frac{1}{y} \cdot \color{blue}{\left(-1 \cdot {y}^{2}\right)}}{x + y} \]
    8. Step-by-step derivation
      1. unpow21.6%

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

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

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

      \[\leadsto \frac{\frac{1}{y} \cdot \color{blue}{\left(y \cdot \left(-y\right)\right)}}{x + y} \]
    10. Step-by-step derivation
      1. associate-*r*2.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-y\right)}{x + y} \]
      3. *-un-lft-identity2.0%

        \[\leadsto \frac{\color{blue}{-y}}{x + y} \]
      4. add-sqr-sqrt1.0%

        \[\leadsto \frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{x + y} \]
      5. sqrt-unprod23.1%

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

        \[\leadsto \frac{\sqrt{\color{blue}{y \cdot y}}}{x + y} \]
      7. sqrt-unprod32.0%

        \[\leadsto \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{x + y} \]
      8. add-sqr-sqrt71.3%

        \[\leadsto \frac{\color{blue}{y}}{x + y} \]
      9. add-log-exp3.6%

        \[\leadsto \frac{\color{blue}{\log \left(e^{y}\right)}}{x + y} \]
      10. *-un-lft-identity3.6%

        \[\leadsto \frac{\log \color{blue}{\left(1 \cdot e^{y}\right)}}{x + y} \]
      11. log-prod3.6%

        \[\leadsto \frac{\color{blue}{\log 1 + \log \left(e^{y}\right)}}{x + y} \]
      12. add-log-exp71.3%

        \[\leadsto \frac{\log 1 + \color{blue}{y}}{x + y} \]
      13. metadata-eval71.3%

        \[\leadsto \frac{\color{blue}{0} + y}{x + y} \]
    11. Applied egg-rr71.3%

      \[\leadsto \frac{\color{blue}{0 + y}}{x + y} \]
    12. Step-by-step derivation
      1. +-lft-identity71.3%

        \[\leadsto \frac{\color{blue}{y}}{x + y} \]
    13. Simplified71.3%

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

    if -1.20000000000000013e-66 < y < -3.5999999999999999e-168 or -2.89999999999999986e-273 < y < 9.7999999999999997e-296 or 4.6999999999999997e-211 < y < 1.6499999999999999e-156

    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-sqrt68.6%

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

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

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

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

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

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

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

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

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

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

    if -3.5999999999999999e-168 < y < -2.89999999999999986e-273

    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-sqrt34.8%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    5. Step-by-step derivation
      1. +-commutative35.4%

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

        \[\leadsto \frac{x}{y} + \color{blue}{\left(-1\right)} \]
      3. sub-neg35.4%

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

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

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      6. clear-num35.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x - y}}} \]
      7. associate-/r/35.3%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{x + y} \]
      4. *-commutative30.8%

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

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

        \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}}}{x + y} \]
      2. *-un-lft-identity31.0%

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{\frac{x \cdot x}{y}}}{-\left(x + y\right)} \]
      8. frac-2neg31.0%

        \[\leadsto -\frac{\color{blue}{\frac{-x \cdot x}{-y}}}{-\left(x + y\right)} \]
      9. add-sqr-sqrt30.9%

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

        \[\leadsto -\frac{\frac{-x \cdot x}{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}}{-\left(x + y\right)} \]
      11. sqr-neg16.2%

        \[\leadsto -\frac{\frac{-x \cdot x}{\sqrt{\color{blue}{y \cdot y}}}}{-\left(x + y\right)} \]
      12. sqrt-unprod0.0%

        \[\leadsto -\frac{\frac{-x \cdot x}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}}{-\left(x + y\right)} \]
      13. add-sqr-sqrt46.9%

        \[\leadsto -\frac{\frac{-x \cdot x}{\color{blue}{y}}}{-\left(x + y\right)} \]
      14. distribute-neg-frac46.9%

        \[\leadsto -\frac{\color{blue}{-\frac{x \cdot x}{y}}}{-\left(x + y\right)} \]
      15. associate-*r/61.2%

        \[\leadsto -\frac{-\color{blue}{x \cdot \frac{x}{y}}}{-\left(x + y\right)} \]
      16. frac-2neg61.2%

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

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

        \[\leadsto -\color{blue}{\frac{x}{x + y} \cdot \frac{x}{y}} \]
    11. Applied egg-rr61.3%

      \[\leadsto \color{blue}{-\frac{x}{x + y} \cdot \frac{x}{y}} \]
    12. Step-by-step derivation
      1. distribute-rgt-neg-in61.3%

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

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

    if 9.7999999999999997e-296 < y < 4.6999999999999997e-211

    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-sqrt26.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    5. Step-by-step derivation
      1. +-commutative26.9%

        \[\leadsto \color{blue}{\frac{x}{y} + -1} \]
      2. metadata-eval26.9%

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

        \[\leadsto \color{blue}{\frac{x}{y} - 1} \]
      4. *-inverses26.9%

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

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      6. clear-num26.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x - y}}} \]
      7. associate-/r/26.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{x + y} \]
      4. *-commutative27.0%

        \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y}}}{x + y} \]
    9. Simplified27.0%

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

        \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}}}{x + y} \]
      2. *-un-lft-identity27.1%

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

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

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

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

        \[\leadsto \left(-\color{blue}{\frac{1 \cdot \left(x \cdot x\right)}{y}}\right) \cdot \frac{1}{-\left(x + y\right)} \]
      7. *-un-lft-identity27.1%

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

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

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

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

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

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

        \[\leadsto \frac{-x \cdot x}{\color{blue}{-y}} \cdot \frac{1}{-\left(x + y\right)} \]
      14. frac-2neg60.2%

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

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

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{-\color{blue}{\left(y + x\right)}} \]
      17. distribute-neg-in66.9%

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

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

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} + \left(-x\right)} \]
      20. sqr-neg66.9%

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

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\sqrt{y} \cdot \sqrt{y}} + \left(-x\right)} \]
      22. fma-def66.9%

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(\sqrt{y}, \sqrt{y}, -x\right)}} \]
      23. fma-neg66.9%

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

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

      \[\leadsto \color{blue}{\left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{y - x}} \]
    12. Step-by-step derivation
      1. associate-*l*67.1%

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

        \[\leadsto x \cdot \color{blue}{\frac{\frac{x}{y} \cdot 1}{y - x}} \]
      3. *-rgt-identity67.1%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{y}}}{y - x} \]
    13. Simplified67.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.2 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq -3.6 \cdot 10^{-168}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{-273}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{-x}{x + y}\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-296}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 4.7 \cdot 10^{-211}:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-156}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x + y}\\ \end{array} \]

Alternative 5: 59.5% accurate, 10.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.4 \cdot 10^{-70}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -3 \cdot 10^{-168}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-272}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{-x}{x + y}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-296}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 4.7 \cdot 10^{-211}:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-155}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -3.4e-70)
   1.0
   (if (<= y -3e-168)
     (/ x y)
     (if (<= y -1e-272)
       (* (/ x y) (/ (- x) (+ x y)))
       (if (<= y 1.05e-296)
         (/ x y)
         (if (<= y 4.7e-211)
           (* x (/ (/ x y) (- y x)))
           (if (<= y 5.8e-155) (/ x y) 1.0)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -3.4e-70) {
		tmp = 1.0;
	} else if (y <= -3e-168) {
		tmp = x / y;
	} else if (y <= -1e-272) {
		tmp = (x / y) * (-x / (x + y));
	} else if (y <= 1.05e-296) {
		tmp = x / y;
	} else if (y <= 4.7e-211) {
		tmp = x * ((x / y) / (y - x));
	} else if (y <= 5.8e-155) {
		tmp = x / y;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-3.4d-70)) then
        tmp = 1.0d0
    else if (y <= (-3d-168)) then
        tmp = x / y
    else if (y <= (-1d-272)) then
        tmp = (x / y) * (-x / (x + y))
    else if (y <= 1.05d-296) then
        tmp = x / y
    else if (y <= 4.7d-211) then
        tmp = x * ((x / y) / (y - x))
    else if (y <= 5.8d-155) then
        tmp = x / y
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -3.4e-70) {
		tmp = 1.0;
	} else if (y <= -3e-168) {
		tmp = x / y;
	} else if (y <= -1e-272) {
		tmp = (x / y) * (-x / (x + y));
	} else if (y <= 1.05e-296) {
		tmp = x / y;
	} else if (y <= 4.7e-211) {
		tmp = x * ((x / y) / (y - x));
	} else if (y <= 5.8e-155) {
		tmp = x / y;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -3.4e-70:
		tmp = 1.0
	elif y <= -3e-168:
		tmp = x / y
	elif y <= -1e-272:
		tmp = (x / y) * (-x / (x + y))
	elif y <= 1.05e-296:
		tmp = x / y
	elif y <= 4.7e-211:
		tmp = x * ((x / y) / (y - x))
	elif y <= 5.8e-155:
		tmp = x / y
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -3.4e-70)
		tmp = 1.0;
	elseif (y <= -3e-168)
		tmp = Float64(x / y);
	elseif (y <= -1e-272)
		tmp = Float64(Float64(x / y) * Float64(Float64(-x) / Float64(x + y)));
	elseif (y <= 1.05e-296)
		tmp = Float64(x / y);
	elseif (y <= 4.7e-211)
		tmp = Float64(x * Float64(Float64(x / y) / Float64(y - x)));
	elseif (y <= 5.8e-155)
		tmp = Float64(x / y);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -3.4e-70)
		tmp = 1.0;
	elseif (y <= -3e-168)
		tmp = x / y;
	elseif (y <= -1e-272)
		tmp = (x / y) * (-x / (x + y));
	elseif (y <= 1.05e-296)
		tmp = x / y;
	elseif (y <= 4.7e-211)
		tmp = x * ((x / y) / (y - x));
	elseif (y <= 5.8e-155)
		tmp = x / y;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -3.4e-70], 1.0, If[LessEqual[y, -3e-168], N[(x / y), $MachinePrecision], If[LessEqual[y, -1e-272], N[(N[(x / y), $MachinePrecision] * N[((-x) / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.05e-296], N[(x / y), $MachinePrecision], If[LessEqual[y, 4.7e-211], N[(x * N[(N[(x / y), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.8e-155], N[(x / y), $MachinePrecision], 1.0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{-70}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq -3 \cdot 10^{-168}:\\
\;\;\;\;\frac{x}{y}\\

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

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

\mathbf{elif}\;y \leq 4.7 \cdot 10^{-211}:\\
\;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\

\mathbf{elif}\;y \leq 5.8 \cdot 10^{-155}:\\
\;\;\;\;\frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.39999999999999995e-70 or 5.80000000000000021e-155 < y

    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. Taylor expanded in x around 0 71.9%

      \[\leadsto \left|\color{blue}{1}\right| \]

    if -3.39999999999999995e-70 < y < -2.99999999999999991e-168 or -9.9999999999999993e-273 < y < 1.05e-296 or 4.6999999999999997e-211 < y < 5.80000000000000021e-155

    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-sqrt68.6%

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

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

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

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

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

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

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

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

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

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

    if -2.99999999999999991e-168 < y < -9.9999999999999993e-273

    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-sqrt34.8%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    5. Step-by-step derivation
      1. +-commutative35.4%

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

        \[\leadsto \frac{x}{y} + \color{blue}{\left(-1\right)} \]
      3. sub-neg35.4%

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

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

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      6. clear-num35.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x - y}}} \]
      7. associate-/r/35.3%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{x + y} \]
      4. *-commutative30.8%

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

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

        \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}}}{x + y} \]
      2. *-un-lft-identity31.0%

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{\frac{x \cdot x}{y}}}{-\left(x + y\right)} \]
      8. frac-2neg31.0%

        \[\leadsto -\frac{\color{blue}{\frac{-x \cdot x}{-y}}}{-\left(x + y\right)} \]
      9. add-sqr-sqrt30.9%

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

        \[\leadsto -\frac{\frac{-x \cdot x}{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}}{-\left(x + y\right)} \]
      11. sqr-neg16.2%

        \[\leadsto -\frac{\frac{-x \cdot x}{\sqrt{\color{blue}{y \cdot y}}}}{-\left(x + y\right)} \]
      12. sqrt-unprod0.0%

        \[\leadsto -\frac{\frac{-x \cdot x}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}}{-\left(x + y\right)} \]
      13. add-sqr-sqrt46.9%

        \[\leadsto -\frac{\frac{-x \cdot x}{\color{blue}{y}}}{-\left(x + y\right)} \]
      14. distribute-neg-frac46.9%

        \[\leadsto -\frac{\color{blue}{-\frac{x \cdot x}{y}}}{-\left(x + y\right)} \]
      15. associate-*r/61.2%

        \[\leadsto -\frac{-\color{blue}{x \cdot \frac{x}{y}}}{-\left(x + y\right)} \]
      16. frac-2neg61.2%

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

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

        \[\leadsto -\color{blue}{\frac{x}{x + y} \cdot \frac{x}{y}} \]
    11. Applied egg-rr61.3%

      \[\leadsto \color{blue}{-\frac{x}{x + y} \cdot \frac{x}{y}} \]
    12. Step-by-step derivation
      1. distribute-rgt-neg-in61.3%

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

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

    if 1.05e-296 < y < 4.6999999999999997e-211

    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-sqrt26.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    5. Step-by-step derivation
      1. +-commutative26.9%

        \[\leadsto \color{blue}{\frac{x}{y} + -1} \]
      2. metadata-eval26.9%

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

        \[\leadsto \color{blue}{\frac{x}{y} - 1} \]
      4. *-inverses26.9%

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

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      6. clear-num26.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x - y}}} \]
      7. associate-/r/26.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{x + y} \]
      4. *-commutative27.0%

        \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y}}}{x + y} \]
    9. Simplified27.0%

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

        \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}}}{x + y} \]
      2. *-un-lft-identity27.1%

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

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

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

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

        \[\leadsto \left(-\color{blue}{\frac{1 \cdot \left(x \cdot x\right)}{y}}\right) \cdot \frac{1}{-\left(x + y\right)} \]
      7. *-un-lft-identity27.1%

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

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

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

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

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

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

        \[\leadsto \frac{-x \cdot x}{\color{blue}{-y}} \cdot \frac{1}{-\left(x + y\right)} \]
      14. frac-2neg60.2%

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

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

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{-\color{blue}{\left(y + x\right)}} \]
      17. distribute-neg-in66.9%

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

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

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} + \left(-x\right)} \]
      20. sqr-neg66.9%

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

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\sqrt{y} \cdot \sqrt{y}} + \left(-x\right)} \]
      22. fma-def66.9%

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\mathsf{fma}\left(\sqrt{y}, \sqrt{y}, -x\right)}} \]
      23. fma-neg66.9%

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

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

      \[\leadsto \color{blue}{\left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{y - x}} \]
    12. Step-by-step derivation
      1. associate-*l*67.1%

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

        \[\leadsto x \cdot \color{blue}{\frac{\frac{x}{y} \cdot 1}{y - x}} \]
      3. *-rgt-identity67.1%

        \[\leadsto x \cdot \frac{\color{blue}{\frac{x}{y}}}{y - x} \]
    13. Simplified67.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.4 \cdot 10^{-70}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -3 \cdot 10^{-168}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-272}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{-x}{x + y}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-296}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 4.7 \cdot 10^{-211}:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-155}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 6: 59.3% accurate, 15.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x + y}\\ \mathbf{if}\;y \leq -8.5 \cdot 10^{-73}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-304}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 3.75 \cdot 10^{-211}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-159}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (+ x y))))
   (if (<= y -8.5e-73)
     t_0
     (if (<= y 7.2e-304)
       (/ x y)
       (if (<= y 3.75e-211)
         (/ (* x x) (* y y))
         (if (<= y 4.6e-159) (/ x y) t_0))))))
double code(double x, double y) {
	double t_0 = y / (x + y);
	double tmp;
	if (y <= -8.5e-73) {
		tmp = t_0;
	} else if (y <= 7.2e-304) {
		tmp = x / y;
	} else if (y <= 3.75e-211) {
		tmp = (x * x) / (y * y);
	} else if (y <= 4.6e-159) {
		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 <= (-8.5d-73)) then
        tmp = t_0
    else if (y <= 7.2d-304) then
        tmp = x / y
    else if (y <= 3.75d-211) then
        tmp = (x * x) / (y * y)
    else if (y <= 4.6d-159) 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 <= -8.5e-73) {
		tmp = t_0;
	} else if (y <= 7.2e-304) {
		tmp = x / y;
	} else if (y <= 3.75e-211) {
		tmp = (x * x) / (y * y);
	} else if (y <= 4.6e-159) {
		tmp = x / y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (x + y)
	tmp = 0
	if y <= -8.5e-73:
		tmp = t_0
	elif y <= 7.2e-304:
		tmp = x / y
	elif y <= 3.75e-211:
		tmp = (x * x) / (y * y)
	elif y <= 4.6e-159:
		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 <= -8.5e-73)
		tmp = t_0;
	elseif (y <= 7.2e-304)
		tmp = Float64(x / y);
	elseif (y <= 3.75e-211)
		tmp = Float64(Float64(x * x) / Float64(y * y));
	elseif (y <= 4.6e-159)
		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 <= -8.5e-73)
		tmp = t_0;
	elseif (y <= 7.2e-304)
		tmp = x / y;
	elseif (y <= 3.75e-211)
		tmp = (x * x) / (y * y);
	elseif (y <= 4.6e-159)
		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, -8.5e-73], t$95$0, If[LessEqual[y, 7.2e-304], N[(x / y), $MachinePrecision], If[LessEqual[y, 3.75e-211], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.6e-159], N[(x / y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 7.2 \cdot 10^{-304}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;y \leq 3.75 \cdot 10^{-211}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y}\\

\mathbf{elif}\;y \leq 4.6 \cdot 10^{-159}:\\
\;\;\;\;\frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -8.4999999999999996e-73 or 4.59999999999999957e-159 < y

    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-sqrt14.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    5. Step-by-step derivation
      1. +-commutative15.4%

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

        \[\leadsto \frac{x}{y} + \color{blue}{\left(-1\right)} \]
      3. sub-neg15.4%

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

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

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      6. clear-num15.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x - y}}} \]
      7. associate-/r/15.4%

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

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

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

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

      \[\leadsto \frac{\frac{1}{y} \cdot \color{blue}{\left(-1 \cdot {y}^{2}\right)}}{x + y} \]
    8. Step-by-step derivation
      1. unpow21.6%

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

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

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

      \[\leadsto \frac{\frac{1}{y} \cdot \color{blue}{\left(y \cdot \left(-y\right)\right)}}{x + y} \]
    10. Step-by-step derivation
      1. associate-*r*2.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-y\right)}{x + y} \]
      3. *-un-lft-identity2.0%

        \[\leadsto \frac{\color{blue}{-y}}{x + y} \]
      4. add-sqr-sqrt1.0%

        \[\leadsto \frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{x + y} \]
      5. sqrt-unprod23.1%

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

        \[\leadsto \frac{\sqrt{\color{blue}{y \cdot y}}}{x + y} \]
      7. sqrt-unprod32.0%

        \[\leadsto \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{x + y} \]
      8. add-sqr-sqrt71.3%

        \[\leadsto \frac{\color{blue}{y}}{x + y} \]
      9. add-log-exp3.6%

        \[\leadsto \frac{\color{blue}{\log \left(e^{y}\right)}}{x + y} \]
      10. *-un-lft-identity3.6%

        \[\leadsto \frac{\log \color{blue}{\left(1 \cdot e^{y}\right)}}{x + y} \]
      11. log-prod3.6%

        \[\leadsto \frac{\color{blue}{\log 1 + \log \left(e^{y}\right)}}{x + y} \]
      12. add-log-exp71.3%

        \[\leadsto \frac{\log 1 + \color{blue}{y}}{x + y} \]
      13. metadata-eval71.3%

        \[\leadsto \frac{\color{blue}{0} + y}{x + y} \]
    11. Applied egg-rr71.3%

      \[\leadsto \frac{\color{blue}{0 + y}}{x + y} \]
    12. Step-by-step derivation
      1. +-lft-identity71.3%

        \[\leadsto \frac{\color{blue}{y}}{x + y} \]
    13. Simplified71.3%

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

    if -8.4999999999999996e-73 < y < 7.2000000000000003e-304 or 3.7500000000000002e-211 < y < 4.59999999999999957e-159

    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-sqrt57.6%

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

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

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

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

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

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

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

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

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

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

    if 7.2000000000000003e-304 < y < 3.7500000000000002e-211

    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-sqrt31.3%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    5. Step-by-step derivation
      1. +-commutative31.5%

        \[\leadsto \color{blue}{\frac{x}{y} + -1} \]
      2. metadata-eval31.5%

        \[\leadsto \frac{x}{y} + \color{blue}{\left(-1\right)} \]
      3. sub-neg31.5%

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

        \[\leadsto \frac{x}{y} - \color{blue}{\frac{y}{y}} \]
      5. div-sub31.5%

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      6. clear-num31.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x - y}}} \]
      7. associate-/r/31.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{x + y} \]
      4. *-commutative31.6%

        \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y}}}{x + y} \]
    9. Simplified31.6%

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

      \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
    11. Step-by-step derivation
      1. unpow263.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{-73}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-304}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 3.75 \cdot 10^{-211}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-159}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x + y}\\ \end{array} \]

Alternative 7: 59.4% accurate, 22.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{-71} \lor \neg \left(y \leq 3.6 \cdot 10^{-159}\right):\\
\;\;\;\;\frac{y}{x + y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.19999999999999997e-71 or 3.60000000000000021e-159 < y

    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-sqrt14.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 + \frac{x}{y}} \]
    5. Step-by-step derivation
      1. +-commutative15.4%

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

        \[\leadsto \frac{x}{y} + \color{blue}{\left(-1\right)} \]
      3. sub-neg15.4%

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

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

        \[\leadsto \color{blue}{\frac{x - y}{y}} \]
      6. clear-num15.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x - y}}} \]
      7. associate-/r/15.4%

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

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

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

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

      \[\leadsto \frac{\frac{1}{y} \cdot \color{blue}{\left(-1 \cdot {y}^{2}\right)}}{x + y} \]
    8. Step-by-step derivation
      1. unpow21.6%

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

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

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

      \[\leadsto \frac{\frac{1}{y} \cdot \color{blue}{\left(y \cdot \left(-y\right)\right)}}{x + y} \]
    10. Step-by-step derivation
      1. associate-*r*2.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-y\right)}{x + y} \]
      3. *-un-lft-identity2.0%

        \[\leadsto \frac{\color{blue}{-y}}{x + y} \]
      4. add-sqr-sqrt1.0%

        \[\leadsto \frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{x + y} \]
      5. sqrt-unprod23.1%

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

        \[\leadsto \frac{\sqrt{\color{blue}{y \cdot y}}}{x + y} \]
      7. sqrt-unprod32.0%

        \[\leadsto \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{x + y} \]
      8. add-sqr-sqrt71.3%

        \[\leadsto \frac{\color{blue}{y}}{x + y} \]
      9. add-log-exp3.6%

        \[\leadsto \frac{\color{blue}{\log \left(e^{y}\right)}}{x + y} \]
      10. *-un-lft-identity3.6%

        \[\leadsto \frac{\log \color{blue}{\left(1 \cdot e^{y}\right)}}{x + y} \]
      11. log-prod3.6%

        \[\leadsto \frac{\color{blue}{\log 1 + \log \left(e^{y}\right)}}{x + y} \]
      12. add-log-exp71.3%

        \[\leadsto \frac{\log 1 + \color{blue}{y}}{x + y} \]
      13. metadata-eval71.3%

        \[\leadsto \frac{\color{blue}{0} + y}{x + y} \]
    11. Applied egg-rr71.3%

      \[\leadsto \frac{\color{blue}{0 + y}}{x + y} \]
    12. Step-by-step derivation
      1. +-lft-identity71.3%

        \[\leadsto \frac{\color{blue}{y}}{x + y} \]
    13. Simplified71.3%

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

    if -2.19999999999999997e-71 < y < 3.60000000000000021e-159

    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-sqrt52.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{-71} \lor \neg \left(y \leq 3.6 \cdot 10^{-159}\right):\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 8: 26.3% 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. 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-sqrt26.1%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{x}{y}} \]
  6. Final simplification27.9%

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

Alternative 9: 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. 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-sqrt26.1%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1 \]

Reproduce

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