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

Percentage Accurate: 50.8% → 99.9%
Time: 7.5s
Alternatives: 8
Speedup: 19.0×

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 8 alternatives:

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

Initial Program: 50.8% 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: 99.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\ \frac{\mathsf{fma}\left(y, 2, x\right)}{t_0} \cdot \frac{x - y \cdot 2}{t_0} \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (hypot x (* y 2.0))))
   (* (/ (fma y 2.0 x) t_0) (/ (- x (* y 2.0)) t_0))))
double code(double x, double y) {
	double t_0 = hypot(x, (y * 2.0));
	return (fma(y, 2.0, x) / t_0) * ((x - (y * 2.0)) / t_0);
}
function code(x, y)
	t_0 = hypot(x, Float64(y * 2.0))
	return Float64(Float64(fma(y, 2.0, x) / t_0) * Float64(Float64(x - Float64(y * 2.0)) / t_0))
end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(y * 2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\mathsf{fma}\left(y, 2, x\right)}{t_0} \cdot \frac{x - y \cdot 2}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 48.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x - \left(y \cdot 4\right) \cdot y}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    5. add-sqr-sqrt48.8%

      \[\leadsto \frac{x \cdot x - \color{blue}{\sqrt{\left(y \cdot 4\right) \cdot y} \cdot \sqrt{\left(y \cdot 4\right) \cdot y}}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    6. difference-of-squares48.8%

      \[\leadsto \frac{\color{blue}{\left(x + \sqrt{\left(y \cdot 4\right) \cdot y}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    7. *-commutative48.8%

      \[\leadsto \frac{\left(x + \sqrt{\color{blue}{y \cdot \left(y \cdot 4\right)}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    8. associate-*r*48.8%

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

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

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

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

      \[\leadsto \frac{\left(x + y \cdot \color{blue}{2}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    13. *-commutative31.9%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{y \cdot \left(y \cdot 4\right)}}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    14. associate-*r*31.9%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{\left(y \cdot y\right) \cdot 4}}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    15. sqrt-prod31.9%

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

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

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \color{blue}{y} \cdot \sqrt{4}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    18. metadata-eval48.8%

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

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

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

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - y \cdot 2\right)}{\color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    3. add-sqr-sqrt48.8%

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

      \[\leadsto \color{blue}{\frac{x + y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \cdot \frac{x - y \cdot 2}{\sqrt{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}}} \]
  7. Applied egg-rr99.6%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{x - y \cdot 2}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
  8. Final simplification99.6%

    \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{x - y \cdot 2}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]

Alternative 2: 76.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ t_1 := x \cdot x + t_0\\ t_2 := \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\ \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-298}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+31}:\\ \;\;\;\;\frac{x \cdot x}{t_1} - \frac{t_0}{t_1}\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot x \leq 10^{+204}:\\ \;\;\;\;\frac{x \cdot x - t_0}{t_1}\\ \mathbf{elif}\;x \cdot x \leq 10^{+263}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{else}:\\ \;\;\;\;1 + -8 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* y 4.0)))
        (t_1 (+ (* x x) t_0))
        (t_2 (+ (/ (/ (/ x y) (/ y x)) 4.0) -1.0)))
   (if (<= (* x x) 2e-298)
     t_2
     (if (<= (* x x) 2e+31)
       (- (/ (* x x) t_1) (/ t_0 t_1))
       (if (<= (* x x) 4e+151)
         t_2
         (if (<= (* x x) 1e+204)
           (/ (- (* x x) t_0) t_1)
           (if (<= (* x x) 1e+263)
             (fma 0.5 (* (/ x y) (/ x y)) -1.0)
             (+ 1.0 (* -8.0 (/ (/ y x) (/ x y)))))))))))
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double t_1 = (x * x) + t_0;
	double t_2 = (((x / y) / (y / x)) / 4.0) + -1.0;
	double tmp;
	if ((x * x) <= 2e-298) {
		tmp = t_2;
	} else if ((x * x) <= 2e+31) {
		tmp = ((x * x) / t_1) - (t_0 / t_1);
	} else if ((x * x) <= 4e+151) {
		tmp = t_2;
	} else if ((x * x) <= 1e+204) {
		tmp = ((x * x) - t_0) / t_1;
	} else if ((x * x) <= 1e+263) {
		tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
	} else {
		tmp = 1.0 + (-8.0 * ((y / x) / (x / y)));
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	t_1 = Float64(Float64(x * x) + t_0)
	t_2 = Float64(Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0) + -1.0)
	tmp = 0.0
	if (Float64(x * x) <= 2e-298)
		tmp = t_2;
	elseif (Float64(x * x) <= 2e+31)
		tmp = Float64(Float64(Float64(x * x) / t_1) - Float64(t_0 / t_1));
	elseif (Float64(x * x) <= 4e+151)
		tmp = t_2;
	elseif (Float64(x * x) <= 1e+204)
		tmp = Float64(Float64(Float64(x * x) - t_0) / t_1);
	elseif (Float64(x * x) <= 1e+263)
		tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0);
	else
		tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x) / Float64(x / y))));
	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[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 2e-298], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 2e+31], N[(N[(N[(x * x), $MachinePrecision] / t$95$1), $MachinePrecision] - N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 4e+151], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 1e+204], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+263], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 + N[(-8.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+151}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \cdot x \leq 10^{+204}:\\
\;\;\;\;\frac{x \cdot x - t_0}{t_1}\\

\mathbf{elif}\;x \cdot x \leq 10^{+263}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (*.f64 x x) < 1.99999999999999982e-298 or 1.9999999999999999e31 < (*.f64 x x) < 4.00000000000000007e151

    1. Initial program 48.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}}{4} - \frac{\left(y \cdot 4\right) \cdot y}{y \cdot \left(y \cdot 4\right)} \]
      6. *-commutative38.8%

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

        \[\leadsto \frac{{\left(\frac{x}{y}\right)}^{2}}{4} - \color{blue}{1} \]
    6. Applied egg-rr85.1%

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}}{4} - 1 \]
      2. clear-num85.1%

        \[\leadsto \frac{\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}}{4} - 1 \]
      3. un-div-inv85.1%

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    8. Applied egg-rr85.1%

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

    if 1.99999999999999982e-298 < (*.f64 x x) < 1.9999999999999999e31

    1. Initial program 88.2%

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

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

        \[\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. associate-/l*88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \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)}{\color{blue}{y \cdot \left(y \cdot 4\right) + x \cdot x}} \]
      10. +-commutative88.2%

        \[\leadsto \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)}{\color{blue}{x \cdot x + y \cdot \left(y \cdot 4\right)}} \]
      11. fma-def88.2%

        \[\leadsto \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)}{\color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    5. Simplified88.2%

      \[\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)}} \]
    6. Step-by-step derivation
      1. fma-udef88.2%

        \[\leadsto \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)}{\color{blue}{x \cdot x + y \cdot \left(y \cdot 4\right)}} \]
      2. *-commutative88.2%

        \[\leadsto \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)}{x \cdot x + \color{blue}{\left(y \cdot 4\right) \cdot y}} \]
      3. +-commutative88.2%

        \[\leadsto \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)}{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}} \]
      4. *-commutative88.2%

        \[\leadsto \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)}{\color{blue}{y \cdot \left(y \cdot 4\right)} + x \cdot x} \]
    7. Applied egg-rr88.2%

      \[\leadsto \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)}{\color{blue}{y \cdot \left(y \cdot 4\right) + x \cdot x}} \]
    8. Step-by-step derivation
      1. fma-udef88.2%

        \[\leadsto \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)}{\color{blue}{x \cdot x + y \cdot \left(y \cdot 4\right)}} \]
      2. *-commutative88.2%

        \[\leadsto \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)}{x \cdot x + \color{blue}{\left(y \cdot 4\right) \cdot y}} \]
      3. +-commutative88.2%

        \[\leadsto \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)}{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}} \]
      4. *-commutative88.2%

        \[\leadsto \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)}{\color{blue}{y \cdot \left(y \cdot 4\right)} + x \cdot x} \]
    9. Applied egg-rr88.2%

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

    if 4.00000000000000007e151 < (*.f64 x x) < 9.99999999999999989e203

    1. Initial program 91.7%

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

    if 9.99999999999999989e203 < (*.f64 x x) < 1.00000000000000002e263

    1. Initial program 41.4%

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

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

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

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

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

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

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

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

    if 1.00000000000000002e263 < (*.f64 x x)

    1. Initial program 11.1%

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

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

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

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

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

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

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

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

        \[\leadsto 1 + -8 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} \]
      3. times-frac83.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-298}:\\ \;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+31}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + y \cdot \left(y \cdot 4\right)} - \frac{y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+151}:\\ \;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\ \mathbf{elif}\;x \cdot x \leq 10^{+204}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;x \cdot x \leq 10^{+263}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{else}:\\ \;\;\;\;1 + -8 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \end{array} \]

Alternative 3: 77.7% accurate, 0.5× speedup?

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

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

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

\mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+151}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 1.99999999999999982e-298 or 1.9999999999999999e31 < (*.f64 x x) < 4.00000000000000007e151

    1. Initial program 48.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}}{4} - \frac{\left(y \cdot 4\right) \cdot y}{y \cdot \left(y \cdot 4\right)} \]
      6. *-commutative38.8%

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

        \[\leadsto \frac{{\left(\frac{x}{y}\right)}^{2}}{4} - \color{blue}{1} \]
    6. Applied egg-rr85.1%

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}}{4} - 1 \]
      2. clear-num85.1%

        \[\leadsto \frac{\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}}{4} - 1 \]
      3. un-div-inv85.1%

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    8. Applied egg-rr85.1%

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

    if 1.99999999999999982e-298 < (*.f64 x x) < 1.9999999999999999e31

    1. Initial program 88.2%

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

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

        \[\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. associate-/l*88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \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)}{\color{blue}{y \cdot \left(y \cdot 4\right) + x \cdot x}} \]
      10. +-commutative88.2%

        \[\leadsto \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)}{\color{blue}{x \cdot x + y \cdot \left(y \cdot 4\right)}} \]
      11. fma-def88.2%

        \[\leadsto \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)}{\color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}} \]
    5. Simplified88.2%

      \[\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)}} \]
    6. Step-by-step derivation
      1. fma-udef88.2%

        \[\leadsto \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)}{\color{blue}{x \cdot x + y \cdot \left(y \cdot 4\right)}} \]
      2. *-commutative88.2%

        \[\leadsto \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)}{x \cdot x + \color{blue}{\left(y \cdot 4\right) \cdot y}} \]
      3. +-commutative88.2%

        \[\leadsto \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)}{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}} \]
      4. *-commutative88.2%

        \[\leadsto \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)}{\color{blue}{y \cdot \left(y \cdot 4\right)} + x \cdot x} \]
    7. Applied egg-rr88.2%

      \[\leadsto \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)}{\color{blue}{y \cdot \left(y \cdot 4\right) + x \cdot x}} \]
    8. Step-by-step derivation
      1. fma-udef88.2%

        \[\leadsto \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)}{\color{blue}{x \cdot x + y \cdot \left(y \cdot 4\right)}} \]
      2. *-commutative88.2%

        \[\leadsto \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)}{x \cdot x + \color{blue}{\left(y \cdot 4\right) \cdot y}} \]
      3. +-commutative88.2%

        \[\leadsto \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)}{\color{blue}{\left(y \cdot 4\right) \cdot y + x \cdot x}} \]
      4. *-commutative88.2%

        \[\leadsto \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)}{\color{blue}{y \cdot \left(y \cdot 4\right)} + x \cdot x} \]
    9. Applied egg-rr88.2%

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

    if 4.00000000000000007e151 < (*.f64 x x)

    1. Initial program 23.8%

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

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

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

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

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

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

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

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

        \[\leadsto 1 + -8 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} \]
      3. times-frac76.8%

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

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

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

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

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

        \[\leadsto 1 + -8 \cdot \color{blue}{\frac{\frac{y}{x}}{\frac{x}{y}}} \]
    8. Applied egg-rr76.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-298}:\\ \;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+31}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + y \cdot \left(y \cdot 4\right)} - \frac{y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+151}:\\ \;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\ \mathbf{else}:\\ \;\;\;\;1 + -8 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \end{array} \]

Alternative 4: 77.7% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+31}:\\
\;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\

\mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+151}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 1.99999999999999982e-298 or 1.9999999999999999e31 < (*.f64 x x) < 4.00000000000000007e151

    1. Initial program 48.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}}{4} - \frac{\left(y \cdot 4\right) \cdot y}{y \cdot \left(y \cdot 4\right)} \]
      6. *-commutative38.8%

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

        \[\leadsto \frac{{\left(\frac{x}{y}\right)}^{2}}{4} - \color{blue}{1} \]
    6. Applied egg-rr85.1%

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}}{4} - 1 \]
      2. clear-num85.1%

        \[\leadsto \frac{\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}}{4} - 1 \]
      3. un-div-inv85.1%

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    8. Applied egg-rr85.1%

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

    if 1.99999999999999982e-298 < (*.f64 x x) < 1.9999999999999999e31

    1. Initial program 88.2%

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

    if 4.00000000000000007e151 < (*.f64 x x)

    1. Initial program 23.8%

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

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

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

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

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

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

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

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

        \[\leadsto 1 + -8 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} \]
      3. times-frac76.8%

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

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

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

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

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

        \[\leadsto 1 + -8 \cdot \color{blue}{\frac{\frac{y}{x}}{\frac{x}{y}}} \]
    8. Applied egg-rr76.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-298}:\\ \;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+31}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+151}:\\ \;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\ \mathbf{else}:\\ \;\;\;\;1 + -8 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \end{array} \]

Alternative 5: 75.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot \left(y \cdot 4\right) \leq 10^{+61}:\\ \;\;\;\;1 + -8 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (* y (* y 4.0)) 1e+61)
   (+ 1.0 (* -8.0 (/ (/ y x) (/ x y))))
   (+ (/ (/ (/ x y) (/ y x)) 4.0) -1.0)))
double code(double x, double y) {
	double tmp;
	if ((y * (y * 4.0)) <= 1e+61) {
		tmp = 1.0 + (-8.0 * ((y / x) / (x / y)));
	} 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) :: tmp
    if ((y * (y * 4.0d0)) <= 1d+61) then
        tmp = 1.0d0 + ((-8.0d0) * ((y / x) / (x / y)))
    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 tmp;
	if ((y * (y * 4.0)) <= 1e+61) {
		tmp = 1.0 + (-8.0 * ((y / x) / (x / y)));
	} else {
		tmp = (((x / y) / (y / x)) / 4.0) + -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y * (y * 4.0)) <= 1e+61:
		tmp = 1.0 + (-8.0 * ((y / x) / (x / y)))
	else:
		tmp = (((x / y) / (y / x)) / 4.0) + -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(y * Float64(y * 4.0)) <= 1e+61)
		tmp = Float64(1.0 + Float64(-8.0 * Float64(Float64(y / x) / Float64(x / y))));
	else
		tmp = Float64(Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0) + -1.0);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y * (y * 4.0)) <= 1e+61)
		tmp = 1.0 + (-8.0 * ((y / x) / (x / y)));
	else
		tmp = (((x / y) / (y / x)) / 4.0) + -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision], 1e+61], N[(1.0 + N[(-8.0 * N[(N[(y / x), $MachinePrecision] / N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \cdot \left(y \cdot 4\right) \leq 10^{+61}:\\
\;\;\;\;1 + -8 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\

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


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

    1. Initial program 61.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999949e60 < (*.f64 (*.f64 y 4) y)

    1. Initial program 36.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 33.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{\left(\frac{x}{y}\right)}^{2}}}{4} - \frac{\left(y \cdot 4\right) \cdot y}{y \cdot \left(y \cdot 4\right)} \]
      6. *-commutative33.4%

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

        \[\leadsto \frac{{\left(\frac{x}{y}\right)}^{2}}{4} - \color{blue}{1} \]
    6. Applied egg-rr79.4%

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

        \[\leadsto \frac{\color{blue}{\frac{x}{y} \cdot \frac{x}{y}}}{4} - 1 \]
      2. clear-num79.4%

        \[\leadsto \frac{\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}}{4} - 1 \]
      3. un-div-inv79.4%

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    8. Applied egg-rr79.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(y \cdot 4\right) \leq 10^{+61}:\\ \;\;\;\;1 + -8 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\ \end{array} \]

Alternative 6: 63.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 6 \cdot 10^{+33}:\\ \;\;\;\;1 + -8 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y 6e+33) (+ 1.0 (* -8.0 (/ (/ y x) (/ x y)))) -1.0))
double code(double x, double y) {
	double tmp;
	if (y <= 6e+33) {
		tmp = 1.0 + (-8.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 <= 6d+33) then
        tmp = 1.0d0 + ((-8.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 <= 6e+33) {
		tmp = 1.0 + (-8.0 * ((y / x) / (x / y)));
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 6e+33:
		tmp = 1.0 + (-8.0 * ((y / x) / (x / y)))
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 6e+33)
		tmp = Float64(1.0 + Float64(-8.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 <= 6e+33)
		tmp = 1.0 + (-8.0 * ((y / x) / (x / y)));
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 6e+33], N[(1.0 + N[(-8.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 6 \cdot 10^{+33}:\\
\;\;\;\;1 + -8 \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 < 5.99999999999999967e33

    1. Initial program 54.9%

      \[\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. sub-neg54.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.99999999999999967e33 < y

    1. Initial program 29.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 0 79.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 6 \cdot 10^{+33}:\\ \;\;\;\;1 + -8 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 7: 62.3% accurate, 6.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.3 \cdot 10^{-10}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y) :precision binary64 (if (<= y 1.3e-10) 1.0 -1.0))
double code(double x, double y) {
	double tmp;
	if (y <= 1.3e-10) {
		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.3d-10) 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.3e-10) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 1.3e-10:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 1.3e-10)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 1.3e-10)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 1.3e-10], 1.0, -1.0]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.29999999999999991e-10

    1. Initial program 54.2%

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

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

    if 1.29999999999999991e-10 < y

    1. Initial program 33.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 79.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.3 \cdot 10^{-10}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 8: 50.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 48.8%

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

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

    \[\leadsto -1 \]

Developer target: 51.3% 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 2023271 
(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))))