Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3

Percentage Accurate: 51.1% → 100.0%
Time: 11.8s
Alternatives: 9
Speedup: 3.7×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y \cdot 4\right) \cdot y\\ \frac{x \cdot x - t_0}{x \cdot x + t_0} \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
	double t_0 = (y * 4.0) * y;
	return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    t_0 = (y * 4.0d0) * y
    code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
	double t_0 = (y * 4.0) * y;
	return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y):
	t_0 = (y * 4.0) * y
	return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y)
	t_0 = Float64(Float64(y * 4.0) * y)
	return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0))
end
function tmp = code(x, y)
	t_0 = (y * 4.0) * y;
	tmp = ((x * x) - t_0) / ((x * x) + t_0);
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t_0}{x \cdot x + t_0}
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 51.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y \cdot 4\right) \cdot y\\ \frac{x \cdot x - t_0}{x \cdot x + t_0} \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
	double t_0 = (y * 4.0) * y;
	return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    t_0 = (y * 4.0d0) * y
    code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
	double t_0 = (y * 4.0) * y;
	return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y):
	t_0 = (y * 4.0) * y
	return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y)
	t_0 = Float64(Float64(y * 4.0) * y)
	return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0))
end
function tmp = code(x, y)
	t_0 = (y * 4.0) * y;
	tmp = ((x * x) - t_0) / ((x * x) + t_0);
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t_0}{x \cdot x + t_0}
\end{array}
\end{array}

Alternative 1: 100.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \frac{x}{x + y \cdot \left(\frac{y}{x} \cdot 4\right)} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \end{array} \]
(FPCore (x y)
 :precision binary64
 (- (/ x (+ x (* y (* (/ y x) 4.0)))) (/ y (fma 0.25 (/ x (/ y x)) y))))
double code(double x, double y) {
	return (x / (x + (y * ((y / x) * 4.0)))) - (y / fma(0.25, (x / (y / x)), y));
}
function code(x, y)
	return Float64(Float64(x / Float64(x + Float64(y * Float64(Float64(y / x) * 4.0)))) - Float64(y / fma(0.25, Float64(x / Float64(y / x)), y)))
end
code[x_, y_] := N[(N[(x / N[(x + N[(y * N[(N[(y / x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y / N[(0.25 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{x + y \cdot \left(\frac{y}{x} \cdot 4\right)} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)}
\end{array}
Derivation
  1. Initial program 47.3%

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Step-by-step derivation
    1. div-sub47.3%

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

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

      \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
    4. *-commutative47.3%

      \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
    5. *-commutative47.3%

      \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
    6. fma-def47.3%

      \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}\right) \]
    7. *-commutative47.3%

      \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}\right) \]
  3. Applied egg-rr47.3%

    \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\right)} \]
  4. Step-by-step derivation
    1. sub-neg47.3%

      \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    2. associate-/l*47.8%

      \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}}} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
    3. associate-/l*48.7%

      \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
  5. Simplified48.7%

    \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
  6. Taylor expanded in x around 0 71.1%

    \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{0.25 \cdot \frac{{x}^{2}}{y} + y}} \]
  7. Step-by-step derivation
    1. fma-def71.1%

      \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{y}, y\right)}} \]
    2. unpow271.1%

      \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{\color{blue}{x \cdot x}}{y}, y\right)} \]
    3. associate-/l*75.1%

      \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\mathsf{fma}\left(0.25, \color{blue}{\frac{x}{\frac{y}{x}}}, y\right)} \]
  8. Simplified75.1%

    \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)}} \]
  9. Taylor expanded in x around 0 94.5%

    \[\leadsto \frac{x}{\color{blue}{4 \cdot \frac{{y}^{2}}{x} + x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
  10. Step-by-step derivation
    1. *-commutative94.5%

      \[\leadsto \frac{x}{\color{blue}{\frac{{y}^{2}}{x} \cdot 4} + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    2. unpow294.5%

      \[\leadsto \frac{x}{\frac{\color{blue}{y \cdot y}}{x} \cdot 4 + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    3. associate-*r/100.0%

      \[\leadsto \frac{x}{\color{blue}{\left(y \cdot \frac{y}{x}\right)} \cdot 4 + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    4. associate-*l*100.0%

      \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    5. fma-def100.0%

      \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
  11. Simplified100.0%

    \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
  12. Step-by-step derivation
    1. fma-udef100.0%

      \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right) + x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
  13. Applied egg-rr100.0%

    \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right) + x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
  14. Final simplification100.0%

    \[\leadsto \frac{x}{x + y \cdot \left(\frac{y}{x} \cdot 4\right)} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]

Alternative 2: 80.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{\frac{y}{x}}\\ t_1 := y \cdot \left(\frac{y}{x} \cdot 4\right)\\ t_2 := y \cdot \left(y \cdot 4\right)\\ t_3 := \frac{x \cdot x - t_2}{t_2 + x \cdot x}\\ \mathbf{if}\;t_2 \leq 0:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{-169}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{-95}:\\ \;\;\;\;\frac{x}{x + t_1} - \frac{y}{0.25 \cdot t_0}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+238}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t_1} - \frac{y}{\mathsf{fma}\left(0.25, t_0, y\right)}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (/ y x)))
        (t_1 (* y (* (/ y x) 4.0)))
        (t_2 (* y (* y 4.0)))
        (t_3 (/ (- (* x x) t_2) (+ t_2 (* x x)))))
   (if (<= t_2 0.0)
     (+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))
     (if (<= t_2 5e-169)
       t_3
       (if (<= t_2 2e-95)
         (- (/ x (+ x t_1)) (/ y (* 0.25 t_0)))
         (if (<= t_2 2e+238) t_3 (- (/ x t_1) (/ y (fma 0.25 t_0 y)))))))))
double code(double x, double y) {
	double t_0 = x / (y / x);
	double t_1 = y * ((y / x) * 4.0);
	double t_2 = y * (y * 4.0);
	double t_3 = ((x * x) - t_2) / (t_2 + (x * x));
	double tmp;
	if (t_2 <= 0.0) {
		tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
	} else if (t_2 <= 5e-169) {
		tmp = t_3;
	} else if (t_2 <= 2e-95) {
		tmp = (x / (x + t_1)) - (y / (0.25 * t_0));
	} else if (t_2 <= 2e+238) {
		tmp = t_3;
	} else {
		tmp = (x / t_1) - (y / fma(0.25, t_0, y));
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(x / Float64(y / x))
	t_1 = Float64(y * Float64(Float64(y / x) * 4.0))
	t_2 = Float64(y * Float64(y * 4.0))
	t_3 = Float64(Float64(Float64(x * x) - t_2) / Float64(t_2 + Float64(x * x)))
	tmp = 0.0
	if (t_2 <= 0.0)
		tmp = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y))));
	elseif (t_2 <= 5e-169)
		tmp = t_3;
	elseif (t_2 <= 2e-95)
		tmp = Float64(Float64(x / Float64(x + t_1)) - Float64(y / Float64(0.25 * t_0)));
	elseif (t_2 <= 2e+238)
		tmp = t_3;
	else
		tmp = Float64(Float64(x / t_1) - Float64(y / fma(0.25, t_0, y)));
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(N[(y / x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(x * x), $MachinePrecision] - t$95$2), $MachinePrecision] / N[(t$95$2 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-169], t$95$3, If[LessEqual[t$95$2, 2e-95], N[(N[(x / N[(x + t$95$1), $MachinePrecision]), $MachinePrecision] - N[(y / N[(0.25 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+238], t$95$3, N[(N[(x / t$95$1), $MachinePrecision] - N[(y / N[(0.25 * t$95$0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{\frac{y}{x}}\\
t_1 := y \cdot \left(\frac{y}{x} \cdot 4\right)\\
t_2 := y \cdot \left(y \cdot 4\right)\\
t_3 := \frac{x \cdot x - t_2}{t_2 + x \cdot x}\\
\mathbf{if}\;t_2 \leq 0:\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-169}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{-95}:\\
\;\;\;\;\frac{x}{x + t_1} - \frac{y}{0.25 \cdot t_0}\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+238}:\\
\;\;\;\;t_3\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{t_1} - \frac{y}{\mathsf{fma}\left(0.25, t_0, y\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 (*.f64 y 4) y) < 0.0

    1. Initial program 51.7%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around inf 51.7%

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    4. Simplified51.7%

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

      \[\leadsto \color{blue}{1 + -4 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. unpow283.3%

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

        \[\leadsto 1 + -4 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} \]
      3. times-frac90.6%

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

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

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

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

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

        \[\leadsto 1 + -4 \cdot \color{blue}{\frac{\frac{y}{x}}{\frac{x}{y}}} \]
    9. Applied egg-rr90.6%

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

    if 0.0 < (*.f64 (*.f64 y 4) y) < 5.0000000000000002e-169 or 1.99999999999999998e-95 < (*.f64 (*.f64 y 4) y) < 2.0000000000000001e238

    1. Initial program 80.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]

    if 5.0000000000000002e-169 < (*.f64 (*.f64 y 4) y) < 1.99999999999999998e-95

    1. Initial program 41.7%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. div-sub41.5%

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      4. *-commutative41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      5. *-commutative41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      6. fma-def41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}\right) \]
      7. *-commutative41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}\right) \]
    3. Applied egg-rr41.5%

      \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\right)} \]
    4. Step-by-step derivation
      1. sub-neg41.5%

        \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
      2. associate-/l*43.4%

        \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}}} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
      3. associate-/l*43.4%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    5. Simplified43.4%

      \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    6. Taylor expanded in x around 0 99.9%

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

        \[\leadsto \frac{x}{\color{blue}{\frac{{y}^{2}}{x} \cdot 4} + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      2. unpow299.9%

        \[\leadsto \frac{x}{\frac{\color{blue}{y \cdot y}}{x} \cdot 4 + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      3. associate-*r/99.9%

        \[\leadsto \frac{x}{\color{blue}{\left(y \cdot \frac{y}{x}\right)} \cdot 4 + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      4. associate-*l*99.9%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      5. fma-def99.9%

        \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    8. Simplified99.9%

      \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}} \]
    9. Taylor expanded in x around inf 80.7%

      \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{\color{blue}{0.25 \cdot \frac{{x}^{2}}{y}}} \]
    10. Step-by-step derivation
      1. unpow280.7%

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{0.25 \cdot \frac{\color{blue}{x \cdot x}}{y}} \]
      2. associate-/l*80.7%

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{0.25 \cdot \color{blue}{\frac{x}{\frac{y}{x}}}} \]
    11. Simplified80.7%

      \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{\color{blue}{0.25 \cdot \frac{x}{\frac{y}{x}}}} \]
    12. Step-by-step derivation
      1. fma-udef99.9%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right) + x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    13. Applied egg-rr80.7%

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

    if 2.0000000000000001e238 < (*.f64 (*.f64 y 4) y)

    1. Initial program 6.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. div-sub6.0%

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      4. *-commutative6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      5. *-commutative6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      6. fma-def6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}\right) \]
      7. *-commutative6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}\right) \]
    3. Applied egg-rr6.0%

      \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\right)} \]
    4. Step-by-step derivation
      1. sub-neg6.0%

        \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
      2. associate-/l*6.0%

        \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}}} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
      3. associate-/l*8.9%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    5. Simplified8.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    6. Taylor expanded in x around 0 76.9%

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

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{y}, y\right)}} \]
      2. unpow276.9%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{\color{blue}{x \cdot x}}{y}, y\right)} \]
      3. associate-/l*89.1%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\mathsf{fma}\left(0.25, \color{blue}{\frac{x}{\frac{y}{x}}}, y\right)} \]
    8. Simplified89.1%

      \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)}} \]
    9. Taylor expanded in x around 0 89.1%

      \[\leadsto \frac{x}{\color{blue}{4 \cdot \frac{{y}^{2}}{x}}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    10. Step-by-step derivation
      1. *-commutative89.1%

        \[\leadsto \frac{x}{\color{blue}{\frac{{y}^{2}}{x} \cdot 4}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      2. unpow289.1%

        \[\leadsto \frac{x}{\frac{\color{blue}{y \cdot y}}{x} \cdot 4} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      3. associate-*r/90.1%

        \[\leadsto \frac{x}{\color{blue}{\left(y \cdot \frac{y}{x}\right)} \cdot 4} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      4. associate-*l*90.1%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    11. Simplified90.1%

      \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(y \cdot 4\right) \leq 0:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 5 \cdot 10^{-169}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 2 \cdot 10^{-95}:\\ \;\;\;\;\frac{x}{x + y \cdot \left(\frac{y}{x} \cdot 4\right)} - \frac{y}{0.25 \cdot \frac{x}{\frac{y}{x}}}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 2 \cdot 10^{+238}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot \left(\frac{y}{x} \cdot 4\right)} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)}\\ \end{array} \]

Alternative 3: 80.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ t_1 := \frac{x \cdot x - t_0}{t_0 + x \cdot x}\\ \mathbf{if}\;t_0 \leq 0:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{-169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{-95}:\\ \;\;\;\;\frac{x}{x + y \cdot \left(\frac{y}{x} \cdot 4\right)} - \frac{y}{0.25 \cdot \frac{x}{\frac{y}{x}}}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+238}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* y 4.0))) (t_1 (/ (- (* x x) t_0) (+ t_0 (* x x)))))
   (if (<= t_0 0.0)
     (+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))
     (if (<= t_0 5e-169)
       t_1
       (if (<= t_0 2e-95)
         (- (/ x (+ x (* y (* (/ y x) 4.0)))) (/ y (* 0.25 (/ x (/ y x)))))
         (if (<= t_0 2e+238) t_1 (fma 0.5 (* (/ x y) (/ x y)) -1.0)))))))
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double t_1 = ((x * x) - t_0) / (t_0 + (x * x));
	double tmp;
	if (t_0 <= 0.0) {
		tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
	} else if (t_0 <= 5e-169) {
		tmp = t_1;
	} else if (t_0 <= 2e-95) {
		tmp = (x / (x + (y * ((y / x) * 4.0)))) - (y / (0.25 * (x / (y / x))));
	} else if (t_0 <= 2e+238) {
		tmp = t_1;
	} else {
		tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	t_1 = Float64(Float64(Float64(x * x) - t_0) / Float64(t_0 + Float64(x * x)))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y))));
	elseif (t_0 <= 5e-169)
		tmp = t_1;
	elseif (t_0 <= 2e-95)
		tmp = Float64(Float64(x / Float64(x + Float64(y * Float64(Float64(y / x) * 4.0)))) - Float64(y / Float64(0.25 * Float64(x / Float64(y / x)))));
	elseif (t_0 <= 2e+238)
		tmp = t_1;
	else
		tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0);
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-169], t$95$1, If[LessEqual[t$95$0, 2e-95], N[(N[(x / N[(x + N[(y * N[(N[(y / x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y / N[(0.25 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+238], t$95$1, N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{x \cdot x - t_0}{t_0 + x \cdot x}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{-169}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+238}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 (*.f64 y 4) y) < 0.0

    1. Initial program 51.7%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around inf 51.7%

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    4. Simplified51.7%

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

      \[\leadsto \color{blue}{1 + -4 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. unpow283.3%

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

        \[\leadsto 1 + -4 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} \]
      3. times-frac90.6%

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

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

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

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

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

        \[\leadsto 1 + -4 \cdot \color{blue}{\frac{\frac{y}{x}}{\frac{x}{y}}} \]
    9. Applied egg-rr90.6%

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

    if 0.0 < (*.f64 (*.f64 y 4) y) < 5.0000000000000002e-169 or 1.99999999999999998e-95 < (*.f64 (*.f64 y 4) y) < 2.0000000000000001e238

    1. Initial program 80.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]

    if 5.0000000000000002e-169 < (*.f64 (*.f64 y 4) y) < 1.99999999999999998e-95

    1. Initial program 41.7%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. div-sub41.5%

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      4. *-commutative41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      5. *-commutative41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      6. fma-def41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}\right) \]
      7. *-commutative41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}\right) \]
    3. Applied egg-rr41.5%

      \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\right)} \]
    4. Step-by-step derivation
      1. sub-neg41.5%

        \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
      2. associate-/l*43.4%

        \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}}} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
      3. associate-/l*43.4%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    5. Simplified43.4%

      \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    6. Taylor expanded in x around 0 99.9%

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

        \[\leadsto \frac{x}{\color{blue}{\frac{{y}^{2}}{x} \cdot 4} + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      2. unpow299.9%

        \[\leadsto \frac{x}{\frac{\color{blue}{y \cdot y}}{x} \cdot 4 + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      3. associate-*r/99.9%

        \[\leadsto \frac{x}{\color{blue}{\left(y \cdot \frac{y}{x}\right)} \cdot 4 + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      4. associate-*l*99.9%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      5. fma-def99.9%

        \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    8. Simplified99.9%

      \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}} \]
    9. Taylor expanded in x around inf 80.7%

      \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{\color{blue}{0.25 \cdot \frac{{x}^{2}}{y}}} \]
    10. Step-by-step derivation
      1. unpow280.7%

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{0.25 \cdot \frac{\color{blue}{x \cdot x}}{y}} \]
      2. associate-/l*80.7%

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{0.25 \cdot \color{blue}{\frac{x}{\frac{y}{x}}}} \]
    11. Simplified80.7%

      \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{\color{blue}{0.25 \cdot \frac{x}{\frac{y}{x}}}} \]
    12. Step-by-step derivation
      1. fma-udef99.9%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right) + x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    13. Applied egg-rr80.7%

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

    if 2.0000000000000001e238 < (*.f64 (*.f64 y 4) y)

    1. Initial program 6.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around 0 76.2%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
    3. Step-by-step derivation
      1. fma-neg76.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, \frac{{x}^{2}}{{y}^{2}}, -1\right)} \]
      2. unpow276.2%

        \[\leadsto \mathsf{fma}\left(0.5, \frac{\color{blue}{x \cdot x}}{{y}^{2}}, -1\right) \]
      3. unpow276.2%

        \[\leadsto \mathsf{fma}\left(0.5, \frac{x \cdot x}{\color{blue}{y \cdot y}}, -1\right) \]
      4. times-frac90.1%

        \[\leadsto \mathsf{fma}\left(0.5, \color{blue}{\frac{x}{y} \cdot \frac{x}{y}}, -1\right) \]
      5. metadata-eval90.1%

        \[\leadsto \mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, \color{blue}{-1}\right) \]
    4. Simplified90.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(y \cdot 4\right) \leq 0:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 5 \cdot 10^{-169}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 2 \cdot 10^{-95}:\\ \;\;\;\;\frac{x}{x + y \cdot \left(\frac{y}{x} \cdot 4\right)} - \frac{y}{0.25 \cdot \frac{x}{\frac{y}{x}}}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 2 \cdot 10^{+238}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \end{array} \]

Alternative 4: 80.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ t_1 := y \cdot \left(y \cdot 4\right)\\ t_2 := \frac{x \cdot x - t_1}{t_1 + x \cdot x}\\ \mathbf{if}\;t_1 \leq 0:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{-169}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-95}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+238}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + -1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* -4.0 (/ (/ y x) (/ x y)))))
        (t_1 (* y (* y 4.0)))
        (t_2 (/ (- (* x x) t_1) (+ t_1 (* x x)))))
   (if (<= t_1 0.0)
     t_0
     (if (<= t_1 5e-169)
       t_2
       (if (<= t_1 2e-95)
         t_0
         (if (<= t_1 2e+238) t_2 (+ (/ x (* y (* (/ y x) 4.0))) -1.0)))))))
double code(double x, double y) {
	double t_0 = 1.0 + (-4.0 * ((y / x) / (x / y)));
	double t_1 = y * (y * 4.0);
	double t_2 = ((x * x) - t_1) / (t_1 + (x * x));
	double tmp;
	if (t_1 <= 0.0) {
		tmp = t_0;
	} else if (t_1 <= 5e-169) {
		tmp = t_2;
	} else if (t_1 <= 2e-95) {
		tmp = t_0;
	} else if (t_1 <= 2e+238) {
		tmp = t_2;
	} else {
		tmp = (x / (y * ((y / x) * 4.0))) + -1.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) :: t_2
    real(8) :: tmp
    t_0 = 1.0d0 + ((-4.0d0) * ((y / x) / (x / y)))
    t_1 = y * (y * 4.0d0)
    t_2 = ((x * x) - t_1) / (t_1 + (x * x))
    if (t_1 <= 0.0d0) then
        tmp = t_0
    else if (t_1 <= 5d-169) then
        tmp = t_2
    else if (t_1 <= 2d-95) then
        tmp = t_0
    else if (t_1 <= 2d+238) then
        tmp = t_2
    else
        tmp = (x / (y * ((y / x) * 4.0d0))) + (-1.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 + (-4.0 * ((y / x) / (x / y)));
	double t_1 = y * (y * 4.0);
	double t_2 = ((x * x) - t_1) / (t_1 + (x * x));
	double tmp;
	if (t_1 <= 0.0) {
		tmp = t_0;
	} else if (t_1 <= 5e-169) {
		tmp = t_2;
	} else if (t_1 <= 2e-95) {
		tmp = t_0;
	} else if (t_1 <= 2e+238) {
		tmp = t_2;
	} else {
		tmp = (x / (y * ((y / x) * 4.0))) + -1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 + (-4.0 * ((y / x) / (x / y)))
	t_1 = y * (y * 4.0)
	t_2 = ((x * x) - t_1) / (t_1 + (x * x))
	tmp = 0
	if t_1 <= 0.0:
		tmp = t_0
	elif t_1 <= 5e-169:
		tmp = t_2
	elif t_1 <= 2e-95:
		tmp = t_0
	elif t_1 <= 2e+238:
		tmp = t_2
	else:
		tmp = (x / (y * ((y / x) * 4.0))) + -1.0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y))))
	t_1 = Float64(y * Float64(y * 4.0))
	t_2 = Float64(Float64(Float64(x * x) - t_1) / Float64(t_1 + Float64(x * x)))
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = t_0;
	elseif (t_1 <= 5e-169)
		tmp = t_2;
	elseif (t_1 <= 2e-95)
		tmp = t_0;
	elseif (t_1 <= 2e+238)
		tmp = t_2;
	else
		tmp = Float64(Float64(x / Float64(y * Float64(Float64(y / x) * 4.0))) + -1.0);
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 + (-4.0 * ((y / x) / (x / y)));
	t_1 = y * (y * 4.0);
	t_2 = ((x * x) - t_1) / (t_1 + (x * x));
	tmp = 0.0;
	if (t_1 <= 0.0)
		tmp = t_0;
	elseif (t_1 <= 5e-169)
		tmp = t_2;
	elseif (t_1 <= 2e-95)
		tmp = t_0;
	elseif (t_1 <= 2e+238)
		tmp = t_2;
	else
		tmp = (x / (y * ((y / x) * 4.0))) + -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x * x), $MachinePrecision] - t$95$1), $MachinePrecision] / N[(t$95$1 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 5e-169], t$95$2, If[LessEqual[t$95$1, 2e-95], t$95$0, If[LessEqual[t$95$1, 2e+238], t$95$2, N[(N[(x / N[(y * N[(N[(y / x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
t_1 := y \cdot \left(y \cdot 4\right)\\
t_2 := \frac{x \cdot x - t_1}{t_1 + x \cdot x}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-169}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-95}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+238}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + -1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 y 4) y) < 0.0 or 5.0000000000000002e-169 < (*.f64 (*.f64 y 4) y) < 1.99999999999999998e-95

    1. Initial program 50.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around inf 46.4%

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

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

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

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

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

        \[\leadsto 1 + -4 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} \]
      3. times-frac88.7%

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

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

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

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

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

        \[\leadsto 1 + -4 \cdot \color{blue}{\frac{\frac{y}{x}}{\frac{x}{y}}} \]
    9. Applied egg-rr88.7%

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

    if 0.0 < (*.f64 (*.f64 y 4) y) < 5.0000000000000002e-169 or 1.99999999999999998e-95 < (*.f64 (*.f64 y 4) y) < 2.0000000000000001e238

    1. Initial program 80.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]

    if 2.0000000000000001e238 < (*.f64 (*.f64 y 4) y)

    1. Initial program 6.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. div-sub6.0%

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      4. *-commutative6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      5. *-commutative6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      6. fma-def6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}\right) \]
      7. *-commutative6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}\right) \]
    3. Applied egg-rr6.0%

      \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\right)} \]
    4. Step-by-step derivation
      1. sub-neg6.0%

        \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
      2. associate-/l*6.0%

        \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}}} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
      3. associate-/l*8.9%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    5. Simplified8.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    6. Taylor expanded in x around 0 76.9%

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

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{y}, y\right)}} \]
      2. unpow276.9%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{\color{blue}{x \cdot x}}{y}, y\right)} \]
      3. associate-/l*89.1%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\mathsf{fma}\left(0.25, \color{blue}{\frac{x}{\frac{y}{x}}}, y\right)} \]
    8. Simplified89.1%

      \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)}} \]
    9. Taylor expanded in x around 0 89.1%

      \[\leadsto \frac{x}{\color{blue}{4 \cdot \frac{{y}^{2}}{x}}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    10. Step-by-step derivation
      1. *-commutative89.1%

        \[\leadsto \frac{x}{\color{blue}{\frac{{y}^{2}}{x} \cdot 4}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      2. unpow289.1%

        \[\leadsto \frac{x}{\frac{\color{blue}{y \cdot y}}{x} \cdot 4} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      3. associate-*r/90.1%

        \[\leadsto \frac{x}{\color{blue}{\left(y \cdot \frac{y}{x}\right)} \cdot 4} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      4. associate-*l*90.1%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    11. Simplified90.1%

      \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    12. Taylor expanded in y around inf 89.7%

      \[\leadsto \frac{x}{y \cdot \left(\frac{y}{x} \cdot 4\right)} - \color{blue}{1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(y \cdot 4\right) \leq 0:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 5 \cdot 10^{-169}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 2 \cdot 10^{-95}:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 2 \cdot 10^{+238}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + -1\\ \end{array} \]

Alternative 5: 80.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(\frac{y}{x} \cdot 4\right)\\ t_1 := y \cdot \left(y \cdot 4\right)\\ t_2 := \frac{x \cdot x - t_1}{t_1 + x \cdot x}\\ \mathbf{if}\;t_1 \leq 0:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{-169}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-95}:\\ \;\;\;\;\frac{x}{x + t_0} - \frac{y}{0.25 \cdot \frac{x}{\frac{y}{x}}}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+238}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t_0} + -1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* (/ y x) 4.0)))
        (t_1 (* y (* y 4.0)))
        (t_2 (/ (- (* x x) t_1) (+ t_1 (* x x)))))
   (if (<= t_1 0.0)
     (+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))
     (if (<= t_1 5e-169)
       t_2
       (if (<= t_1 2e-95)
         (- (/ x (+ x t_0)) (/ y (* 0.25 (/ x (/ y x)))))
         (if (<= t_1 2e+238) t_2 (+ (/ x t_0) -1.0)))))))
double code(double x, double y) {
	double t_0 = y * ((y / x) * 4.0);
	double t_1 = y * (y * 4.0);
	double t_2 = ((x * x) - t_1) / (t_1 + (x * x));
	double tmp;
	if (t_1 <= 0.0) {
		tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
	} else if (t_1 <= 5e-169) {
		tmp = t_2;
	} else if (t_1 <= 2e-95) {
		tmp = (x / (x + t_0)) - (y / (0.25 * (x / (y / x))));
	} else if (t_1 <= 2e+238) {
		tmp = t_2;
	} else {
		tmp = (x / t_0) + -1.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) :: t_2
    real(8) :: tmp
    t_0 = y * ((y / x) * 4.0d0)
    t_1 = y * (y * 4.0d0)
    t_2 = ((x * x) - t_1) / (t_1 + (x * x))
    if (t_1 <= 0.0d0) then
        tmp = 1.0d0 + ((-4.0d0) * ((y / x) / (x / y)))
    else if (t_1 <= 5d-169) then
        tmp = t_2
    else if (t_1 <= 2d-95) then
        tmp = (x / (x + t_0)) - (y / (0.25d0 * (x / (y / x))))
    else if (t_1 <= 2d+238) then
        tmp = t_2
    else
        tmp = (x / t_0) + (-1.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = y * ((y / x) * 4.0);
	double t_1 = y * (y * 4.0);
	double t_2 = ((x * x) - t_1) / (t_1 + (x * x));
	double tmp;
	if (t_1 <= 0.0) {
		tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
	} else if (t_1 <= 5e-169) {
		tmp = t_2;
	} else if (t_1 <= 2e-95) {
		tmp = (x / (x + t_0)) - (y / (0.25 * (x / (y / x))));
	} else if (t_1 <= 2e+238) {
		tmp = t_2;
	} else {
		tmp = (x / t_0) + -1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y * ((y / x) * 4.0)
	t_1 = y * (y * 4.0)
	t_2 = ((x * x) - t_1) / (t_1 + (x * x))
	tmp = 0
	if t_1 <= 0.0:
		tmp = 1.0 + (-4.0 * ((y / x) / (x / y)))
	elif t_1 <= 5e-169:
		tmp = t_2
	elif t_1 <= 2e-95:
		tmp = (x / (x + t_0)) - (y / (0.25 * (x / (y / x))))
	elif t_1 <= 2e+238:
		tmp = t_2
	else:
		tmp = (x / t_0) + -1.0
	return tmp
function code(x, y)
	t_0 = Float64(y * Float64(Float64(y / x) * 4.0))
	t_1 = Float64(y * Float64(y * 4.0))
	t_2 = Float64(Float64(Float64(x * x) - t_1) / Float64(t_1 + Float64(x * x)))
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y))));
	elseif (t_1 <= 5e-169)
		tmp = t_2;
	elseif (t_1 <= 2e-95)
		tmp = Float64(Float64(x / Float64(x + t_0)) - Float64(y / Float64(0.25 * Float64(x / Float64(y / x)))));
	elseif (t_1 <= 2e+238)
		tmp = t_2;
	else
		tmp = Float64(Float64(x / t_0) + -1.0);
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y * ((y / x) * 4.0);
	t_1 = y * (y * 4.0);
	t_2 = ((x * x) - t_1) / (t_1 + (x * x));
	tmp = 0.0;
	if (t_1 <= 0.0)
		tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
	elseif (t_1 <= 5e-169)
		tmp = t_2;
	elseif (t_1 <= 2e-95)
		tmp = (x / (x + t_0)) - (y / (0.25 * (x / (y / x))));
	elseif (t_1 <= 2e+238)
		tmp = t_2;
	else
		tmp = (x / t_0) + -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(N[(y / x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x * x), $MachinePrecision] - t$95$1), $MachinePrecision] / N[(t$95$1 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-169], t$95$2, If[LessEqual[t$95$1, 2e-95], N[(N[(x / N[(x + t$95$0), $MachinePrecision]), $MachinePrecision] - N[(y / N[(0.25 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+238], t$95$2, N[(N[(x / t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(\frac{y}{x} \cdot 4\right)\\
t_1 := y \cdot \left(y \cdot 4\right)\\
t_2 := \frac{x \cdot x - t_1}{t_1 + x \cdot x}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-169}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-95}:\\
\;\;\;\;\frac{x}{x + t_0} - \frac{y}{0.25 \cdot \frac{x}{\frac{y}{x}}}\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+238}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 (*.f64 y 4) y) < 0.0

    1. Initial program 51.7%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around inf 51.7%

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

        \[\leadsto \frac{\color{blue}{x \cdot x}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    4. Simplified51.7%

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

      \[\leadsto \color{blue}{1 + -4 \cdot \frac{{y}^{2}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. unpow283.3%

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

        \[\leadsto 1 + -4 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} \]
      3. times-frac90.6%

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

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

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

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

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

        \[\leadsto 1 + -4 \cdot \color{blue}{\frac{\frac{y}{x}}{\frac{x}{y}}} \]
    9. Applied egg-rr90.6%

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

    if 0.0 < (*.f64 (*.f64 y 4) y) < 5.0000000000000002e-169 or 1.99999999999999998e-95 < (*.f64 (*.f64 y 4) y) < 2.0000000000000001e238

    1. Initial program 80.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]

    if 5.0000000000000002e-169 < (*.f64 (*.f64 y 4) y) < 1.99999999999999998e-95

    1. Initial program 41.7%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. div-sub41.5%

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      4. *-commutative41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      5. *-commutative41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      6. fma-def41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}\right) \]
      7. *-commutative41.5%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}\right) \]
    3. Applied egg-rr41.5%

      \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\right)} \]
    4. Step-by-step derivation
      1. sub-neg41.5%

        \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
      2. associate-/l*43.4%

        \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}}} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
      3. associate-/l*43.4%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    5. Simplified43.4%

      \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    6. Taylor expanded in x around 0 99.9%

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

        \[\leadsto \frac{x}{\color{blue}{\frac{{y}^{2}}{x} \cdot 4} + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      2. unpow299.9%

        \[\leadsto \frac{x}{\frac{\color{blue}{y \cdot y}}{x} \cdot 4 + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      3. associate-*r/99.9%

        \[\leadsto \frac{x}{\color{blue}{\left(y \cdot \frac{y}{x}\right)} \cdot 4 + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      4. associate-*l*99.9%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + x} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      5. fma-def99.9%

        \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    8. Simplified99.9%

      \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}} \]
    9. Taylor expanded in x around inf 80.7%

      \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{\color{blue}{0.25 \cdot \frac{{x}^{2}}{y}}} \]
    10. Step-by-step derivation
      1. unpow280.7%

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{0.25 \cdot \frac{\color{blue}{x \cdot x}}{y}} \]
      2. associate-/l*80.7%

        \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{0.25 \cdot \color{blue}{\frac{x}{\frac{y}{x}}}} \]
    11. Simplified80.7%

      \[\leadsto \frac{x}{\mathsf{fma}\left(y, \frac{y}{x} \cdot 4, x\right)} - \frac{y}{\color{blue}{0.25 \cdot \frac{x}{\frac{y}{x}}}} \]
    12. Step-by-step derivation
      1. fma-udef99.9%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right) + x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    13. Applied egg-rr80.7%

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

    if 2.0000000000000001e238 < (*.f64 (*.f64 y 4) y)

    1. Initial program 6.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. div-sub6.0%

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      4. *-commutative6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      5. *-commutative6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      6. fma-def6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}\right) \]
      7. *-commutative6.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}\right) \]
    3. Applied egg-rr6.0%

      \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\right)} \]
    4. Step-by-step derivation
      1. sub-neg6.0%

        \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
      2. associate-/l*6.0%

        \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}}} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
      3. associate-/l*8.9%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    5. Simplified8.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    6. Taylor expanded in x around 0 76.9%

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

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{y}, y\right)}} \]
      2. unpow276.9%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{\color{blue}{x \cdot x}}{y}, y\right)} \]
      3. associate-/l*89.1%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\mathsf{fma}\left(0.25, \color{blue}{\frac{x}{\frac{y}{x}}}, y\right)} \]
    8. Simplified89.1%

      \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)}} \]
    9. Taylor expanded in x around 0 89.1%

      \[\leadsto \frac{x}{\color{blue}{4 \cdot \frac{{y}^{2}}{x}}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    10. Step-by-step derivation
      1. *-commutative89.1%

        \[\leadsto \frac{x}{\color{blue}{\frac{{y}^{2}}{x} \cdot 4}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      2. unpow289.1%

        \[\leadsto \frac{x}{\frac{\color{blue}{y \cdot y}}{x} \cdot 4} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      3. associate-*r/90.1%

        \[\leadsto \frac{x}{\color{blue}{\left(y \cdot \frac{y}{x}\right)} \cdot 4} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      4. associate-*l*90.1%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    11. Simplified90.1%

      \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    12. Taylor expanded in y around inf 89.7%

      \[\leadsto \frac{x}{y \cdot \left(\frac{y}{x} \cdot 4\right)} - \color{blue}{1} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(y \cdot 4\right) \leq 0:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 5 \cdot 10^{-169}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 2 \cdot 10^{-95}:\\ \;\;\;\;\frac{x}{x + y \cdot \left(\frac{y}{x} \cdot 4\right)} - \frac{y}{0.25 \cdot \frac{x}{\frac{y}{x}}}\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 2 \cdot 10^{+238}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + -1\\ \end{array} \]

Alternative 6: 74.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{-45} \lor \neg \left(y \leq 6.5 \cdot 10^{+92}\right):\\ \;\;\;\;\frac{x}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + -1\\ \mathbf{else}:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -4.6e-45) (not (<= y 6.5e+92)))
   (+ (/ x (* y (* (/ y x) 4.0))) -1.0)
   (+ 1.0 (* -4.0 (/ (/ y x) (/ x y))))))
double code(double x, double y) {
	double tmp;
	if ((y <= -4.6e-45) || !(y <= 6.5e+92)) {
		tmp = (x / (y * ((y / x) * 4.0))) + -1.0;
	} else {
		tmp = 1.0 + (-4.0 * ((y / x) / (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 <= (-4.6d-45)) .or. (.not. (y <= 6.5d+92))) then
        tmp = (x / (y * ((y / x) * 4.0d0))) + (-1.0d0)
    else
        tmp = 1.0d0 + ((-4.0d0) * ((y / x) / (x / y)))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -4.6e-45) || !(y <= 6.5e+92)) {
		tmp = (x / (y * ((y / x) * 4.0))) + -1.0;
	} else {
		tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -4.6e-45) or not (y <= 6.5e+92):
		tmp = (x / (y * ((y / x) * 4.0))) + -1.0
	else:
		tmp = 1.0 + (-4.0 * ((y / x) / (x / y)))
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -4.6e-45) || !(y <= 6.5e+92))
		tmp = Float64(Float64(x / Float64(y * Float64(Float64(y / x) * 4.0))) + -1.0);
	else
		tmp = Float64(1.0 + Float64(-4.0 * Float64(Float64(y / x) / Float64(x / y))));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -4.6e-45) || ~((y <= 6.5e+92)))
		tmp = (x / (y * ((y / x) * 4.0))) + -1.0;
	else
		tmp = 1.0 + (-4.0 * ((y / x) / (x / y)));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -4.6e-45], N[Not[LessEqual[y, 6.5e+92]], $MachinePrecision]], N[(N[(x / N[(y * N[(N[(y / x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 + N[(-4.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{-45} \lor \neg \left(y \leq 6.5 \cdot 10^{+92}\right):\\
\;\;\;\;\frac{x}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.59999999999999983e-45 or 6.49999999999999999e92 < y

    1. Initial program 30.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. div-sub30.0%

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

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

        \[\leadsto \frac{x \cdot x}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      4. *-commutative30.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)} + \left(-\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      5. *-commutative30.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{\color{blue}{y \cdot \left(y \cdot 4\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \]
      6. fma-def30.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 4\right) \cdot y\right)}}\right) \]
      7. *-commutative30.0%

        \[\leadsto \frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y \cdot 4\right)}\right)}\right) \]
    3. Applied egg-rr30.0%

      \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} + \left(-\frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\right)} \]
    4. Step-by-step derivation
      1. sub-neg30.0%

        \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
      2. associate-/l*30.1%

        \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}}} - \frac{y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \]
      3. associate-/l*32.2%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    5. Simplified32.2%

      \[\leadsto \color{blue}{\frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{y \cdot 4}}} \]
    6. Taylor expanded in x around 0 79.8%

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

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{{x}^{2}}{y}, y\right)}} \]
      2. unpow279.8%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{\color{blue}{x \cdot x}}{y}, y\right)} \]
      3. associate-/l*88.3%

        \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\mathsf{fma}\left(0.25, \color{blue}{\frac{x}{\frac{y}{x}}}, y\right)} \]
    8. Simplified88.3%

      \[\leadsto \frac{x}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x}} - \frac{y}{\color{blue}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)}} \]
    9. Taylor expanded in x around 0 81.3%

      \[\leadsto \frac{x}{\color{blue}{4 \cdot \frac{{y}^{2}}{x}}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    10. Step-by-step derivation
      1. *-commutative81.3%

        \[\leadsto \frac{x}{\color{blue}{\frac{{y}^{2}}{x} \cdot 4}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      2. unpow281.3%

        \[\leadsto \frac{x}{\frac{\color{blue}{y \cdot y}}{x} \cdot 4} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      3. associate-*r/82.0%

        \[\leadsto \frac{x}{\color{blue}{\left(y \cdot \frac{y}{x}\right)} \cdot 4} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
      4. associate-*l*82.0%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    11. Simplified82.0%

      \[\leadsto \frac{x}{\color{blue}{y \cdot \left(\frac{y}{x} \cdot 4\right)}} - \frac{y}{\mathsf{fma}\left(0.25, \frac{x}{\frac{y}{x}}, y\right)} \]
    12. Taylor expanded in y around inf 81.7%

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

    if -4.59999999999999983e-45 < y < 6.49999999999999999e92

    1. Initial program 62.5%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around inf 42.0%

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

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

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

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

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

        \[\leadsto 1 + -4 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} \]
      3. times-frac75.7%

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

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

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

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

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

        \[\leadsto 1 + -4 \cdot \color{blue}{\frac{\frac{y}{x}}{\frac{x}{y}}} \]
    9. Applied egg-rr75.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{-45} \lor \neg \left(y \leq 6.5 \cdot 10^{+92}\right):\\ \;\;\;\;\frac{x}{y \cdot \left(\frac{y}{x} \cdot 4\right)} + -1\\ \mathbf{else}:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \end{array} \]

Alternative 7: 73.0% accurate, 1.3× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.28000000000000001e-48 or 5.5000000000000003e118 < y

    1. Initial program 28.1%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around 0 82.4%

      \[\leadsto \color{blue}{-1} \]

    if -1.28000000000000001e-48 < y < 5.5000000000000003e118

    1. Initial program 62.7%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around inf 41.0%

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

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

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

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

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

        \[\leadsto 1 + -4 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} \]
      3. times-frac74.7%

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

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

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

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

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

        \[\leadsto 1 + -4 \cdot \color{blue}{\frac{\frac{y}{x}}{\frac{x}{y}}} \]
    9. Applied egg-rr74.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.28 \cdot 10^{-48}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+118}:\\ \;\;\;\;1 + -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 8: 73.2% accurate, 3.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.28 \cdot 10^{-48}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+92}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.28e-48) -1.0 (if (<= y 8.5e+92) 1.0 -1.0)))
double code(double x, double y) {
	double tmp;
	if (y <= -1.28e-48) {
		tmp = -1.0;
	} else if (y <= 8.5e+92) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-1.28d-48)) then
        tmp = -1.0d0
    else if (y <= 8.5d+92) then
        tmp = 1.0d0
    else
        tmp = -1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -1.28e-48) {
		tmp = -1.0;
	} else if (y <= 8.5e+92) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.28e-48:
		tmp = -1.0
	elif y <= 8.5e+92:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.28e-48)
		tmp = -1.0;
	elseif (y <= 8.5e+92)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1.28e-48)
		tmp = -1.0;
	elseif (y <= 8.5e+92)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.28e-48], -1.0, If[LessEqual[y, 8.5e+92], 1.0, -1.0]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 8.5 \cdot 10^{+92}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.28000000000000001e-48 or 8.5000000000000001e92 < y

    1. Initial program 30.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around 0 80.8%

      \[\leadsto \color{blue}{-1} \]

    if -1.28000000000000001e-48 < y < 8.5000000000000001e92

    1. Initial program 62.5%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Taylor expanded in x around inf 74.9%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.28 \cdot 10^{-48}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+92}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 9: 49.9% accurate, 19.0× speedup?

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

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

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Taylor expanded in x around 0 51.1%

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

    \[\leadsto -1 \]

Developer target: 51.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y \cdot y\right) \cdot 4\\ t_1 := x \cdot x + t_0\\ t_2 := \frac{t_0}{t_1}\\ t_3 := \left(y \cdot 4\right) \cdot y\\ \mathbf{if}\;\frac{x \cdot x - t_3}{x \cdot x + t_3} < 0.9743233849626781:\\ \;\;\;\;\frac{x \cdot x}{t_1} - t_2\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{x}{\sqrt{t_1}}\right)}^{2} - t_2\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (* y y) 4.0))
        (t_1 (+ (* x x) t_0))
        (t_2 (/ t_0 t_1))
        (t_3 (* (* y 4.0) y)))
   (if (< (/ (- (* x x) t_3) (+ (* x x) t_3)) 0.9743233849626781)
     (- (/ (* x x) t_1) t_2)
     (- (pow (/ x (sqrt t_1)) 2.0) t_2))))
double code(double x, double y) {
	double t_0 = (y * y) * 4.0;
	double t_1 = (x * x) + t_0;
	double t_2 = t_0 / t_1;
	double t_3 = (y * 4.0) * y;
	double tmp;
	if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781) {
		tmp = ((x * x) / t_1) - t_2;
	} else {
		tmp = pow((x / sqrt(t_1)), 2.0) - t_2;
	}
	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) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = (y * y) * 4.0d0
    t_1 = (x * x) + t_0
    t_2 = t_0 / t_1
    t_3 = (y * 4.0d0) * y
    if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781d0) then
        tmp = ((x * x) / t_1) - t_2
    else
        tmp = ((x / sqrt(t_1)) ** 2.0d0) - t_2
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (y * y) * 4.0;
	double t_1 = (x * x) + t_0;
	double t_2 = t_0 / t_1;
	double t_3 = (y * 4.0) * y;
	double tmp;
	if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781) {
		tmp = ((x * x) / t_1) - t_2;
	} else {
		tmp = Math.pow((x / Math.sqrt(t_1)), 2.0) - t_2;
	}
	return tmp;
}
def code(x, y):
	t_0 = (y * y) * 4.0
	t_1 = (x * x) + t_0
	t_2 = t_0 / t_1
	t_3 = (y * 4.0) * y
	tmp = 0
	if (((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781:
		tmp = ((x * x) / t_1) - t_2
	else:
		tmp = math.pow((x / math.sqrt(t_1)), 2.0) - t_2
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y * y) * 4.0)
	t_1 = Float64(Float64(x * x) + t_0)
	t_2 = Float64(t_0 / t_1)
	t_3 = Float64(Float64(y * 4.0) * y)
	tmp = 0.0
	if (Float64(Float64(Float64(x * x) - t_3) / Float64(Float64(x * x) + t_3)) < 0.9743233849626781)
		tmp = Float64(Float64(Float64(x * x) / t_1) - t_2);
	else
		tmp = Float64((Float64(x / sqrt(t_1)) ^ 2.0) - t_2);
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (y * y) * 4.0;
	t_1 = (x * x) + t_0;
	t_2 = t_0 / t_1;
	t_3 = (y * 4.0) * y;
	tmp = 0.0;
	if ((((x * x) - t_3) / ((x * x) + t_3)) < 0.9743233849626781)
		tmp = ((x * x) / t_1) - t_2;
	else
		tmp = ((x / sqrt(t_1)) ^ 2.0) - t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * y), $MachinePrecision] * 4.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[Less[N[(N[(N[(x * x), $MachinePrecision] - t$95$3), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision], 0.9743233849626781], N[(N[(N[(x * x), $MachinePrecision] / t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision], N[(N[Power[N[(x / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y \cdot y\right) \cdot 4\\
t_1 := x \cdot x + t_0\\
t_2 := \frac{t_0}{t_1}\\
t_3 := \left(y \cdot 4\right) \cdot y\\
\mathbf{if}\;\frac{x \cdot x - t_3}{x \cdot x + t_3} < 0.9743233849626781:\\
\;\;\;\;\frac{x \cdot x}{t_1} - t_2\\

\mathbf{else}:\\
\;\;\;\;{\left(\frac{x}{\sqrt{t_1}}\right)}^{2} - t_2\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023196 
(FPCore (x y)
  :name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))

  (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))