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

Percentage Accurate: 51.1% → 99.9%
Time: 9.9s
Alternatives: 12
Speedup: 1.2×

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 12 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: 99.9% accurate, 0.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(x\_m, y\_m \cdot 2\right)\\ \frac{\mathsf{fma}\left(y\_m, -2, x\_m\right)}{t\_0 \cdot \frac{t\_0}{\mathsf{fma}\left(y\_m, 2, x\_m\right)}} \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (let* ((t_0 (hypot x_m (* y_m 2.0))))
   (/ (fma y_m -2.0 x_m) (* t_0 (/ t_0 (fma y_m 2.0 x_m))))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = hypot(x_m, (y_m * 2.0));
	return fma(y_m, -2.0, x_m) / (t_0 * (t_0 / fma(y_m, 2.0, x_m)));
}
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = hypot(x_m, Float64(y_m * 2.0))
	return Float64(fma(y_m, -2.0, x_m) / Float64(t_0 * Float64(t_0 / fma(y_m, 2.0, x_m))))
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[Sqrt[x$95$m ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(y$95$m * -2.0 + x$95$m), $MachinePrecision] / N[(t$95$0 * N[(t$95$0 / N[(y$95$m * 2.0 + x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

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

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrt52.3%

      \[\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} \]
    2. difference-of-squares52.3%

      \[\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} \]
    3. *-commutative52.3%

      \[\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} \]
    4. associate-*r*52.3%

      \[\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} \]
    5. sqrt-prod52.3%

      \[\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} \]
    6. sqrt-unprod26.5%

      \[\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} \]
    7. add-sqr-sqrt39.7%

      \[\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} \]
    8. metadata-eval39.7%

      \[\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} \]
    9. *-commutative39.7%

      \[\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} \]
    10. associate-*r*39.4%

      \[\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} \]
    11. sqrt-prod39.4%

      \[\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} \]
    12. sqrt-unprod26.5%

      \[\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} \]
    13. add-sqr-sqrt52.3%

      \[\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} \]
    14. metadata-eval52.3%

      \[\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} \]
  4. Applied egg-rr52.3%

    \[\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} \]
  5. Step-by-step derivation
    1. add-sqr-sqrt52.3%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
    10. metadata-eval26.7%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
    11. associate-*l*26.7%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right) \cdot 2}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
    12. add-sqr-sqrt53.4%

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(y, -2, x\right)}}{\mathsf{hypot}\left(x, y \cdot 2\right) \cdot \frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}} \]
    5. *-un-lft-identity99.6%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y, -2, x\right)}}{\mathsf{hypot}\left(x, y \cdot 2\right) \cdot \frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}} \]
  8. 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{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}}} \]
  9. Add Preprocessing

Alternative 2: 99.9% accurate, 0.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(x\_m, y\_m \cdot 2\right)\\ \frac{\mathsf{fma}\left(y\_m, 2, x\_m\right)}{t\_0} \cdot \frac{\mathsf{fma}\left(y\_m, -2, x\_m\right)}{t\_0} \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (let* ((t_0 (hypot x_m (* y_m 2.0))))
   (* (/ (fma y_m 2.0 x_m) t_0) (/ (fma y_m -2.0 x_m) t_0))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = hypot(x_m, (y_m * 2.0));
	return (fma(y_m, 2.0, x_m) / t_0) * (fma(y_m, -2.0, x_m) / t_0);
}
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = hypot(x_m, Float64(y_m * 2.0))
	return Float64(Float64(fma(y_m, 2.0, x_m) / t_0) * Float64(fma(y_m, -2.0, x_m) / t_0))
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[Sqrt[x$95$m ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(y$95$m * 2.0 + x$95$m), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(y$95$m * -2.0 + x$95$m), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

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

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrt52.3%

      \[\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} \]
    2. difference-of-squares52.3%

      \[\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} \]
    3. *-commutative52.3%

      \[\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} \]
    4. associate-*r*52.3%

      \[\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} \]
    5. sqrt-prod52.3%

      \[\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} \]
    6. sqrt-unprod26.5%

      \[\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} \]
    7. add-sqr-sqrt39.7%

      \[\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} \]
    8. metadata-eval39.7%

      \[\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} \]
    9. *-commutative39.7%

      \[\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} \]
    10. associate-*r*39.4%

      \[\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} \]
    11. sqrt-prod39.4%

      \[\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} \]
    12. sqrt-unprod26.5%

      \[\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} \]
    13. add-sqr-sqrt52.3%

      \[\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} \]
    14. metadata-eval52.3%

      \[\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} \]
  4. Applied egg-rr52.3%

    \[\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} \]
  5. Step-by-step derivation
    1. add-sqr-sqrt52.3%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
    10. metadata-eval26.7%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
    11. associate-*l*26.7%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right) \cdot 2}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
    12. add-sqr-sqrt53.4%

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
  7. Add Preprocessing

Alternative 3: 81.4% accurate, 0.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\ t_1 := {\left(0.5 \cdot \frac{x\_m}{y\_m}\right)}^{2}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;\frac{\mathsf{fma}\left(y\_m, 2, x\_m\right)}{\mathsf{hypot}\left(x\_m, y\_m \cdot 2\right)} \cdot \left(1 + \frac{y\_m \cdot -2}{x\_m}\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\ \;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{t\_0 + x\_m \cdot x\_m}\\ \mathbf{else}:\\ \;\;\;\;t\_1 + \left(\left(\frac{0}{y\_m} + t\_1\right) + -1\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (pow (* 0.5 (/ x_m y_m)) 2.0)))
   (if (<= t_0 0.0)
     (*
      (/ (fma y_m 2.0 x_m) (hypot x_m (* y_m 2.0)))
      (+ 1.0 (/ (* y_m -2.0) x_m)))
     (if (<= t_0 5e+182)
       (/ (* (+ x_m (* y_m 2.0)) (- x_m (* y_m 2.0))) (+ t_0 (* x_m x_m)))
       (+ t_1 (+ (+ (/ 0.0 y_m) t_1) -1.0))))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = y_m * (y_m * 4.0);
	double t_1 = pow((0.5 * (x_m / y_m)), 2.0);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = (fma(y_m, 2.0, x_m) / hypot(x_m, (y_m * 2.0))) * (1.0 + ((y_m * -2.0) / x_m));
	} else if (t_0 <= 5e+182) {
		tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / (t_0 + (x_m * x_m));
	} else {
		tmp = t_1 + (((0.0 / y_m) + t_1) + -1.0);
	}
	return tmp;
}
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = Float64(y_m * Float64(y_m * 4.0))
	t_1 = Float64(0.5 * Float64(x_m / y_m)) ^ 2.0
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = Float64(Float64(fma(y_m, 2.0, x_m) / hypot(x_m, Float64(y_m * 2.0))) * Float64(1.0 + Float64(Float64(y_m * -2.0) / x_m)));
	elseif (t_0 <= 5e+182)
		tmp = Float64(Float64(Float64(x_m + Float64(y_m * 2.0)) * Float64(x_m - Float64(y_m * 2.0))) / Float64(t_0 + Float64(x_m * x_m)));
	else
		tmp = Float64(t_1 + Float64(Float64(Float64(0.0 / y_m) + t_1) + -1.0));
	end
	return tmp
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(0.5 * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(y$95$m * 2.0 + x$95$m), $MachinePrecision] / N[Sqrt[x$95$m ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(y$95$m * -2.0), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+182], N[(N[(N[(x$95$m + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(N[(N[(0.0 / y$95$m), $MachinePrecision] + t$95$1), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
t_1 := {\left(0.5 \cdot \frac{x\_m}{y\_m}\right)}^{2}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{\mathsf{fma}\left(y\_m, 2, x\_m\right)}{\mathsf{hypot}\left(x\_m, y\_m \cdot 2\right)} \cdot \left(1 + \frac{y\_m \cdot -2}{x\_m}\right)\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\
\;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{t\_0 + x\_m \cdot x\_m}\\

\mathbf{else}:\\
\;\;\;\;t\_1 + \left(\left(\frac{0}{y\_m} + t\_1\right) + -1\right)\\


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

    1. Initial program 58.1%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt58.1%

        \[\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} \]
      2. difference-of-squares58.1%

        \[\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} \]
      3. *-commutative58.1%

        \[\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} \]
      4. associate-*r*58.1%

        \[\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} \]
      5. sqrt-prod58.1%

        \[\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} \]
      6. sqrt-unprod30.6%

        \[\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} \]
      7. add-sqr-sqrt58.1%

        \[\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} \]
      8. metadata-eval58.1%

        \[\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} \]
      9. *-commutative58.1%

        \[\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} \]
      10. associate-*r*58.1%

        \[\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} \]
      11. sqrt-prod58.1%

        \[\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} \]
      12. sqrt-unprod30.6%

        \[\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} \]
      13. add-sqr-sqrt58.1%

        \[\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} \]
      14. metadata-eval58.1%

        \[\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} \]
    4. Applied egg-rr58.1%

      \[\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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt58.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      10. metadata-eval30.6%

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*30.6%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around 0 38.4%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \color{blue}{\left(1 + -2 \cdot \frac{y}{x}\right)} \]
    8. Step-by-step derivation
      1. associate-*r/38.4%

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

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

    if 0.0 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 4.99999999999999973e182

    1. Initial program 81.6%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt81.6%

        \[\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} \]
      2. difference-of-squares81.6%

        \[\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} \]
      3. *-commutative81.6%

        \[\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} \]
      4. associate-*r*81.6%

        \[\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} \]
      5. sqrt-prod81.6%

        \[\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} \]
      6. sqrt-unprod40.7%

        \[\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} \]
      7. add-sqr-sqrt57.7%

        \[\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} \]
      8. metadata-eval57.7%

        \[\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} \]
      9. *-commutative57.7%

        \[\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} \]
      10. associate-*r*57.0%

        \[\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} \]
      11. sqrt-prod57.0%

        \[\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} \]
      12. sqrt-unprod40.7%

        \[\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} \]
      13. add-sqr-sqrt81.6%

        \[\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} \]
      14. metadata-eval81.6%

        \[\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} \]
    4. Applied egg-rr81.6%

      \[\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} \]

    if 4.99999999999999973e182 < (*.f64 (*.f64 y #s(literal 4 binary64)) y)

    1. Initial program 18.8%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt18.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} \]
      2. difference-of-squares18.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} \]
      3. *-commutative18.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} \]
      4. associate-*r*18.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} \]
      5. sqrt-prod18.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} \]
      6. sqrt-unprod9.3%

        \[\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} \]
      7. add-sqr-sqrt9.5%

        \[\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} \]
      8. metadata-eval9.5%

        \[\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} \]
      9. *-commutative9.5%

        \[\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} \]
      10. associate-*r*9.5%

        \[\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} \]
      11. sqrt-prod9.5%

        \[\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} \]
      12. sqrt-unprod9.3%

        \[\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} \]
      13. add-sqr-sqrt18.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} \]
      14. metadata-eval18.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} \]
    4. Applied egg-rr18.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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt18.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*10.4%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Step-by-step derivation
      1. *-commutative98.8%

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

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(y, -2, x\right)}}{\mathsf{hypot}\left(x, y \cdot 2\right) \cdot \frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}} \]
      5. *-un-lft-identity98.9%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y, -2, x\right)}}{\mathsf{hypot}\left(x, y \cdot 2\right) \cdot \frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}} \]
    8. Applied egg-rr98.9%

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

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

        \[\leadsto \color{blue}{\left(\left(0.25 \cdot \frac{-2 \cdot x + 2 \cdot x}{y} + 0.25 \cdot \frac{{x}^{2}}{{y}^{2}}\right) - 1\right) - -0.25 \cdot \frac{{x}^{2}}{{y}^{2}}} \]
      2. cancel-sign-sub-inv74.9%

        \[\leadsto \color{blue}{\left(\left(0.25 \cdot \frac{-2 \cdot x + 2 \cdot x}{y} + 0.25 \cdot \frac{{x}^{2}}{{y}^{2}}\right) - 1\right) + \left(--0.25\right) \cdot \frac{{x}^{2}}{{y}^{2}}} \]
    11. Simplified82.5%

      \[\leadsto \color{blue}{\left(\left(\frac{0}{y} + {\left(0.5 \cdot \frac{x}{y}\right)}^{2}\right) + -1\right) + {\left(0.5 \cdot \frac{x}{y}\right)}^{2}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.5%

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

Alternative 4: 81.3% accurate, 0.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := 0.5 \cdot \frac{x\_m}{y\_m}\\ t_1 := y\_m \cdot \left(y\_m \cdot 4\right)\\ \mathbf{if}\;t\_1 \leq 0:\\ \;\;\;\;\frac{\mathsf{fma}\left(y\_m, 2, x\_m\right)}{\mathsf{hypot}\left(x\_m, y\_m \cdot 2\right)} \cdot \left(1 + \frac{y\_m \cdot -2}{x\_m}\right)\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+182}:\\ \;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{t\_1 + x\_m \cdot x\_m}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (let* ((t_0 (* 0.5 (/ x_m y_m))) (t_1 (* y_m (* y_m 4.0))))
   (if (<= t_1 0.0)
     (*
      (/ (fma y_m 2.0 x_m) (hypot x_m (* y_m 2.0)))
      (+ 1.0 (/ (* y_m -2.0) x_m)))
     (if (<= t_1 5e+182)
       (/ (* (+ x_m (* y_m 2.0)) (- x_m (* y_m 2.0))) (+ t_1 (* x_m x_m)))
       (* (+ 1.0 t_0) (+ t_0 -1.0))))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = 0.5 * (x_m / y_m);
	double t_1 = y_m * (y_m * 4.0);
	double tmp;
	if (t_1 <= 0.0) {
		tmp = (fma(y_m, 2.0, x_m) / hypot(x_m, (y_m * 2.0))) * (1.0 + ((y_m * -2.0) / x_m));
	} else if (t_1 <= 5e+182) {
		tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / (t_1 + (x_m * x_m));
	} else {
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	}
	return tmp;
}
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = Float64(0.5 * Float64(x_m / y_m))
	t_1 = Float64(y_m * Float64(y_m * 4.0))
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = Float64(Float64(fma(y_m, 2.0, x_m) / hypot(x_m, Float64(y_m * 2.0))) * Float64(1.0 + Float64(Float64(y_m * -2.0) / x_m)));
	elseif (t_1 <= 5e+182)
		tmp = Float64(Float64(Float64(x_m + Float64(y_m * 2.0)) * Float64(x_m - Float64(y_m * 2.0))) / Float64(t_1 + Float64(x_m * x_m)));
	else
		tmp = Float64(Float64(1.0 + t_0) * Float64(t_0 + -1.0));
	end
	return tmp
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(0.5 * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[(y$95$m * 2.0 + x$95$m), $MachinePrecision] / N[Sqrt[x$95$m ^ 2 + N[(y$95$m * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(y$95$m * -2.0), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+182], N[(N[(N[(x$95$m + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$0), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{x\_m}{y\_m}\\
t_1 := y\_m \cdot \left(y\_m \cdot 4\right)\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{fma}\left(y\_m, 2, x\_m\right)}{\mathsf{hypot}\left(x\_m, y\_m \cdot 2\right)} \cdot \left(1 + \frac{y\_m \cdot -2}{x\_m}\right)\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+182}:\\
\;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{t\_1 + x\_m \cdot x\_m}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\


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

    1. Initial program 58.1%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt58.1%

        \[\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} \]
      2. difference-of-squares58.1%

        \[\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} \]
      3. *-commutative58.1%

        \[\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} \]
      4. associate-*r*58.1%

        \[\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} \]
      5. sqrt-prod58.1%

        \[\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} \]
      6. sqrt-unprod30.6%

        \[\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} \]
      7. add-sqr-sqrt58.1%

        \[\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} \]
      8. metadata-eval58.1%

        \[\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} \]
      9. *-commutative58.1%

        \[\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} \]
      10. associate-*r*58.1%

        \[\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} \]
      11. sqrt-prod58.1%

        \[\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} \]
      12. sqrt-unprod30.6%

        \[\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} \]
      13. add-sqr-sqrt58.1%

        \[\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} \]
      14. metadata-eval58.1%

        \[\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} \]
    4. Applied egg-rr58.1%

      \[\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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt58.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      10. metadata-eval30.6%

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*30.6%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around 0 38.4%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \color{blue}{\left(1 + -2 \cdot \frac{y}{x}\right)} \]
    8. Step-by-step derivation
      1. associate-*r/38.4%

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

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

    if 0.0 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 4.99999999999999973e182

    1. Initial program 81.6%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt81.6%

        \[\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} \]
      2. difference-of-squares81.6%

        \[\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} \]
      3. *-commutative81.6%

        \[\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} \]
      4. associate-*r*81.6%

        \[\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} \]
      5. sqrt-prod81.6%

        \[\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} \]
      6. sqrt-unprod40.7%

        \[\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} \]
      7. add-sqr-sqrt57.7%

        \[\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} \]
      8. metadata-eval57.7%

        \[\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} \]
      9. *-commutative57.7%

        \[\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} \]
      10. associate-*r*57.0%

        \[\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} \]
      11. sqrt-prod57.0%

        \[\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} \]
      12. sqrt-unprod40.7%

        \[\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} \]
      13. add-sqr-sqrt81.6%

        \[\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} \]
      14. metadata-eval81.6%

        \[\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} \]
    4. Applied egg-rr81.6%

      \[\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} \]

    if 4.99999999999999973e182 < (*.f64 (*.f64 y #s(literal 4 binary64)) y)

    1. Initial program 18.8%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt18.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} \]
      2. difference-of-squares18.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} \]
      3. *-commutative18.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} \]
      4. associate-*r*18.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} \]
      5. sqrt-prod18.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} \]
      6. sqrt-unprod9.3%

        \[\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} \]
      7. add-sqr-sqrt9.5%

        \[\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} \]
      8. metadata-eval9.5%

        \[\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} \]
      9. *-commutative9.5%

        \[\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} \]
      10. associate-*r*9.5%

        \[\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} \]
      11. sqrt-prod9.5%

        \[\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} \]
      12. sqrt-unprod9.3%

        \[\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} \]
      13. add-sqr-sqrt18.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} \]
      14. metadata-eval18.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} \]
    4. Applied egg-rr18.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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt18.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*10.4%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around inf 35.9%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot \frac{x}{y}\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
    8. Taylor expanded in y around inf 82.2%

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

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

Alternative 5: 81.3% accurate, 0.2× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := 0.5 \cdot \frac{x\_m}{y\_m}\\ t_1 := y\_m \cdot \left(y\_m \cdot 4\right)\\ \mathbf{if}\;t\_1 \leq 0:\\ \;\;\;\;\frac{\mathsf{fma}\left(y\_m, -2, x\_m\right)}{x\_m + y\_m \cdot \left(8 \cdot \frac{y\_m}{x\_m} - 2\right)}\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+182}:\\ \;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{t\_1 + x\_m \cdot x\_m}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (let* ((t_0 (* 0.5 (/ x_m y_m))) (t_1 (* y_m (* y_m 4.0))))
   (if (<= t_1 0.0)
     (/ (fma y_m -2.0 x_m) (+ x_m (* y_m (- (* 8.0 (/ y_m x_m)) 2.0))))
     (if (<= t_1 5e+182)
       (/ (* (+ x_m (* y_m 2.0)) (- x_m (* y_m 2.0))) (+ t_1 (* x_m x_m)))
       (* (+ 1.0 t_0) (+ t_0 -1.0))))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = 0.5 * (x_m / y_m);
	double t_1 = y_m * (y_m * 4.0);
	double tmp;
	if (t_1 <= 0.0) {
		tmp = fma(y_m, -2.0, x_m) / (x_m + (y_m * ((8.0 * (y_m / x_m)) - 2.0)));
	} else if (t_1 <= 5e+182) {
		tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / (t_1 + (x_m * x_m));
	} else {
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	}
	return tmp;
}
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = Float64(0.5 * Float64(x_m / y_m))
	t_1 = Float64(y_m * Float64(y_m * 4.0))
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = Float64(fma(y_m, -2.0, x_m) / Float64(x_m + Float64(y_m * Float64(Float64(8.0 * Float64(y_m / x_m)) - 2.0))));
	elseif (t_1 <= 5e+182)
		tmp = Float64(Float64(Float64(x_m + Float64(y_m * 2.0)) * Float64(x_m - Float64(y_m * 2.0))) / Float64(t_1 + Float64(x_m * x_m)));
	else
		tmp = Float64(Float64(1.0 + t_0) * Float64(t_0 + -1.0));
	end
	return tmp
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(0.5 * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(y$95$m * -2.0 + x$95$m), $MachinePrecision] / N[(x$95$m + N[(y$95$m * N[(N[(8.0 * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+182], N[(N[(N[(x$95$m + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$0), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{x\_m}{y\_m}\\
t_1 := y\_m \cdot \left(y\_m \cdot 4\right)\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{fma}\left(y\_m, -2, x\_m\right)}{x\_m + y\_m \cdot \left(8 \cdot \frac{y\_m}{x\_m} - 2\right)}\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+182}:\\
\;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{t\_1 + x\_m \cdot x\_m}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\


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

    1. Initial program 58.1%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt58.1%

        \[\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} \]
      2. difference-of-squares58.1%

        \[\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} \]
      3. *-commutative58.1%

        \[\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} \]
      4. associate-*r*58.1%

        \[\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} \]
      5. sqrt-prod58.1%

        \[\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} \]
      6. sqrt-unprod30.6%

        \[\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} \]
      7. add-sqr-sqrt58.1%

        \[\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} \]
      8. metadata-eval58.1%

        \[\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} \]
      9. *-commutative58.1%

        \[\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} \]
      10. associate-*r*58.1%

        \[\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} \]
      11. sqrt-prod58.1%

        \[\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} \]
      12. sqrt-unprod30.6%

        \[\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} \]
      13. add-sqr-sqrt58.1%

        \[\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} \]
      14. metadata-eval58.1%

        \[\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} \]
    4. Applied egg-rr58.1%

      \[\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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt58.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      10. metadata-eval30.6%

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*30.6%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
      2. clear-num100.0%

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(y, -2, x\right)}}{\mathsf{hypot}\left(x, y \cdot 2\right) \cdot \frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}} \]
      5. *-un-lft-identity99.9%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y, -2, x\right)}}{\mathsf{hypot}\left(x, y \cdot 2\right) \cdot \frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}} \]
    8. Applied egg-rr99.9%

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

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

    if 0.0 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 4.99999999999999973e182

    1. Initial program 81.6%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt81.6%

        \[\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} \]
      2. difference-of-squares81.6%

        \[\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} \]
      3. *-commutative81.6%

        \[\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} \]
      4. associate-*r*81.6%

        \[\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} \]
      5. sqrt-prod81.6%

        \[\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} \]
      6. sqrt-unprod40.7%

        \[\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} \]
      7. add-sqr-sqrt57.7%

        \[\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} \]
      8. metadata-eval57.7%

        \[\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} \]
      9. *-commutative57.7%

        \[\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} \]
      10. associate-*r*57.0%

        \[\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} \]
      11. sqrt-prod57.0%

        \[\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} \]
      12. sqrt-unprod40.7%

        \[\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} \]
      13. add-sqr-sqrt81.6%

        \[\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} \]
      14. metadata-eval81.6%

        \[\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} \]
    4. Applied egg-rr81.6%

      \[\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} \]

    if 4.99999999999999973e182 < (*.f64 (*.f64 y #s(literal 4 binary64)) y)

    1. Initial program 18.8%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt18.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} \]
      2. difference-of-squares18.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} \]
      3. *-commutative18.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} \]
      4. associate-*r*18.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} \]
      5. sqrt-prod18.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} \]
      6. sqrt-unprod9.3%

        \[\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} \]
      7. add-sqr-sqrt9.5%

        \[\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} \]
      8. metadata-eval9.5%

        \[\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} \]
      9. *-commutative9.5%

        \[\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} \]
      10. associate-*r*9.5%

        \[\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} \]
      11. sqrt-prod9.5%

        \[\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} \]
      12. sqrt-unprod9.3%

        \[\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} \]
      13. add-sqr-sqrt18.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} \]
      14. metadata-eval18.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} \]
    4. Applied egg-rr18.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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt18.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*10.4%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around inf 35.9%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot \frac{x}{y}\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
    8. Taylor expanded in y around inf 82.2%

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

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

Alternative 6: 81.2% accurate, 0.2× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\ t_1 := 0.5 \cdot \frac{x\_m}{y\_m}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;\frac{\mathsf{fma}\left(y\_m, -2, x\_m\right)}{x\_m}\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\ \;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{t\_0 + x\_m \cdot x\_m}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + t\_1\right) \cdot \left(t\_1 + -1\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (* 0.5 (/ x_m y_m))))
   (if (<= t_0 0.0)
     (/ (fma y_m -2.0 x_m) x_m)
     (if (<= t_0 5e+182)
       (/ (* (+ x_m (* y_m 2.0)) (- x_m (* y_m 2.0))) (+ t_0 (* x_m x_m)))
       (* (+ 1.0 t_1) (+ t_1 -1.0))))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = y_m * (y_m * 4.0);
	double t_1 = 0.5 * (x_m / y_m);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = fma(y_m, -2.0, x_m) / x_m;
	} else if (t_0 <= 5e+182) {
		tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / (t_0 + (x_m * x_m));
	} else {
		tmp = (1.0 + t_1) * (t_1 + -1.0);
	}
	return tmp;
}
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = Float64(y_m * Float64(y_m * 4.0))
	t_1 = Float64(0.5 * Float64(x_m / y_m))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = Float64(fma(y_m, -2.0, x_m) / x_m);
	elseif (t_0 <= 5e+182)
		tmp = Float64(Float64(Float64(x_m + Float64(y_m * 2.0)) * Float64(x_m - Float64(y_m * 2.0))) / Float64(t_0 + Float64(x_m * x_m)));
	else
		tmp = Float64(Float64(1.0 + t_1) * Float64(t_1 + -1.0));
	end
	return tmp
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(y$95$m * -2.0 + x$95$m), $MachinePrecision] / x$95$m), $MachinePrecision], If[LessEqual[t$95$0, 5e+182], N[(N[(N[(x$95$m + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$1), $MachinePrecision] * N[(t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\
t_1 := 0.5 \cdot \frac{x\_m}{y\_m}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{\mathsf{fma}\left(y\_m, -2, x\_m\right)}{x\_m}\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\
\;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{t\_0 + x\_m \cdot x\_m}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t\_1\right) \cdot \left(t\_1 + -1\right)\\


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

    1. Initial program 58.1%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt58.1%

        \[\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} \]
      2. difference-of-squares58.1%

        \[\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} \]
      3. *-commutative58.1%

        \[\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} \]
      4. associate-*r*58.1%

        \[\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} \]
      5. sqrt-prod58.1%

        \[\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} \]
      6. sqrt-unprod30.6%

        \[\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} \]
      7. add-sqr-sqrt58.1%

        \[\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} \]
      8. metadata-eval58.1%

        \[\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} \]
      9. *-commutative58.1%

        \[\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} \]
      10. associate-*r*58.1%

        \[\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} \]
      11. sqrt-prod58.1%

        \[\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} \]
      12. sqrt-unprod30.6%

        \[\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} \]
      13. add-sqr-sqrt58.1%

        \[\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} \]
      14. metadata-eval58.1%

        \[\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} \]
    4. Applied egg-rr58.1%

      \[\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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt58.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      10. metadata-eval30.6%

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*30.6%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
      2. clear-num100.0%

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(y, -2, x\right)}}{\mathsf{hypot}\left(x, y \cdot 2\right) \cdot \frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}} \]
      5. *-un-lft-identity99.9%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y, -2, x\right)}}{\mathsf{hypot}\left(x, y \cdot 2\right) \cdot \frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\mathsf{fma}\left(y, 2, x\right)}} \]
    8. Applied egg-rr99.9%

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

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

    if 0.0 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 4.99999999999999973e182

    1. Initial program 81.6%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt81.6%

        \[\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} \]
      2. difference-of-squares81.6%

        \[\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} \]
      3. *-commutative81.6%

        \[\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} \]
      4. associate-*r*81.6%

        \[\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} \]
      5. sqrt-prod81.6%

        \[\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} \]
      6. sqrt-unprod40.7%

        \[\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} \]
      7. add-sqr-sqrt57.7%

        \[\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} \]
      8. metadata-eval57.7%

        \[\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} \]
      9. *-commutative57.7%

        \[\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} \]
      10. associate-*r*57.0%

        \[\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} \]
      11. sqrt-prod57.0%

        \[\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} \]
      12. sqrt-unprod40.7%

        \[\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} \]
      13. add-sqr-sqrt81.6%

        \[\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} \]
      14. metadata-eval81.6%

        \[\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} \]
    4. Applied egg-rr81.6%

      \[\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} \]

    if 4.99999999999999973e182 < (*.f64 (*.f64 y #s(literal 4 binary64)) y)

    1. Initial program 18.8%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt18.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} \]
      2. difference-of-squares18.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} \]
      3. *-commutative18.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} \]
      4. associate-*r*18.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} \]
      5. sqrt-prod18.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} \]
      6. sqrt-unprod9.3%

        \[\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} \]
      7. add-sqr-sqrt9.5%

        \[\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} \]
      8. metadata-eval9.5%

        \[\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} \]
      9. *-commutative9.5%

        \[\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} \]
      10. associate-*r*9.5%

        \[\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} \]
      11. sqrt-prod9.5%

        \[\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} \]
      12. sqrt-unprod9.3%

        \[\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} \]
      13. add-sqr-sqrt18.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} \]
      14. metadata-eval18.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} \]
    4. Applied egg-rr18.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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt18.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*10.4%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around inf 35.9%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot \frac{x}{y}\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
    8. Taylor expanded in y around inf 82.2%

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

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

Alternative 7: 81.3% accurate, 0.5× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := 0.5 \cdot \frac{x\_m}{y\_m}\\ t_1 := y\_m \cdot \left(y\_m \cdot 4\right)\\ \mathbf{if}\;t\_1 \leq 0:\\ \;\;\;\;\left(1 + \frac{y\_m \cdot -2}{x\_m}\right) \cdot \left(1 + 2 \cdot \frac{y\_m}{x\_m}\right)\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+182}:\\ \;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{t\_1 + x\_m \cdot x\_m}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (let* ((t_0 (* 0.5 (/ x_m y_m))) (t_1 (* y_m (* y_m 4.0))))
   (if (<= t_1 0.0)
     (* (+ 1.0 (/ (* y_m -2.0) x_m)) (+ 1.0 (* 2.0 (/ y_m x_m))))
     (if (<= t_1 5e+182)
       (/ (* (+ x_m (* y_m 2.0)) (- x_m (* y_m 2.0))) (+ t_1 (* x_m x_m)))
       (* (+ 1.0 t_0) (+ t_0 -1.0))))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = 0.5 * (x_m / y_m);
	double t_1 = y_m * (y_m * 4.0);
	double tmp;
	if (t_1 <= 0.0) {
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)));
	} else if (t_1 <= 5e+182) {
		tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / (t_1 + (x_m * x_m));
	} else {
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	}
	return tmp;
}
x_m = abs(x)
y_m = abs(y)
real(8) function code(x_m, y_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.5d0 * (x_m / y_m)
    t_1 = y_m * (y_m * 4.0d0)
    if (t_1 <= 0.0d0) then
        tmp = (1.0d0 + ((y_m * (-2.0d0)) / x_m)) * (1.0d0 + (2.0d0 * (y_m / x_m)))
    else if (t_1 <= 5d+182) then
        tmp = ((x_m + (y_m * 2.0d0)) * (x_m - (y_m * 2.0d0))) / (t_1 + (x_m * x_m))
    else
        tmp = (1.0d0 + t_0) * (t_0 + (-1.0d0))
    end if
    code = tmp
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
	double t_0 = 0.5 * (x_m / y_m);
	double t_1 = y_m * (y_m * 4.0);
	double tmp;
	if (t_1 <= 0.0) {
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)));
	} else if (t_1 <= 5e+182) {
		tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / (t_1 + (x_m * x_m));
	} else {
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	}
	return tmp;
}
x_m = math.fabs(x)
y_m = math.fabs(y)
def code(x_m, y_m):
	t_0 = 0.5 * (x_m / y_m)
	t_1 = y_m * (y_m * 4.0)
	tmp = 0
	if t_1 <= 0.0:
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)))
	elif t_1 <= 5e+182:
		tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / (t_1 + (x_m * x_m))
	else:
		tmp = (1.0 + t_0) * (t_0 + -1.0)
	return tmp
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = Float64(0.5 * Float64(x_m / y_m))
	t_1 = Float64(y_m * Float64(y_m * 4.0))
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = Float64(Float64(1.0 + Float64(Float64(y_m * -2.0) / x_m)) * Float64(1.0 + Float64(2.0 * Float64(y_m / x_m))));
	elseif (t_1 <= 5e+182)
		tmp = Float64(Float64(Float64(x_m + Float64(y_m * 2.0)) * Float64(x_m - Float64(y_m * 2.0))) / Float64(t_1 + Float64(x_m * x_m)));
	else
		tmp = Float64(Float64(1.0 + t_0) * Float64(t_0 + -1.0));
	end
	return tmp
end
x_m = abs(x);
y_m = abs(y);
function tmp_2 = code(x_m, y_m)
	t_0 = 0.5 * (x_m / y_m);
	t_1 = y_m * (y_m * 4.0);
	tmp = 0.0;
	if (t_1 <= 0.0)
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)));
	elseif (t_1 <= 5e+182)
		tmp = ((x_m + (y_m * 2.0)) * (x_m - (y_m * 2.0))) / (t_1 + (x_m * x_m));
	else
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(0.5 * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(1.0 + N[(N[(y$95$m * -2.0), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(2.0 * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+182], N[(N[(N[(x$95$m + N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$0), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

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

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+182}:\\
\;\;\;\;\frac{\left(x\_m + y\_m \cdot 2\right) \cdot \left(x\_m - y\_m \cdot 2\right)}{t\_1 + x\_m \cdot x\_m}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\


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

    1. Initial program 58.1%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt58.1%

        \[\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} \]
      2. difference-of-squares58.1%

        \[\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} \]
      3. *-commutative58.1%

        \[\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} \]
      4. associate-*r*58.1%

        \[\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} \]
      5. sqrt-prod58.1%

        \[\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} \]
      6. sqrt-unprod30.6%

        \[\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} \]
      7. add-sqr-sqrt58.1%

        \[\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} \]
      8. metadata-eval58.1%

        \[\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} \]
      9. *-commutative58.1%

        \[\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} \]
      10. associate-*r*58.1%

        \[\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} \]
      11. sqrt-prod58.1%

        \[\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} \]
      12. sqrt-unprod30.6%

        \[\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} \]
      13. add-sqr-sqrt58.1%

        \[\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} \]
      14. metadata-eval58.1%

        \[\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} \]
    4. Applied egg-rr58.1%

      \[\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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt58.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      10. metadata-eval30.6%

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*30.6%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around 0 38.4%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \color{blue}{\left(1 + -2 \cdot \frac{y}{x}\right)} \]
    8. Step-by-step derivation
      1. associate-*r/38.4%

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

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

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

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

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

    if 0.0 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 4.99999999999999973e182

    1. Initial program 81.6%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt81.6%

        \[\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} \]
      2. difference-of-squares81.6%

        \[\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} \]
      3. *-commutative81.6%

        \[\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} \]
      4. associate-*r*81.6%

        \[\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} \]
      5. sqrt-prod81.6%

        \[\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} \]
      6. sqrt-unprod40.7%

        \[\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} \]
      7. add-sqr-sqrt57.7%

        \[\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} \]
      8. metadata-eval57.7%

        \[\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} \]
      9. *-commutative57.7%

        \[\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} \]
      10. associate-*r*57.0%

        \[\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} \]
      11. sqrt-prod57.0%

        \[\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} \]
      12. sqrt-unprod40.7%

        \[\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} \]
      13. add-sqr-sqrt81.6%

        \[\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} \]
      14. metadata-eval81.6%

        \[\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} \]
    4. Applied egg-rr81.6%

      \[\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} \]

    if 4.99999999999999973e182 < (*.f64 (*.f64 y #s(literal 4 binary64)) y)

    1. Initial program 18.8%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt18.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} \]
      2. difference-of-squares18.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} \]
      3. *-commutative18.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} \]
      4. associate-*r*18.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} \]
      5. sqrt-prod18.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} \]
      6. sqrt-unprod9.3%

        \[\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} \]
      7. add-sqr-sqrt9.5%

        \[\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} \]
      8. metadata-eval9.5%

        \[\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} \]
      9. *-commutative9.5%

        \[\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} \]
      10. associate-*r*9.5%

        \[\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} \]
      11. sqrt-prod9.5%

        \[\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} \]
      12. sqrt-unprod9.3%

        \[\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} \]
      13. add-sqr-sqrt18.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} \]
      14. metadata-eval18.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} \]
    4. Applied egg-rr18.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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt18.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*10.4%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around inf 35.9%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot \frac{x}{y}\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
    8. Taylor expanded in y around inf 82.2%

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

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

Alternative 8: 81.3% accurate, 0.5× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := y\_m \cdot \left(y\_m \cdot 4\right)\\ t_1 := 0.5 \cdot \frac{x\_m}{y\_m}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;\left(1 + \frac{y\_m \cdot -2}{x\_m}\right) \cdot \left(1 + 2 \cdot \frac{y\_m}{x\_m}\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\ \;\;\;\;\frac{x\_m \cdot x\_m - t\_0}{t\_0 + x\_m \cdot x\_m}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + t\_1\right) \cdot \left(t\_1 + -1\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (let* ((t_0 (* y_m (* y_m 4.0))) (t_1 (* 0.5 (/ x_m y_m))))
   (if (<= t_0 0.0)
     (* (+ 1.0 (/ (* y_m -2.0) x_m)) (+ 1.0 (* 2.0 (/ y_m x_m))))
     (if (<= t_0 5e+182)
       (/ (- (* x_m x_m) t_0) (+ t_0 (* x_m x_m)))
       (* (+ 1.0 t_1) (+ t_1 -1.0))))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = y_m * (y_m * 4.0);
	double t_1 = 0.5 * (x_m / y_m);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)));
	} else if (t_0 <= 5e+182) {
		tmp = ((x_m * x_m) - t_0) / (t_0 + (x_m * x_m));
	} else {
		tmp = (1.0 + t_1) * (t_1 + -1.0);
	}
	return tmp;
}
x_m = abs(x)
y_m = abs(y)
real(8) function code(x_m, y_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y_m * (y_m * 4.0d0)
    t_1 = 0.5d0 * (x_m / y_m)
    if (t_0 <= 0.0d0) then
        tmp = (1.0d0 + ((y_m * (-2.0d0)) / x_m)) * (1.0d0 + (2.0d0 * (y_m / x_m)))
    else if (t_0 <= 5d+182) then
        tmp = ((x_m * x_m) - t_0) / (t_0 + (x_m * x_m))
    else
        tmp = (1.0d0 + t_1) * (t_1 + (-1.0d0))
    end if
    code = tmp
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
	double t_0 = y_m * (y_m * 4.0);
	double t_1 = 0.5 * (x_m / y_m);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)));
	} else if (t_0 <= 5e+182) {
		tmp = ((x_m * x_m) - t_0) / (t_0 + (x_m * x_m));
	} else {
		tmp = (1.0 + t_1) * (t_1 + -1.0);
	}
	return tmp;
}
x_m = math.fabs(x)
y_m = math.fabs(y)
def code(x_m, y_m):
	t_0 = y_m * (y_m * 4.0)
	t_1 = 0.5 * (x_m / y_m)
	tmp = 0
	if t_0 <= 0.0:
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)))
	elif t_0 <= 5e+182:
		tmp = ((x_m * x_m) - t_0) / (t_0 + (x_m * x_m))
	else:
		tmp = (1.0 + t_1) * (t_1 + -1.0)
	return tmp
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = Float64(y_m * Float64(y_m * 4.0))
	t_1 = Float64(0.5 * Float64(x_m / y_m))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = Float64(Float64(1.0 + Float64(Float64(y_m * -2.0) / x_m)) * Float64(1.0 + Float64(2.0 * Float64(y_m / x_m))));
	elseif (t_0 <= 5e+182)
		tmp = Float64(Float64(Float64(x_m * x_m) - t_0) / Float64(t_0 + Float64(x_m * x_m)));
	else
		tmp = Float64(Float64(1.0 + t_1) * Float64(t_1 + -1.0));
	end
	return tmp
end
x_m = abs(x);
y_m = abs(y);
function tmp_2 = code(x_m, y_m)
	t_0 = y_m * (y_m * 4.0);
	t_1 = 0.5 * (x_m / y_m);
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)));
	elseif (t_0 <= 5e+182)
		tmp = ((x_m * x_m) - t_0) / (t_0 + (x_m * x_m));
	else
		tmp = (1.0 + t_1) * (t_1 + -1.0);
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(1.0 + N[(N[(y$95$m * -2.0), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(2.0 * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+182], N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$0 + N[(x$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$1), $MachinePrecision] * N[(t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

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

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+182}:\\
\;\;\;\;\frac{x\_m \cdot x\_m - t\_0}{t\_0 + x\_m \cdot x\_m}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + t\_1\right) \cdot \left(t\_1 + -1\right)\\


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

    1. Initial program 58.1%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt58.1%

        \[\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} \]
      2. difference-of-squares58.1%

        \[\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} \]
      3. *-commutative58.1%

        \[\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} \]
      4. associate-*r*58.1%

        \[\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} \]
      5. sqrt-prod58.1%

        \[\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} \]
      6. sqrt-unprod30.6%

        \[\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} \]
      7. add-sqr-sqrt58.1%

        \[\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} \]
      8. metadata-eval58.1%

        \[\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} \]
      9. *-commutative58.1%

        \[\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} \]
      10. associate-*r*58.1%

        \[\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} \]
      11. sqrt-prod58.1%

        \[\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} \]
      12. sqrt-unprod30.6%

        \[\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} \]
      13. add-sqr-sqrt58.1%

        \[\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} \]
      14. metadata-eval58.1%

        \[\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} \]
    4. Applied egg-rr58.1%

      \[\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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt58.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      10. metadata-eval30.6%

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*30.6%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around 0 38.4%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \color{blue}{\left(1 + -2 \cdot \frac{y}{x}\right)} \]
    8. Step-by-step derivation
      1. associate-*r/38.4%

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

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

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

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

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

    if 0.0 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 4.99999999999999973e182

    1. Initial program 81.6%

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

    if 4.99999999999999973e182 < (*.f64 (*.f64 y #s(literal 4 binary64)) y)

    1. Initial program 18.8%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt18.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} \]
      2. difference-of-squares18.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} \]
      3. *-commutative18.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} \]
      4. associate-*r*18.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} \]
      5. sqrt-prod18.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} \]
      6. sqrt-unprod9.3%

        \[\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} \]
      7. add-sqr-sqrt9.5%

        \[\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} \]
      8. metadata-eval9.5%

        \[\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} \]
      9. *-commutative9.5%

        \[\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} \]
      10. associate-*r*9.5%

        \[\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} \]
      11. sqrt-prod9.5%

        \[\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} \]
      12. sqrt-unprod9.3%

        \[\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} \]
      13. add-sqr-sqrt18.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} \]
      14. metadata-eval18.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} \]
    4. Applied egg-rr18.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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt18.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*10.4%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around inf 35.9%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot \frac{x}{y}\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
    8. Taylor expanded in y around inf 82.2%

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

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

Alternative 9: 74.4% accurate, 0.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := 0.5 \cdot \frac{x\_m}{y\_m}\\ \mathbf{if}\;x\_m \leq 9.2 \cdot 10^{-28} \lor \neg \left(x\_m \leq 1.45 \cdot 10^{+34}\right) \land x\_m \leq 3.35 \cdot 10^{+47}:\\ \;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{y\_m \cdot -2}{x\_m}\right) \cdot \left(1 + 2 \cdot \frac{y\_m}{x\_m}\right)\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (let* ((t_0 (* 0.5 (/ x_m y_m))))
   (if (or (<= x_m 9.2e-28) (and (not (<= x_m 1.45e+34)) (<= x_m 3.35e+47)))
     (* (+ 1.0 t_0) (+ t_0 -1.0))
     (* (+ 1.0 (/ (* y_m -2.0) x_m)) (+ 1.0 (* 2.0 (/ y_m x_m)))))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = 0.5 * (x_m / y_m);
	double tmp;
	if ((x_m <= 9.2e-28) || (!(x_m <= 1.45e+34) && (x_m <= 3.35e+47))) {
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	} else {
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)));
	}
	return tmp;
}
x_m = abs(x)
y_m = abs(y)
real(8) function code(x_m, y_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.5d0 * (x_m / y_m)
    if ((x_m <= 9.2d-28) .or. (.not. (x_m <= 1.45d+34)) .and. (x_m <= 3.35d+47)) then
        tmp = (1.0d0 + t_0) * (t_0 + (-1.0d0))
    else
        tmp = (1.0d0 + ((y_m * (-2.0d0)) / x_m)) * (1.0d0 + (2.0d0 * (y_m / x_m)))
    end if
    code = tmp
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
	double t_0 = 0.5 * (x_m / y_m);
	double tmp;
	if ((x_m <= 9.2e-28) || (!(x_m <= 1.45e+34) && (x_m <= 3.35e+47))) {
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	} else {
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)));
	}
	return tmp;
}
x_m = math.fabs(x)
y_m = math.fabs(y)
def code(x_m, y_m):
	t_0 = 0.5 * (x_m / y_m)
	tmp = 0
	if (x_m <= 9.2e-28) or (not (x_m <= 1.45e+34) and (x_m <= 3.35e+47)):
		tmp = (1.0 + t_0) * (t_0 + -1.0)
	else:
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)))
	return tmp
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = Float64(0.5 * Float64(x_m / y_m))
	tmp = 0.0
	if ((x_m <= 9.2e-28) || (!(x_m <= 1.45e+34) && (x_m <= 3.35e+47)))
		tmp = Float64(Float64(1.0 + t_0) * Float64(t_0 + -1.0));
	else
		tmp = Float64(Float64(1.0 + Float64(Float64(y_m * -2.0) / x_m)) * Float64(1.0 + Float64(2.0 * Float64(y_m / x_m))));
	end
	return tmp
end
x_m = abs(x);
y_m = abs(y);
function tmp_2 = code(x_m, y_m)
	t_0 = 0.5 * (x_m / y_m);
	tmp = 0.0;
	if ((x_m <= 9.2e-28) || (~((x_m <= 1.45e+34)) && (x_m <= 3.35e+47)))
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	else
		tmp = (1.0 + ((y_m * -2.0) / x_m)) * (1.0 + (2.0 * (y_m / x_m)));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(0.5 * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x$95$m, 9.2e-28], And[N[Not[LessEqual[x$95$m, 1.45e+34]], $MachinePrecision], LessEqual[x$95$m, 3.35e+47]]], N[(N[(1.0 + t$95$0), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(y$95$m * -2.0), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(2.0 * N[(y$95$m / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{x\_m}{y\_m}\\
\mathbf{if}\;x\_m \leq 9.2 \cdot 10^{-28} \lor \neg \left(x\_m \leq 1.45 \cdot 10^{+34}\right) \land x\_m \leq 3.35 \cdot 10^{+47}:\\
\;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 9.19999999999999942e-28 or 1.4500000000000001e34 < x < 3.34999999999999986e47

    1. Initial program 54.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt54.0%

        \[\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} \]
      2. difference-of-squares54.0%

        \[\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} \]
      3. *-commutative54.0%

        \[\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} \]
      4. associate-*r*54.0%

        \[\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} \]
      5. sqrt-prod54.0%

        \[\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} \]
      6. sqrt-unprod27.7%

        \[\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} \]
      7. add-sqr-sqrt38.4%

        \[\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} \]
      8. metadata-eval38.4%

        \[\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} \]
      9. *-commutative38.4%

        \[\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} \]
      10. associate-*r*38.0%

        \[\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} \]
      11. sqrt-prod38.0%

        \[\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} \]
      12. sqrt-unprod27.7%

        \[\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} \]
      13. add-sqr-sqrt54.0%

        \[\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} \]
      14. metadata-eval54.0%

        \[\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} \]
    4. Applied egg-rr54.0%

      \[\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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt54.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      10. metadata-eval27.8%

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*27.8%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around inf 28.8%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot \frac{x}{y}\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
    8. Taylor expanded in y around inf 62.9%

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

    if 9.19999999999999942e-28 < x < 1.4500000000000001e34 or 3.34999999999999986e47 < x

    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. Add Preprocessing
    3. Step-by-step derivation
      1. 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} \]
      2. 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} \]
      3. *-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} \]
      4. 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} \]
      5. 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} \]
      6. sqrt-unprod23.8%

        \[\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} \]
      7. add-sqr-sqrt42.6%

        \[\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} \]
      8. metadata-eval42.6%

        \[\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} \]
      9. *-commutative42.6%

        \[\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} \]
      10. associate-*r*42.6%

        \[\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} \]
      11. sqrt-prod42.6%

        \[\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} \]
      12. sqrt-unprod23.8%

        \[\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} \]
      13. 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} \]
      14. 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} \]
    4. 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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt48.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      10. metadata-eval24.5%

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*24.5%

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right) \cdot 2}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      12. add-sqr-sqrt50.4%

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around 0 81.5%

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \color{blue}{\left(1 + -2 \cdot \frac{y}{x}\right)} \]
    8. Step-by-step derivation
      1. associate-*r/81.5%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 9.2 \cdot 10^{-28} \lor \neg \left(x \leq 1.45 \cdot 10^{+34}\right) \land x \leq 3.35 \cdot 10^{+47}:\\ \;\;\;\;\left(1 + 0.5 \cdot \frac{x}{y}\right) \cdot \left(0.5 \cdot \frac{x}{y} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{y \cdot -2}{x}\right) \cdot \left(1 + 2 \cdot \frac{y}{x}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 73.9% accurate, 0.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := 0.5 \cdot \frac{x\_m}{y\_m}\\ \mathbf{if}\;x\_m \leq 4 \cdot 10^{-30} \lor \neg \left(x\_m \leq 9.5 \cdot 10^{+33}\right) \land x\_m \leq 6.8 \cdot 10^{+46}:\\ \;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (let* ((t_0 (* 0.5 (/ x_m y_m))))
   (if (or (<= x_m 4e-30) (and (not (<= x_m 9.5e+33)) (<= x_m 6.8e+46)))
     (* (+ 1.0 t_0) (+ t_0 -1.0))
     1.0)))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = 0.5 * (x_m / y_m);
	double tmp;
	if ((x_m <= 4e-30) || (!(x_m <= 9.5e+33) && (x_m <= 6.8e+46))) {
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
x_m = abs(x)
y_m = abs(y)
real(8) function code(x_m, y_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.5d0 * (x_m / y_m)
    if ((x_m <= 4d-30) .or. (.not. (x_m <= 9.5d+33)) .and. (x_m <= 6.8d+46)) then
        tmp = (1.0d0 + t_0) * (t_0 + (-1.0d0))
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
	double t_0 = 0.5 * (x_m / y_m);
	double tmp;
	if ((x_m <= 4e-30) || (!(x_m <= 9.5e+33) && (x_m <= 6.8e+46))) {
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
x_m = math.fabs(x)
y_m = math.fabs(y)
def code(x_m, y_m):
	t_0 = 0.5 * (x_m / y_m)
	tmp = 0
	if (x_m <= 4e-30) or (not (x_m <= 9.5e+33) and (x_m <= 6.8e+46)):
		tmp = (1.0 + t_0) * (t_0 + -1.0)
	else:
		tmp = 1.0
	return tmp
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = Float64(0.5 * Float64(x_m / y_m))
	tmp = 0.0
	if ((x_m <= 4e-30) || (!(x_m <= 9.5e+33) && (x_m <= 6.8e+46)))
		tmp = Float64(Float64(1.0 + t_0) * Float64(t_0 + -1.0));
	else
		tmp = 1.0;
	end
	return tmp
end
x_m = abs(x);
y_m = abs(y);
function tmp_2 = code(x_m, y_m)
	t_0 = 0.5 * (x_m / y_m);
	tmp = 0.0;
	if ((x_m <= 4e-30) || (~((x_m <= 9.5e+33)) && (x_m <= 6.8e+46)))
		tmp = (1.0 + t_0) * (t_0 + -1.0);
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := Block[{t$95$0 = N[(0.5 * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x$95$m, 4e-30], And[N[Not[LessEqual[x$95$m, 9.5e+33]], $MachinePrecision], LessEqual[x$95$m, 6.8e+46]]], N[(N[(1.0 + t$95$0), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{x\_m}{y\_m}\\
\mathbf{if}\;x\_m \leq 4 \cdot 10^{-30} \lor \neg \left(x\_m \leq 9.5 \cdot 10^{+33}\right) \land x\_m \leq 6.8 \cdot 10^{+46}:\\
\;\;\;\;\left(1 + t\_0\right) \cdot \left(t\_0 + -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4e-30 or 9.5000000000000003e33 < x < 6.7999999999999996e46

    1. Initial program 54.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt54.0%

        \[\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} \]
      2. difference-of-squares54.0%

        \[\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} \]
      3. *-commutative54.0%

        \[\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} \]
      4. associate-*r*54.0%

        \[\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} \]
      5. sqrt-prod54.0%

        \[\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} \]
      6. sqrt-unprod27.7%

        \[\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} \]
      7. add-sqr-sqrt38.4%

        \[\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} \]
      8. metadata-eval38.4%

        \[\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} \]
      9. *-commutative38.4%

        \[\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} \]
      10. associate-*r*38.0%

        \[\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} \]
      11. sqrt-prod38.0%

        \[\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} \]
      12. sqrt-unprod27.7%

        \[\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} \]
      13. add-sqr-sqrt54.0%

        \[\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} \]
      14. metadata-eval54.0%

        \[\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} \]
    4. Applied egg-rr54.0%

      \[\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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt54.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{4}\right)}\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      10. metadata-eval27.8%

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, \sqrt{y} \cdot \left(\sqrt{y} \cdot \color{blue}{2}\right)\right)} \cdot \frac{x - y \cdot 2}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}} \]
      11. associate-*l*27.8%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    7. Taylor expanded in y around inf 28.8%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot \frac{x}{y}\right)} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \]
    8. Taylor expanded in y around inf 62.9%

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

    if 4e-30 < x < 9.5000000000000003e33 or 6.7999999999999996e46 < x

    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. Add Preprocessing
    3. Taylor expanded in x around inf 80.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4 \cdot 10^{-30} \lor \neg \left(x \leq 9.5 \cdot 10^{+33}\right) \land x \leq 6.8 \cdot 10^{+46}:\\ \;\;\;\;\left(1 + 0.5 \cdot \frac{x}{y}\right) \cdot \left(0.5 \cdot \frac{x}{y} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 73.4% accurate, 1.2× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 4 \cdot 10^{-30}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x\_m \leq 1.55 \cdot 10^{+34}:\\ \;\;\;\;1\\ \mathbf{elif}\;x\_m \leq 5 \cdot 10^{+45}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
y_m = (fabs.f64 y)
(FPCore (x_m y_m)
 :precision binary64
 (if (<= x_m 4e-30)
   -1.0
   (if (<= x_m 1.55e+34) 1.0 (if (<= x_m 5e+45) -1.0 1.0))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double tmp;
	if (x_m <= 4e-30) {
		tmp = -1.0;
	} else if (x_m <= 1.55e+34) {
		tmp = 1.0;
	} else if (x_m <= 5e+45) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
x_m = abs(x)
y_m = abs(y)
real(8) function code(x_m, y_m)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y_m
    real(8) :: tmp
    if (x_m <= 4d-30) then
        tmp = -1.0d0
    else if (x_m <= 1.55d+34) then
        tmp = 1.0d0
    else if (x_m <= 5d+45) then
        tmp = -1.0d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
x_m = Math.abs(x);
y_m = Math.abs(y);
public static double code(double x_m, double y_m) {
	double tmp;
	if (x_m <= 4e-30) {
		tmp = -1.0;
	} else if (x_m <= 1.55e+34) {
		tmp = 1.0;
	} else if (x_m <= 5e+45) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
x_m = math.fabs(x)
y_m = math.fabs(y)
def code(x_m, y_m):
	tmp = 0
	if x_m <= 4e-30:
		tmp = -1.0
	elif x_m <= 1.55e+34:
		tmp = 1.0
	elif x_m <= 5e+45:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	tmp = 0.0
	if (x_m <= 4e-30)
		tmp = -1.0;
	elseif (x_m <= 1.55e+34)
		tmp = 1.0;
	elseif (x_m <= 5e+45)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
x_m = abs(x);
y_m = abs(y);
function tmp_2 = code(x_m, y_m)
	tmp = 0.0;
	if (x_m <= 4e-30)
		tmp = -1.0;
	elseif (x_m <= 1.55e+34)
		tmp = 1.0;
	elseif (x_m <= 5e+45)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
y_m = N[Abs[y], $MachinePrecision]
code[x$95$m_, y$95$m_] := If[LessEqual[x$95$m, 4e-30], -1.0, If[LessEqual[x$95$m, 1.55e+34], 1.0, If[LessEqual[x$95$m, 5e+45], -1.0, 1.0]]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 4 \cdot 10^{-30}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x\_m \leq 1.55 \cdot 10^{+34}:\\
\;\;\;\;1\\

\mathbf{elif}\;x\_m \leq 5 \cdot 10^{+45}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4e-30 or 1.54999999999999989e34 < x < 5e45

    1. Initial program 54.0%

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

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

    if 4e-30 < x < 1.54999999999999989e34 or 5e45 < x

    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. Add Preprocessing
    3. Taylor expanded in x around inf 80.3%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 50.4% accurate, 19.0× speedup?

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

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

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

    \[\leadsto \color{blue}{-1} \]
  4. Add Preprocessing

Developer target: 51.6% 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 2024089 
(FPCore (x y)
  :name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
  :precision binary64

  :alt
  (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))))