Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5

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

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 56.8% accurate, 8.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x + y}\\ t_1 := \frac{x \cdot \frac{x}{y}}{y - x}\\ \mathbf{if}\;y \leq -1.15 \cdot 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.42 \cdot 10^{-182}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-189}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -5 \cdot 10^{-262}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-304}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-269}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-78}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (+ x y))) (t_1 (/ (* x (/ x y)) (- y x))))
   (if (<= y -1.15e-66)
     t_0
     (if (<= y -1.42e-182)
       t_1
       (if (<= y -1.8e-189)
         t_0
         (if (<= y -5e-262)
           (/ x y)
           (if (<= y 2.2e-304)
             (/ (* x x) (* y y))
             (if (<= y 2.3e-269) (/ x y) (if (<= y 1.7e-78) t_1 t_0)))))))))
double code(double x, double y) {
	double t_0 = y / (x + y);
	double t_1 = (x * (x / y)) / (y - x);
	double tmp;
	if (y <= -1.15e-66) {
		tmp = t_0;
	} else if (y <= -1.42e-182) {
		tmp = t_1;
	} else if (y <= -1.8e-189) {
		tmp = t_0;
	} else if (y <= -5e-262) {
		tmp = x / y;
	} else if (y <= 2.2e-304) {
		tmp = (x * x) / (y * y);
	} else if (y <= 2.3e-269) {
		tmp = x / y;
	} else if (y <= 1.7e-78) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = y / (x + y)
    t_1 = (x * (x / y)) / (y - x)
    if (y <= (-1.15d-66)) then
        tmp = t_0
    else if (y <= (-1.42d-182)) then
        tmp = t_1
    else if (y <= (-1.8d-189)) then
        tmp = t_0
    else if (y <= (-5d-262)) then
        tmp = x / y
    else if (y <= 2.2d-304) then
        tmp = (x * x) / (y * y)
    else if (y <= 2.3d-269) then
        tmp = x / y
    else if (y <= 1.7d-78) then
        tmp = t_1
    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 t_1 = (x * (x / y)) / (y - x);
	double tmp;
	if (y <= -1.15e-66) {
		tmp = t_0;
	} else if (y <= -1.42e-182) {
		tmp = t_1;
	} else if (y <= -1.8e-189) {
		tmp = t_0;
	} else if (y <= -5e-262) {
		tmp = x / y;
	} else if (y <= 2.2e-304) {
		tmp = (x * x) / (y * y);
	} else if (y <= 2.3e-269) {
		tmp = x / y;
	} else if (y <= 1.7e-78) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (x + y)
	t_1 = (x * (x / y)) / (y - x)
	tmp = 0
	if y <= -1.15e-66:
		tmp = t_0
	elif y <= -1.42e-182:
		tmp = t_1
	elif y <= -1.8e-189:
		tmp = t_0
	elif y <= -5e-262:
		tmp = x / y
	elif y <= 2.2e-304:
		tmp = (x * x) / (y * y)
	elif y <= 2.3e-269:
		tmp = x / y
	elif y <= 1.7e-78:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(y / Float64(x + y))
	t_1 = Float64(Float64(x * Float64(x / y)) / Float64(y - x))
	tmp = 0.0
	if (y <= -1.15e-66)
		tmp = t_0;
	elseif (y <= -1.42e-182)
		tmp = t_1;
	elseif (y <= -1.8e-189)
		tmp = t_0;
	elseif (y <= -5e-262)
		tmp = Float64(x / y);
	elseif (y <= 2.2e-304)
		tmp = Float64(Float64(x * x) / Float64(y * y));
	elseif (y <= 2.3e-269)
		tmp = Float64(x / y);
	elseif (y <= 1.7e-78)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y / (x + y);
	t_1 = (x * (x / y)) / (y - x);
	tmp = 0.0;
	if (y <= -1.15e-66)
		tmp = t_0;
	elseif (y <= -1.42e-182)
		tmp = t_1;
	elseif (y <= -1.8e-189)
		tmp = t_0;
	elseif (y <= -5e-262)
		tmp = x / y;
	elseif (y <= 2.2e-304)
		tmp = (x * x) / (y * y);
	elseif (y <= 2.3e-269)
		tmp = x / y;
	elseif (y <= 1.7e-78)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.15e-66], t$95$0, If[LessEqual[y, -1.42e-182], t$95$1, If[LessEqual[y, -1.8e-189], t$95$0, If[LessEqual[y, -5e-262], N[(x / y), $MachinePrecision], If[LessEqual[y, 2.2e-304], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3e-269], N[(x / y), $MachinePrecision], If[LessEqual[y, 1.7e-78], t$95$1, t$95$0]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1.42 \cdot 10^{-182}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -1.8 \cdot 10^{-189}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -5 \cdot 10^{-262}:\\
\;\;\;\;\frac{x}{y}\\

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

\mathbf{elif}\;y \leq 2.3 \cdot 10^{-269}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;y \leq 1.7 \cdot 10^{-78}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.14999999999999996e-66 or -1.4199999999999999e-182 < y < -1.80000000000000008e-189 or 1.70000000000000006e-78 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{0 + y}}{y + x} \]
    11. Step-by-step derivation
      1. +-lft-identity69.8%

        \[\leadsto \frac{\color{blue}{y}}{y + x} \]
    12. Simplified69.8%

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

    if -1.14999999999999996e-66 < y < -1.4199999999999999e-182 or 2.3e-269 < y < 1.70000000000000006e-78

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(x \cdot \frac{x}{y}\right) \cdot 1}{y - x}} \]
      2. *-rgt-identity54.3%

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

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

    if -1.80000000000000008e-189 < y < -4.99999999999999992e-262 or 2.2e-304 < y < 2.3e-269

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -4.99999999999999992e-262 < y < 2.2e-304

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} \]
    11. Simplified72.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.15 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq -1.42 \cdot 10^{-182}:\\ \;\;\;\;\frac{x \cdot \frac{x}{y}}{y - x}\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-189}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq -5 \cdot 10^{-262}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-304}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-269}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-78}:\\ \;\;\;\;\frac{x \cdot \frac{x}{y}}{y - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x + y}\\ \end{array} \]

Alternative 3: 56.0% accurate, 8.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x + y}\\ t_1 := \frac{\frac{x}{y}}{\frac{y - x}{x}}\\ \mathbf{if}\;y \leq -1.65 \cdot 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -9.6 \cdot 10^{-184}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-189}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{-262}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-304}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-269}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{+57}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (+ x y))) (t_1 (/ (/ x y) (/ (- y x) x))))
   (if (<= y -1.65e-66)
     t_0
     (if (<= y -9.6e-184)
       t_1
       (if (<= y -6.5e-189)
         t_0
         (if (<= y -2.25e-262)
           (/ x y)
           (if (<= y 2.2e-304)
             (/ (* x x) (* y y))
             (if (<= y 1.5e-269) (/ x y) (if (<= y 5.8e+57) t_1 t_0)))))))))
double code(double x, double y) {
	double t_0 = y / (x + y);
	double t_1 = (x / y) / ((y - x) / x);
	double tmp;
	if (y <= -1.65e-66) {
		tmp = t_0;
	} else if (y <= -9.6e-184) {
		tmp = t_1;
	} else if (y <= -6.5e-189) {
		tmp = t_0;
	} else if (y <= -2.25e-262) {
		tmp = x / y;
	} else if (y <= 2.2e-304) {
		tmp = (x * x) / (y * y);
	} else if (y <= 1.5e-269) {
		tmp = x / y;
	} else if (y <= 5.8e+57) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = y / (x + y)
    t_1 = (x / y) / ((y - x) / x)
    if (y <= (-1.65d-66)) then
        tmp = t_0
    else if (y <= (-9.6d-184)) then
        tmp = t_1
    else if (y <= (-6.5d-189)) then
        tmp = t_0
    else if (y <= (-2.25d-262)) then
        tmp = x / y
    else if (y <= 2.2d-304) then
        tmp = (x * x) / (y * y)
    else if (y <= 1.5d-269) then
        tmp = x / y
    else if (y <= 5.8d+57) then
        tmp = t_1
    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 t_1 = (x / y) / ((y - x) / x);
	double tmp;
	if (y <= -1.65e-66) {
		tmp = t_0;
	} else if (y <= -9.6e-184) {
		tmp = t_1;
	} else if (y <= -6.5e-189) {
		tmp = t_0;
	} else if (y <= -2.25e-262) {
		tmp = x / y;
	} else if (y <= 2.2e-304) {
		tmp = (x * x) / (y * y);
	} else if (y <= 1.5e-269) {
		tmp = x / y;
	} else if (y <= 5.8e+57) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (x + y)
	t_1 = (x / y) / ((y - x) / x)
	tmp = 0
	if y <= -1.65e-66:
		tmp = t_0
	elif y <= -9.6e-184:
		tmp = t_1
	elif y <= -6.5e-189:
		tmp = t_0
	elif y <= -2.25e-262:
		tmp = x / y
	elif y <= 2.2e-304:
		tmp = (x * x) / (y * y)
	elif y <= 1.5e-269:
		tmp = x / y
	elif y <= 5.8e+57:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(y / Float64(x + y))
	t_1 = Float64(Float64(x / y) / Float64(Float64(y - x) / x))
	tmp = 0.0
	if (y <= -1.65e-66)
		tmp = t_0;
	elseif (y <= -9.6e-184)
		tmp = t_1;
	elseif (y <= -6.5e-189)
		tmp = t_0;
	elseif (y <= -2.25e-262)
		tmp = Float64(x / y);
	elseif (y <= 2.2e-304)
		tmp = Float64(Float64(x * x) / Float64(y * y));
	elseif (y <= 1.5e-269)
		tmp = Float64(x / y);
	elseif (y <= 5.8e+57)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y / (x + y);
	t_1 = (x / y) / ((y - x) / x);
	tmp = 0.0;
	if (y <= -1.65e-66)
		tmp = t_0;
	elseif (y <= -9.6e-184)
		tmp = t_1;
	elseif (y <= -6.5e-189)
		tmp = t_0;
	elseif (y <= -2.25e-262)
		tmp = x / y;
	elseif (y <= 2.2e-304)
		tmp = (x * x) / (y * y);
	elseif (y <= 1.5e-269)
		tmp = x / y;
	elseif (y <= 5.8e+57)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] / N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.65e-66], t$95$0, If[LessEqual[y, -9.6e-184], t$95$1, If[LessEqual[y, -6.5e-189], t$95$0, If[LessEqual[y, -2.25e-262], N[(x / y), $MachinePrecision], If[LessEqual[y, 2.2e-304], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e-269], N[(x / y), $MachinePrecision], If[LessEqual[y, 5.8e+57], t$95$1, t$95$0]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -9.6 \cdot 10^{-184}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -6.5 \cdot 10^{-189}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -2.25 \cdot 10^{-262}:\\
\;\;\;\;\frac{x}{y}\\

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

\mathbf{elif}\;y \leq 1.5 \cdot 10^{-269}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;y \leq 5.8 \cdot 10^{+57}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.6499999999999999e-66 or -9.60000000000000097e-184 < y < -6.5000000000000001e-189 or 5.8000000000000003e57 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{0 + y}}{y + x} \]
    11. Step-by-step derivation
      1. +-lft-identity78.4%

        \[\leadsto \frac{\color{blue}{y}}{y + x} \]
    12. Simplified78.4%

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

    if -1.6499999999999999e-66 < y < -9.60000000000000097e-184 or 1.4999999999999999e-269 < y < 5.8000000000000003e57

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(x \cdot \frac{x}{y}\right) \cdot 1}{y - x}} \]
      2. *-rgt-identity36.3%

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{y - x} \]
      4. associate-/l*52.6%

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

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

    if -6.5000000000000001e-189 < y < -2.24999999999999999e-262 or 2.2e-304 < y < 1.4999999999999999e-269

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -2.24999999999999999e-262 < y < 2.2e-304

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} \]
    11. Simplified72.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.65 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq -9.6 \cdot 10^{-184}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{y - x}{x}}\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-189}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{-262}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-304}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-269}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{+57}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{y - x}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x + y}\\ \end{array} \]

Alternative 4: 55.3% accurate, 8.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x + y}\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2 \cdot 10^{-183}:\\ \;\;\;\;\frac{\frac{x}{y} \cdot \left(-x\right)}{x + y}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-188}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-262}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-304}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-270}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{+57}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{y - x}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (+ x y))))
   (if (<= y -1.25e-66)
     t_0
     (if (<= y -2e-183)
       (/ (* (/ x y) (- x)) (+ x y))
       (if (<= y -1e-188)
         t_0
         (if (<= y -6.5e-262)
           (/ x y)
           (if (<= y 2.35e-304)
             (/ (* x x) (* y y))
             (if (<= y 9.6e-270)
               (/ x y)
               (if (<= y 3.3e+57) (/ (/ x y) (/ (- y x) x)) t_0)))))))))
double code(double x, double y) {
	double t_0 = y / (x + y);
	double tmp;
	if (y <= -1.25e-66) {
		tmp = t_0;
	} else if (y <= -2e-183) {
		tmp = ((x / y) * -x) / (x + y);
	} else if (y <= -1e-188) {
		tmp = t_0;
	} else if (y <= -6.5e-262) {
		tmp = x / y;
	} else if (y <= 2.35e-304) {
		tmp = (x * x) / (y * y);
	} else if (y <= 9.6e-270) {
		tmp = x / y;
	} else if (y <= 3.3e+57) {
		tmp = (x / y) / ((y - x) / x);
	} 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.25d-66)) then
        tmp = t_0
    else if (y <= (-2d-183)) then
        tmp = ((x / y) * -x) / (x + y)
    else if (y <= (-1d-188)) then
        tmp = t_0
    else if (y <= (-6.5d-262)) then
        tmp = x / y
    else if (y <= 2.35d-304) then
        tmp = (x * x) / (y * y)
    else if (y <= 9.6d-270) then
        tmp = x / y
    else if (y <= 3.3d+57) then
        tmp = (x / y) / ((y - x) / x)
    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.25e-66) {
		tmp = t_0;
	} else if (y <= -2e-183) {
		tmp = ((x / y) * -x) / (x + y);
	} else if (y <= -1e-188) {
		tmp = t_0;
	} else if (y <= -6.5e-262) {
		tmp = x / y;
	} else if (y <= 2.35e-304) {
		tmp = (x * x) / (y * y);
	} else if (y <= 9.6e-270) {
		tmp = x / y;
	} else if (y <= 3.3e+57) {
		tmp = (x / y) / ((y - x) / x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (x + y)
	tmp = 0
	if y <= -1.25e-66:
		tmp = t_0
	elif y <= -2e-183:
		tmp = ((x / y) * -x) / (x + y)
	elif y <= -1e-188:
		tmp = t_0
	elif y <= -6.5e-262:
		tmp = x / y
	elif y <= 2.35e-304:
		tmp = (x * x) / (y * y)
	elif y <= 9.6e-270:
		tmp = x / y
	elif y <= 3.3e+57:
		tmp = (x / y) / ((y - x) / x)
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(y / Float64(x + y))
	tmp = 0.0
	if (y <= -1.25e-66)
		tmp = t_0;
	elseif (y <= -2e-183)
		tmp = Float64(Float64(Float64(x / y) * Float64(-x)) / Float64(x + y));
	elseif (y <= -1e-188)
		tmp = t_0;
	elseif (y <= -6.5e-262)
		tmp = Float64(x / y);
	elseif (y <= 2.35e-304)
		tmp = Float64(Float64(x * x) / Float64(y * y));
	elseif (y <= 9.6e-270)
		tmp = Float64(x / y);
	elseif (y <= 3.3e+57)
		tmp = Float64(Float64(x / y) / Float64(Float64(y - x) / x));
	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.25e-66)
		tmp = t_0;
	elseif (y <= -2e-183)
		tmp = ((x / y) * -x) / (x + y);
	elseif (y <= -1e-188)
		tmp = t_0;
	elseif (y <= -6.5e-262)
		tmp = x / y;
	elseif (y <= 2.35e-304)
		tmp = (x * x) / (y * y);
	elseif (y <= 9.6e-270)
		tmp = x / y;
	elseif (y <= 3.3e+57)
		tmp = (x / y) / ((y - x) / x);
	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.25e-66], t$95$0, If[LessEqual[y, -2e-183], N[(N[(N[(x / y), $MachinePrecision] * (-x)), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1e-188], t$95$0, If[LessEqual[y, -6.5e-262], N[(x / y), $MachinePrecision], If[LessEqual[y, 2.35e-304], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.6e-270], N[(x / y), $MachinePrecision], If[LessEqual[y, 3.3e+57], N[(N[(x / y), $MachinePrecision] / N[(N[(y - x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -2 \cdot 10^{-183}:\\
\;\;\;\;\frac{\frac{x}{y} \cdot \left(-x\right)}{x + y}\\

\mathbf{elif}\;y \leq -1 \cdot 10^{-188}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -6.5 \cdot 10^{-262}:\\
\;\;\;\;\frac{x}{y}\\

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

\mathbf{elif}\;y \leq 9.6 \cdot 10^{-270}:\\
\;\;\;\;\frac{x}{y}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < -1.2499999999999999e-66 or -2.00000000000000001e-183 < y < -9.9999999999999995e-189 or 3.3000000000000001e57 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{0 + y}}{y + x} \]
    11. Step-by-step derivation
      1. +-lft-identity78.4%

        \[\leadsto \frac{\color{blue}{y}}{y + x} \]
    12. Simplified78.4%

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

    if -1.2499999999999999e-66 < y < -2.00000000000000001e-183

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x \cdot x}{y}}}{y + x} \]
      2. frac-2neg32.2%

        \[\leadsto \frac{\color{blue}{\frac{-x \cdot x}{-y}}}{y + x} \]
      3. add-sqr-sqrt32.1%

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

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

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

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

        \[\leadsto \frac{\frac{-x \cdot x}{\color{blue}{y}}}{y + x} \]
      8. distribute-neg-frac53.3%

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

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

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

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

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

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

        \[\leadsto \frac{0 - x \cdot \color{blue}{\frac{x}{y}}}{y + x} \]
    10. Applied egg-rr53.3%

      \[\leadsto \frac{\color{blue}{0 - x \cdot \frac{x}{y}}}{y + x} \]
    11. Step-by-step derivation
      1. neg-sub053.3%

        \[\leadsto \frac{\color{blue}{-x \cdot \frac{x}{y}}}{y + x} \]
      2. distribute-lft-neg-in53.3%

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

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

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

    if -9.9999999999999995e-189 < y < -6.5000000000000003e-262 or 2.35e-304 < y < 9.60000000000000007e-270

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -6.5000000000000003e-262 < y < 2.35e-304

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} \]
    11. Simplified72.6%

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

    if 9.60000000000000007e-270 < y < 3.3000000000000001e57

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x \cdot \frac{x}{y}\right) \cdot \frac{1}{\color{blue}{\left(-y\right) + \left(-x\right)}} \]
      17. 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)} \]
      18. sqrt-unprod30.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)} \]
      19. sqr-neg30.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot x}}{y - x} \]
      4. associate-/l*52.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq -2 \cdot 10^{-183}:\\ \;\;\;\;\frac{\frac{x}{y} \cdot \left(-x\right)}{x + y}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-188}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-262}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-304}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-270}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{+57}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{y - x}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x + y}\\ \end{array} \]

Alternative 5: 56.7% accurate, 18.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{+40}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+156}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -7e+40)
   (/ x y)
   (if (<= x 1.65e+156) (/ y (+ x y)) (/ (* x x) (* y y)))))
double code(double x, double y) {
	double tmp;
	if (x <= -7e+40) {
		tmp = x / y;
	} else if (x <= 1.65e+156) {
		tmp = y / (x + y);
	} else {
		tmp = (x * x) / (y * y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-7d+40)) then
        tmp = x / y
    else if (x <= 1.65d+156) then
        tmp = y / (x + y)
    else
        tmp = (x * x) / (y * y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -7e+40) {
		tmp = x / y;
	} else if (x <= 1.65e+156) {
		tmp = y / (x + y);
	} else {
		tmp = (x * x) / (y * y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -7e+40:
		tmp = x / y
	elif x <= 1.65e+156:
		tmp = y / (x + y)
	else:
		tmp = (x * x) / (y * y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -7e+40)
		tmp = Float64(x / y);
	elseif (x <= 1.65e+156)
		tmp = Float64(y / Float64(x + y));
	else
		tmp = Float64(Float64(x * x) / Float64(y * y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -7e+40)
		tmp = x / y;
	elseif (x <= 1.65e+156)
		tmp = y / (x + y);
	else
		tmp = (x * x) / (y * y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -7e+40], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.65e+156], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{y}\\

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -6.9999999999999998e40 < x < 1.6499999999999999e156

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{0} + y}{y + x} \]
    10. Applied egg-rr68.1%

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

        \[\leadsto \frac{\color{blue}{y}}{y + x} \]
    12. Simplified68.1%

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

    if 1.6499999999999999e156 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} \]
    11. Simplified57.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{+40}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+156}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \end{array} \]

Alternative 6: 58.6% accurate, 22.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.52 \cdot 10^{-58} \lor \neg \left(y \leq 1.75 \cdot 10^{-69}\right):\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -1.52e-58) (not (<= y 1.75e-69))) (/ y (+ x y)) (/ x y)))
double code(double x, double y) {
	double tmp;
	if ((y <= -1.52e-58) || !(y <= 1.75e-69)) {
		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 <= (-1.52d-58)) .or. (.not. (y <= 1.75d-69))) 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 <= -1.52e-58) || !(y <= 1.75e-69)) {
		tmp = y / (x + y);
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -1.52e-58) or not (y <= 1.75e-69):
		tmp = y / (x + y)
	else:
		tmp = x / y
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -1.52e-58) || !(y <= 1.75e-69))
		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 <= -1.52e-58) || ~((y <= 1.75e-69)))
		tmp = y / (x + y);
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -1.52e-58], N[Not[LessEqual[y, 1.75e-69]], $MachinePrecision]], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.52 \cdot 10^{-58} \lor \neg \left(y \leq 1.75 \cdot 10^{-69}\right):\\
\;\;\;\;\frac{y}{x + y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.51999999999999993e-58 or 1.7500000000000001e-69 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y}}{y + x} \]
    12. Simplified71.1%

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

    if -1.51999999999999993e-58 < y < 1.7500000000000001e-69

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.52 \cdot 10^{-58} \lor \neg \left(y \leq 1.75 \cdot 10^{-69}\right):\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 7: 26.4% accurate, 68.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{x}{y}} \]
  5. Final simplification26.1%

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

Alternative 8: 1.3% accurate, 205.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1 \]

Reproduce

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