Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5

Percentage Accurate: 100.0% → 100.0%
Time: 4.3s
Alternatives: 7
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 7 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.1% accurate, 8.7× 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}\;x \leq -6.6 \cdot 10^{+183}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{+115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8 \cdot 10^{+96}:\\ \;\;\;\;\frac{x}{y} + -1\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-30}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{+92}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+216}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (/ (/ x y) (- y x)))) (t_1 (/ y (+ x y))))
   (if (<= x -6.6e+183)
     (/ x y)
     (if (<= x -3.3e+115)
       t_1
       (if (<= x -8e+96)
         (+ (/ x y) -1.0)
         (if (<= x -1.35e-30)
           t_0
           (if (<= x 1.5e+69)
             t_1
             (if (<= x 1.22e+92)
               (/ x y)
               (if (<= x 2.3e+216) t_0 (/ (* x x) (* y y)))))))))))
double code(double x, double y) {
	double t_0 = x * ((x / y) / (y - x));
	double t_1 = y / (x + y);
	double tmp;
	if (x <= -6.6e+183) {
		tmp = x / y;
	} else if (x <= -3.3e+115) {
		tmp = t_1;
	} else if (x <= -8e+96) {
		tmp = (x / y) + -1.0;
	} else if (x <= -1.35e-30) {
		tmp = t_0;
	} else if (x <= 1.5e+69) {
		tmp = t_1;
	} else if (x <= 1.22e+92) {
		tmp = x / y;
	} else if (x <= 2.3e+216) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * ((x / y) / (y - x))
    t_1 = y / (x + y)
    if (x <= (-6.6d+183)) then
        tmp = x / y
    else if (x <= (-3.3d+115)) then
        tmp = t_1
    else if (x <= (-8d+96)) then
        tmp = (x / y) + (-1.0d0)
    else if (x <= (-1.35d-30)) then
        tmp = t_0
    else if (x <= 1.5d+69) then
        tmp = t_1
    else if (x <= 1.22d+92) then
        tmp = x / y
    else if (x <= 2.3d+216) then
        tmp = t_0
    else
        tmp = (x * x) / (y * y)
    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 (x <= -6.6e+183) {
		tmp = x / y;
	} else if (x <= -3.3e+115) {
		tmp = t_1;
	} else if (x <= -8e+96) {
		tmp = (x / y) + -1.0;
	} else if (x <= -1.35e-30) {
		tmp = t_0;
	} else if (x <= 1.5e+69) {
		tmp = t_1;
	} else if (x <= 1.22e+92) {
		tmp = x / y;
	} else if (x <= 2.3e+216) {
		tmp = t_0;
	} else {
		tmp = (x * x) / (y * y);
	}
	return tmp;
}
def code(x, y):
	t_0 = x * ((x / y) / (y - x))
	t_1 = y / (x + y)
	tmp = 0
	if x <= -6.6e+183:
		tmp = x / y
	elif x <= -3.3e+115:
		tmp = t_1
	elif x <= -8e+96:
		tmp = (x / y) + -1.0
	elif x <= -1.35e-30:
		tmp = t_0
	elif x <= 1.5e+69:
		tmp = t_1
	elif x <= 1.22e+92:
		tmp = x / y
	elif x <= 2.3e+216:
		tmp = t_0
	else:
		tmp = (x * x) / (y * y)
	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 (x <= -6.6e+183)
		tmp = Float64(x / y);
	elseif (x <= -3.3e+115)
		tmp = t_1;
	elseif (x <= -8e+96)
		tmp = Float64(Float64(x / y) + -1.0);
	elseif (x <= -1.35e-30)
		tmp = t_0;
	elseif (x <= 1.5e+69)
		tmp = t_1;
	elseif (x <= 1.22e+92)
		tmp = Float64(x / y);
	elseif (x <= 2.3e+216)
		tmp = t_0;
	else
		tmp = Float64(Float64(x * x) / Float64(y * y));
	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 (x <= -6.6e+183)
		tmp = x / y;
	elseif (x <= -3.3e+115)
		tmp = t_1;
	elseif (x <= -8e+96)
		tmp = (x / y) + -1.0;
	elseif (x <= -1.35e-30)
		tmp = t_0;
	elseif (x <= 1.5e+69)
		tmp = t_1;
	elseif (x <= 1.22e+92)
		tmp = x / y;
	elseif (x <= 2.3e+216)
		tmp = t_0;
	else
		tmp = (x * x) / (y * y);
	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[x, -6.6e+183], N[(x / y), $MachinePrecision], If[LessEqual[x, -3.3e+115], t$95$1, If[LessEqual[x, -8e+96], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, -1.35e-30], t$95$0, If[LessEqual[x, 1.5e+69], t$95$1, If[LessEqual[x, 1.22e+92], N[(x / y), $MachinePrecision], If[LessEqual[x, 2.3e+216], t$95$0, N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -3.3 \cdot 10^{+115}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq -1.35 \cdot 10^{-30}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{+69}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.22 \cdot 10^{+92}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;x \leq 2.3 \cdot 10^{+216}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -6.60000000000000019e183 or 1.49999999999999992e69 < x < 1.22e92

    1. Initial program 100.0%

      \[\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.4%

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

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

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

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

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

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

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

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

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

    if -6.60000000000000019e183 < x < -3.30000000000000005e115 or -1.34999999999999994e-30 < x < 1.49999999999999992e69

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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.8%

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

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

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

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

      \[\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. neg-sub02.0%

        \[\leadsto \frac{\color{blue}{0 - y}}{y + x} \]
      5. metadata-eval2.0%

        \[\leadsto \frac{\color{blue}{\log 1} - y}{y + x} \]
      6. sub-neg2.0%

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

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

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

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

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

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

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

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

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

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

    if -3.30000000000000005e115 < x < -8.0000000000000004e96

    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-sqrt66.4%

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

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

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

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

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

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

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

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

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

    if -8.0000000000000004e96 < x < -1.34999999999999994e-30 or 1.22e92 < x < 2.29999999999999996e216

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 14.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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.1%

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

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

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

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

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

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

        \[\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-neg39.0%

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

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

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

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

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

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

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

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

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

    if 2.29999999999999996e216 < x

    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-sqrt94.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.6 \cdot 10^{+183}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{+115}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;x \leq -8 \cdot 10^{+96}:\\ \;\;\;\;\frac{x}{y} + -1\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-30}:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+69}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{+92}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+216}:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \end{array} \]

Alternative 3: 56.2% accurate, 8.7× 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}\;x \leq -6.5 \cdot 10^{+183}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.4 \cdot 10^{+123}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{+97}:\\ \;\;\;\;\frac{x}{y} + -1\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-31}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.9 \cdot 10^{+71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+93}:\\ \;\;\;\;\frac{x \cdot \frac{x}{y}}{x + y}\\ \mathbf{elif}\;x \leq 1.06 \cdot 10^{+216}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (/ (/ x y) (- y x)))) (t_1 (/ y (+ x y))))
   (if (<= x -6.5e+183)
     (/ x y)
     (if (<= x -2.4e+123)
       t_1
       (if (<= x -1.8e+97)
         (+ (/ x y) -1.0)
         (if (<= x -3.3e-31)
           t_0
           (if (<= x 6.9e+71)
             t_1
             (if (<= x 1.35e+93)
               (/ (* x (/ x y)) (+ x y))
               (if (<= x 1.06e+216) t_0 (/ (* x x) (* y y)))))))))))
double code(double x, double y) {
	double t_0 = x * ((x / y) / (y - x));
	double t_1 = y / (x + y);
	double tmp;
	if (x <= -6.5e+183) {
		tmp = x / y;
	} else if (x <= -2.4e+123) {
		tmp = t_1;
	} else if (x <= -1.8e+97) {
		tmp = (x / y) + -1.0;
	} else if (x <= -3.3e-31) {
		tmp = t_0;
	} else if (x <= 6.9e+71) {
		tmp = t_1;
	} else if (x <= 1.35e+93) {
		tmp = (x * (x / y)) / (x + y);
	} else if (x <= 1.06e+216) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * ((x / y) / (y - x))
    t_1 = y / (x + y)
    if (x <= (-6.5d+183)) then
        tmp = x / y
    else if (x <= (-2.4d+123)) then
        tmp = t_1
    else if (x <= (-1.8d+97)) then
        tmp = (x / y) + (-1.0d0)
    else if (x <= (-3.3d-31)) then
        tmp = t_0
    else if (x <= 6.9d+71) then
        tmp = t_1
    else if (x <= 1.35d+93) then
        tmp = (x * (x / y)) / (x + y)
    else if (x <= 1.06d+216) then
        tmp = t_0
    else
        tmp = (x * x) / (y * y)
    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 (x <= -6.5e+183) {
		tmp = x / y;
	} else if (x <= -2.4e+123) {
		tmp = t_1;
	} else if (x <= -1.8e+97) {
		tmp = (x / y) + -1.0;
	} else if (x <= -3.3e-31) {
		tmp = t_0;
	} else if (x <= 6.9e+71) {
		tmp = t_1;
	} else if (x <= 1.35e+93) {
		tmp = (x * (x / y)) / (x + y);
	} else if (x <= 1.06e+216) {
		tmp = t_0;
	} else {
		tmp = (x * x) / (y * y);
	}
	return tmp;
}
def code(x, y):
	t_0 = x * ((x / y) / (y - x))
	t_1 = y / (x + y)
	tmp = 0
	if x <= -6.5e+183:
		tmp = x / y
	elif x <= -2.4e+123:
		tmp = t_1
	elif x <= -1.8e+97:
		tmp = (x / y) + -1.0
	elif x <= -3.3e-31:
		tmp = t_0
	elif x <= 6.9e+71:
		tmp = t_1
	elif x <= 1.35e+93:
		tmp = (x * (x / y)) / (x + y)
	elif x <= 1.06e+216:
		tmp = t_0
	else:
		tmp = (x * x) / (y * y)
	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 (x <= -6.5e+183)
		tmp = Float64(x / y);
	elseif (x <= -2.4e+123)
		tmp = t_1;
	elseif (x <= -1.8e+97)
		tmp = Float64(Float64(x / y) + -1.0);
	elseif (x <= -3.3e-31)
		tmp = t_0;
	elseif (x <= 6.9e+71)
		tmp = t_1;
	elseif (x <= 1.35e+93)
		tmp = Float64(Float64(x * Float64(x / y)) / Float64(x + y));
	elseif (x <= 1.06e+216)
		tmp = t_0;
	else
		tmp = Float64(Float64(x * x) / Float64(y * y));
	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 (x <= -6.5e+183)
		tmp = x / y;
	elseif (x <= -2.4e+123)
		tmp = t_1;
	elseif (x <= -1.8e+97)
		tmp = (x / y) + -1.0;
	elseif (x <= -3.3e-31)
		tmp = t_0;
	elseif (x <= 6.9e+71)
		tmp = t_1;
	elseif (x <= 1.35e+93)
		tmp = (x * (x / y)) / (x + y);
	elseif (x <= 1.06e+216)
		tmp = t_0;
	else
		tmp = (x * x) / (y * y);
	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[x, -6.5e+183], N[(x / y), $MachinePrecision], If[LessEqual[x, -2.4e+123], t$95$1, If[LessEqual[x, -1.8e+97], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, -3.3e-31], t$95$0, If[LessEqual[x, 6.9e+71], t$95$1, If[LessEqual[x, 1.35e+93], N[(N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.06e+216], t$95$0, N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2.4 \cdot 10^{+123}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq -3.3 \cdot 10^{-31}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 6.9 \cdot 10^{+71}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.35 \cdot 10^{+93}:\\
\;\;\;\;\frac{x \cdot \frac{x}{y}}{x + y}\\

\mathbf{elif}\;x \leq 1.06 \cdot 10^{+216}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < -6.49999999999999983e183

    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-sqrt0.0%

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

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

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

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

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

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

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

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

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

    if -6.49999999999999983e183 < x < -2.39999999999999989e123 or -3.2999999999999999e-31 < x < 6.89999999999999975e71

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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.8%

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

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

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

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

      \[\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. neg-sub02.0%

        \[\leadsto \frac{\color{blue}{0 - y}}{y + x} \]
      5. metadata-eval2.0%

        \[\leadsto \frac{\color{blue}{\log 1} - y}{y + x} \]
      6. sub-neg2.0%

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

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

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

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

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

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

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

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

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

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

    if -2.39999999999999989e123 < x < -1.79999999999999983e97

    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-sqrt66.4%

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

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

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

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

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

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

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

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

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

    if -1.79999999999999983e97 < x < -3.2999999999999999e-31 or 1.35e93 < x < 1.06e216

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 14.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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.1%

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

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

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

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

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

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

        \[\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-neg39.0%

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

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

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

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

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

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

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

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

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

    if 6.89999999999999975e71 < x < 1.35e93

    1. Initial program 100.0%

      \[\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-sqrt86.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.06e216 < x

    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-sqrt94.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{+183}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.4 \cdot 10^{+123}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{+97}:\\ \;\;\;\;\frac{x}{y} + -1\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-31}:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\ \mathbf{elif}\;x \leq 6.9 \cdot 10^{+71}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+93}:\\ \;\;\;\;\frac{x \cdot \frac{x}{y}}{x + y}\\ \mathbf{elif}\;x \leq 1.06 \cdot 10^{+216}:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \end{array} \]

Alternative 4: 56.7% accurate, 13.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{x + y}\\ \mathbf{if}\;x \leq -1.65 \cdot 10^{+184}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{+69}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+89}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 5.3 \cdot 10^{+171}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ y (+ x y))))
   (if (<= x -1.65e+184)
     (/ x y)
     (if (<= x 1.16e+69)
       t_0
       (if (<= x 8e+89)
         (/ x y)
         (if (<= x 5.3e+171) t_0 (/ (* x x) (* y y))))))))
double code(double x, double y) {
	double t_0 = y / (x + y);
	double tmp;
	if (x <= -1.65e+184) {
		tmp = x / y;
	} else if (x <= 1.16e+69) {
		tmp = t_0;
	} else if (x <= 8e+89) {
		tmp = x / y;
	} else if (x <= 5.3e+171) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = y / (x + y)
    if (x <= (-1.65d+184)) then
        tmp = x / y
    else if (x <= 1.16d+69) then
        tmp = t_0
    else if (x <= 8d+89) then
        tmp = x / y
    else if (x <= 5.3d+171) then
        tmp = t_0
    else
        tmp = (x * x) / (y * y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = y / (x + y);
	double tmp;
	if (x <= -1.65e+184) {
		tmp = x / y;
	} else if (x <= 1.16e+69) {
		tmp = t_0;
	} else if (x <= 8e+89) {
		tmp = x / y;
	} else if (x <= 5.3e+171) {
		tmp = t_0;
	} else {
		tmp = (x * x) / (y * y);
	}
	return tmp;
}
def code(x, y):
	t_0 = y / (x + y)
	tmp = 0
	if x <= -1.65e+184:
		tmp = x / y
	elif x <= 1.16e+69:
		tmp = t_0
	elif x <= 8e+89:
		tmp = x / y
	elif x <= 5.3e+171:
		tmp = t_0
	else:
		tmp = (x * x) / (y * y)
	return tmp
function code(x, y)
	t_0 = Float64(y / Float64(x + y))
	tmp = 0.0
	if (x <= -1.65e+184)
		tmp = Float64(x / y);
	elseif (x <= 1.16e+69)
		tmp = t_0;
	elseif (x <= 8e+89)
		tmp = Float64(x / y);
	elseif (x <= 5.3e+171)
		tmp = t_0;
	else
		tmp = Float64(Float64(x * x) / Float64(y * y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y / (x + y);
	tmp = 0.0;
	if (x <= -1.65e+184)
		tmp = x / y;
	elseif (x <= 1.16e+69)
		tmp = t_0;
	elseif (x <= 8e+89)
		tmp = x / y;
	elseif (x <= 5.3e+171)
		tmp = t_0;
	else
		tmp = (x * x) / (y * y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.65e+184], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.16e+69], t$95$0, If[LessEqual[x, 8e+89], N[(x / y), $MachinePrecision], If[LessEqual[x, 5.3e+171], t$95$0, N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 1.16 \cdot 10^{+69}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 8 \cdot 10^{+89}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;x \leq 5.3 \cdot 10^{+171}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.6499999999999999e184 or 1.16000000000000005e69 < x < 7.99999999999999996e89

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

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

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

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

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

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

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

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

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

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

    if -1.6499999999999999e184 < x < 1.16000000000000005e69 or 7.99999999999999996e89 < x < 5.29999999999999982e171

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

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

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

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

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

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

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

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

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

        \[\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 2.0%

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

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

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

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

      \[\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.2%

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

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

        \[\leadsto \frac{\color{blue}{-y}}{y + x} \]
      4. neg-sub02.2%

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

        \[\leadsto \frac{\color{blue}{\log 1} - y}{y + x} \]
      6. sub-neg2.2%

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

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

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

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

        \[\leadsto \frac{0 + \sqrt{\color{blue}{y \cdot y}}}{y + x} \]
      11. sqrt-unprod27.1%

        \[\leadsto \frac{0 + \color{blue}{\sqrt{y} \cdot \sqrt{y}}}{y + x} \]
      12. add-sqr-sqrt62.9%

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

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

        \[\leadsto \frac{\color{blue}{y}}{y + x} \]
    12. Simplified62.9%

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

    if 5.29999999999999982e171 < x

    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-sqrt93.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.65 \cdot 10^{+184}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{+69}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+89}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 5.3 \cdot 10^{+171}:\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot x}{y \cdot y}\\ \end{array} \]

Alternative 5: 57.2% accurate, 22.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.65 \cdot 10^{-83} \lor \neg \left(y \leq 6 \cdot 10^{-182}\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.65e-83 or 6.0000000000000003e-182 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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.8%

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

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

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

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

      \[\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.1%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\log 1} - y}{y + x} \]
      6. sub-neg2.1%

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

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

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

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

        \[\leadsto \frac{0 + \sqrt{\color{blue}{y \cdot y}}}{y + x} \]
      11. sqrt-unprod30.2%

        \[\leadsto \frac{0 + \color{blue}{\sqrt{y} \cdot \sqrt{y}}}{y + x} \]
      12. add-sqr-sqrt62.2%

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

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

        \[\leadsto \frac{\color{blue}{y}}{y + x} \]
    12. Simplified62.2%

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

    if -2.65e-83 < y < 6.0000000000000003e-182

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.65 \cdot 10^{-83} \lor \neg \left(y \leq 6 \cdot 10^{-182}\right):\\ \;\;\;\;\frac{y}{x + y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 6: 26.1% accurate, 68.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{x}{y}} \]
  5. Final simplification25.3%

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

Alternative 7: 1.3% accurate, 205.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

    \[\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 2023199 
(FPCore (x y)
  :name "Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5"
  :precision binary64
  (/ (fabs (- x y)) (fabs y)))