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

Percentage Accurate: 50.7% → 100.0%
Time: 10.1s
Alternatives: 9
Speedup: 3.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 9 alternatives:

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

Initial Program: 50.7% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(2 \cdot y\_m, x\_m\right)\\ \frac{\mathsf{fma}\left(2, y\_m, -x\_m\right)}{\frac{t\_0}{\mathsf{fma}\left(2, y\_m, x\_m\right)} \cdot \left(-t\_0\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 (* 2.0 y_m) x_m)))
   (/ (fma 2.0 y_m (- x_m)) (* (/ t_0 (fma 2.0 y_m x_m)) (- t_0)))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = hypot((2.0 * y_m), x_m);
	return fma(2.0, y_m, -x_m) / ((t_0 / fma(2.0, y_m, x_m)) * -t_0);
}
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = hypot(Float64(2.0 * y_m), x_m)
	return Float64(fma(2.0, y_m, Float64(-x_m)) / Float64(Float64(t_0 / fma(2.0, y_m, x_m)) * Float64(-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[N[(2.0 * y$95$m), $MachinePrecision] ^ 2 + x$95$m ^ 2], $MachinePrecision]}, N[(N[(2.0 * y$95$m + (-x$95$m)), $MachinePrecision] / N[(N[(t$95$0 / N[(2.0 * y$95$m + x$95$m), $MachinePrecision]), $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(2 \cdot y\_m, x\_m\right)\\
\frac{\mathsf{fma}\left(2, y\_m, -x\_m\right)}{\frac{t\_0}{\mathsf{fma}\left(2, y\_m, x\_m\right)} \cdot \left(-t\_0\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 45.7%

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

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

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

      \[\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*45.7%

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

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

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

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

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

      \[\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*35.2%

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

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

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

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

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

    \[\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. Applied egg-rr69.6%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{{\left({\left(\sqrt[3]{\mathsf{hypot}\left(y \cdot 2, x\right)}\right)}^{2}\right)}^{2}} \cdot \frac{x + y \cdot -2}{{\left(\sqrt[3]{\mathsf{hypot}\left(y \cdot 2, x\right)}\right)}^{2}}} \]
  6. Step-by-step derivation
    1. fma-undefine69.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(2, y, x\right)}{{\left(\sqrt[3]{\mathsf{hypot}\left(2 \cdot y, x\right)}\right)}^{4}} \cdot \frac{\mathsf{fma}\left(y, -2, x\right)}{{\left(\sqrt[3]{\mathsf{hypot}\left(2 \cdot y, x\right)}\right)}^{2}}} \]
  8. Step-by-step derivation
    1. fma-undefine69.6%

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

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

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

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

Alternative 2: 99.9% accurate, 0.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(2 \cdot y\_m, x\_m\right)\\ \frac{\mathsf{fma}\left(y\_m, 2, x\_m\right)}{t\_0} \cdot \frac{x\_m + y\_m \cdot -2}{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 (* 2.0 y_m) x_m)))
   (* (/ (fma y_m 2.0 x_m) t_0) (/ (+ x_m (* y_m -2.0)) t_0))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double t_0 = hypot((2.0 * y_m), x_m);
	return (fma(y_m, 2.0, x_m) / t_0) * ((x_m + (y_m * -2.0)) / t_0);
}
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	t_0 = hypot(Float64(2.0 * y_m), x_m)
	return Float64(Float64(fma(y_m, 2.0, x_m) / t_0) * Float64(Float64(x_m + Float64(y_m * -2.0)) / 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[N[(2.0 * y$95$m), $MachinePrecision] ^ 2 + x$95$m ^ 2], $MachinePrecision]}, N[(N[(N[(y$95$m * 2.0 + x$95$m), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(x$95$m + N[(y$95$m * -2.0), $MachinePrecision]), $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(2 \cdot y\_m, x\_m\right)\\
\frac{\mathsf{fma}\left(y\_m, 2, x\_m\right)}{t\_0} \cdot \frac{x\_m + y\_m \cdot -2}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 45.7%

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

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

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

      \[\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*45.7%

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

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

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

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

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

      \[\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*35.2%

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

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

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

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

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

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

      \[\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-frac47.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. +-commutative47.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-define47.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. +-commutative47.4%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(\color{blue}{y \cdot 2}, x\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(y \cdot 2, x\right)} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(y \cdot 2, x\right)}} \]
  7. Final simplification100.0%

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

Alternative 3: 91.9% accurate, 0.2× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 2.2 \cdot 10^{-164}:\\ \;\;\;\;0.5 \cdot \left(\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{x\_m}{\mathsf{hypot}\left(2 \cdot y\_m, x\_m\right)} \cdot \left(1 + \frac{y\_m \cdot -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
 (if (<= x_m 2.2e-164)
   (+ (* 0.5 (* (/ x_m y_m) (/ x_m y_m))) -1.0)
   (* (/ x_m (hypot (* 2.0 y_m) x_m)) (+ 1.0 (/ (* y_m -2.0) x_m)))))
x_m = fabs(x);
y_m = fabs(y);
double code(double x_m, double y_m) {
	double tmp;
	if (x_m <= 2.2e-164) {
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0;
	} else {
		tmp = (x_m / hypot((2.0 * y_m), x_m)) * (1.0 + ((y_m * -2.0) / x_m));
	}
	return tmp;
}
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 <= 2.2e-164) {
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0;
	} else {
		tmp = (x_m / Math.hypot((2.0 * y_m), x_m)) * (1.0 + ((y_m * -2.0) / x_m));
	}
	return tmp;
}
x_m = math.fabs(x)
y_m = math.fabs(y)
def code(x_m, y_m):
	tmp = 0
	if x_m <= 2.2e-164:
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0
	else:
		tmp = (x_m / math.hypot((2.0 * y_m), x_m)) * (1.0 + ((y_m * -2.0) / x_m))
	return tmp
x_m = abs(x)
y_m = abs(y)
function code(x_m, y_m)
	tmp = 0.0
	if (x_m <= 2.2e-164)
		tmp = Float64(Float64(0.5 * Float64(Float64(x_m / y_m) * Float64(x_m / y_m))) + -1.0);
	else
		tmp = Float64(Float64(x_m / hypot(Float64(2.0 * y_m), x_m)) * Float64(1.0 + Float64(Float64(y_m * -2.0) / x_m)));
	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 <= 2.2e-164)
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0;
	else
		tmp = (x_m / hypot((2.0 * y_m), x_m)) * (1.0 + ((y_m * -2.0) / 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_] := If[LessEqual[x$95$m, 2.2e-164], N[(N[(0.5 * N[(N[(x$95$m / y$95$m), $MachinePrecision] * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(x$95$m / N[Sqrt[N[(2.0 * y$95$m), $MachinePrecision] ^ 2 + x$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(y$95$m * -2.0), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 2.2 \cdot 10^{-164}:\\
\;\;\;\;0.5 \cdot \left(\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\right) + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.19999999999999988e-164

    1. Initial program 45.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} - 1 \]
      2. unpow248.6%

        \[\leadsto 0.5 \cdot \frac{x \cdot x}{\color{blue}{y \cdot y}} - 1 \]
      3. times-frac56.4%

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

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

    if 2.19999999999999988e-164 < x

    1. Initial program 46.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-sqrt46.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-squares46.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. *-commutative46.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*46.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-prod46.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-unprod16.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-sqrt39.9%

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

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

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

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

        \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \color{blue}{\sqrt{y \cdot y} \cdot \sqrt{4}}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      12. sqrt-unprod16.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-sqrt46.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-eval46.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-rr46.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-sqrt46.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-frac48.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(\color{blue}{y \cdot 2}, x\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(y \cdot 2, x\right)} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(y \cdot 2, x\right)}} \]
    7. Taylor expanded in x around inf 72.2%

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

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

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

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

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

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

Alternative 4: 80.6% accurate, 0.6× 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)\\ \mathbf{if}\;x\_m \cdot x\_m \leq 10^{-237}:\\ \;\;\;\;0.5 \cdot \left(\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\right) + -1\\ \mathbf{elif}\;x\_m \cdot x\_m \leq 2 \cdot 10^{+234}:\\ \;\;\;\;\frac{x\_m \cdot x\_m - t\_0}{x\_m \cdot x\_m + t\_0}\\ \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 (* y_m (* y_m 4.0))))
   (if (<= (* x_m x_m) 1e-237)
     (+ (* 0.5 (* (/ x_m y_m) (/ x_m y_m))) -1.0)
     (if (<= (* x_m x_m) 2e+234)
       (/ (- (* x_m x_m) t_0) (+ (* x_m x_m) t_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 = y_m * (y_m * 4.0);
	double tmp;
	if ((x_m * x_m) <= 1e-237) {
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0;
	} else if ((x_m * x_m) <= 2e+234) {
		tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_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 = y_m * (y_m * 4.0d0)
    if ((x_m * x_m) <= 1d-237) then
        tmp = (0.5d0 * ((x_m / y_m) * (x_m / y_m))) + (-1.0d0)
    else if ((x_m * x_m) <= 2d+234) then
        tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_0)
    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 = y_m * (y_m * 4.0);
	double tmp;
	if ((x_m * x_m) <= 1e-237) {
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0;
	} else if ((x_m * x_m) <= 2e+234) {
		tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_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 = y_m * (y_m * 4.0)
	tmp = 0
	if (x_m * x_m) <= 1e-237:
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0
	elif (x_m * x_m) <= 2e+234:
		tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_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(y_m * Float64(y_m * 4.0))
	tmp = 0.0
	if (Float64(x_m * x_m) <= 1e-237)
		tmp = Float64(Float64(0.5 * Float64(Float64(x_m / y_m) * Float64(x_m / y_m))) + -1.0);
	elseif (Float64(x_m * x_m) <= 2e+234)
		tmp = Float64(Float64(Float64(x_m * x_m) - t_0) / Float64(Float64(x_m * x_m) + t_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 = y_m * (y_m * 4.0);
	tmp = 0.0;
	if ((x_m * x_m) <= 1e-237)
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0;
	elseif ((x_m * x_m) <= 2e+234)
		tmp = ((x_m * x_m) - t_0) / ((x_m * x_m) + t_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[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 1e-237], N[(N[(0.5 * N[(N[(x$95$m / y$95$m), $MachinePrecision] * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x$95$m * x$95$m), $MachinePrecision], 2e+234], N[(N[(N[(x$95$m * x$95$m), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x$95$m * x$95$m), $MachinePrecision] + t$95$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 := y\_m \cdot \left(y\_m \cdot 4\right)\\
\mathbf{if}\;x\_m \cdot x\_m \leq 10^{-237}:\\
\;\;\;\;0.5 \cdot \left(\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\right) + -1\\

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

\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 3 regimes
  2. if (*.f64 x x) < 9.9999999999999999e-238

    1. Initial program 48.5%

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot x - \left(-y \cdot 4\right) \cdot \left(-y\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      4. distribute-lft-neg-out48.5%

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

        \[\leadsto \frac{x \cdot x - \left(\left(-y\right) \cdot 4\right) \cdot \left(-y\right)}{x \cdot x + \color{blue}{\left(-\left(-y \cdot 4\right)\right)} \cdot y} \]
      6. distribute-lft-neg-out48.5%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} - 1 \]
      2. unpow277.3%

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

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

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

    if 9.9999999999999999e-238 < (*.f64 x x) < 2.00000000000000004e234

    1. Initial program 71.9%

      \[\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 2.00000000000000004e234 < (*.f64 x x)

    1. Initial program 15.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-sqrt15.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-squares15.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. *-commutative15.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*15.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-prod15.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-unprod7.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-sqrt15.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-eval15.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. *-commutative15.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*15.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-prod15.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-unprod7.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-sqrt15.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-eval15.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-rr15.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} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt15.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(\color{blue}{y \cdot 2}, x\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(y \cdot 2, x\right)} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(y \cdot 2, x\right)}} \]
    7. Taylor expanded in x around inf 49.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-237}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right) + -1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+234}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\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 5: 80.6% accurate, 0.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 2 \cdot 10^{-118}:\\ \;\;\;\;0.5 \cdot \left(\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\right) + -1\\ \mathbf{elif}\;x\_m \leq 2.15 \cdot 10^{+120}:\\ \;\;\;\;\frac{\left(x\_m + 2 \cdot y\_m\right) \cdot \left(x\_m - 2 \cdot y\_m\right)}{x\_m \cdot x\_m + y\_m \cdot \left(y\_m \cdot 4\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
 (if (<= x_m 2e-118)
   (+ (* 0.5 (* (/ x_m y_m) (/ x_m y_m))) -1.0)
   (if (<= x_m 2.15e+120)
     (/
      (* (+ x_m (* 2.0 y_m)) (- x_m (* 2.0 y_m)))
      (+ (* x_m x_m) (* y_m (* y_m 4.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 tmp;
	if (x_m <= 2e-118) {
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0;
	} else if (x_m <= 2.15e+120) {
		tmp = ((x_m + (2.0 * y_m)) * (x_m - (2.0 * y_m))) / ((x_m * x_m) + (y_m * (y_m * 4.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) :: tmp
    if (x_m <= 2d-118) then
        tmp = (0.5d0 * ((x_m / y_m) * (x_m / y_m))) + (-1.0d0)
    else if (x_m <= 2.15d+120) then
        tmp = ((x_m + (2.0d0 * y_m)) * (x_m - (2.0d0 * y_m))) / ((x_m * x_m) + (y_m * (y_m * 4.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 tmp;
	if (x_m <= 2e-118) {
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0;
	} else if (x_m <= 2.15e+120) {
		tmp = ((x_m + (2.0 * y_m)) * (x_m - (2.0 * y_m))) / ((x_m * x_m) + (y_m * (y_m * 4.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):
	tmp = 0
	if x_m <= 2e-118:
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0
	elif x_m <= 2.15e+120:
		tmp = ((x_m + (2.0 * y_m)) * (x_m - (2.0 * y_m))) / ((x_m * x_m) + (y_m * (y_m * 4.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)
	tmp = 0.0
	if (x_m <= 2e-118)
		tmp = Float64(Float64(0.5 * Float64(Float64(x_m / y_m) * Float64(x_m / y_m))) + -1.0);
	elseif (x_m <= 2.15e+120)
		tmp = Float64(Float64(Float64(x_m + Float64(2.0 * y_m)) * Float64(x_m - Float64(2.0 * y_m))) / Float64(Float64(x_m * x_m) + Float64(y_m * Float64(y_m * 4.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)
	tmp = 0.0;
	if (x_m <= 2e-118)
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -1.0;
	elseif (x_m <= 2.15e+120)
		tmp = ((x_m + (2.0 * y_m)) * (x_m - (2.0 * y_m))) / ((x_m * x_m) + (y_m * (y_m * 4.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_] := If[LessEqual[x$95$m, 2e-118], N[(N[(0.5 * N[(N[(x$95$m / y$95$m), $MachinePrecision] * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x$95$m, 2.15e+120], N[(N[(N[(x$95$m + N[(2.0 * y$95$m), $MachinePrecision]), $MachinePrecision] * N[(x$95$m - N[(2.0 * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x$95$m * x$95$m), $MachinePrecision] + N[(y$95$m * N[(y$95$m * 4.0), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;x\_m \leq 2 \cdot 10^{-118}:\\
\;\;\;\;0.5 \cdot \left(\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\right) + -1\\

\mathbf{elif}\;x\_m \leq 2.15 \cdot 10^{+120}:\\
\;\;\;\;\frac{\left(x\_m + 2 \cdot y\_m\right) \cdot \left(x\_m - 2 \cdot y\_m\right)}{x\_m \cdot x\_m + y\_m \cdot \left(y\_m \cdot 4\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 3 regimes
  2. if x < 1.99999999999999997e-118

    1. Initial program 44.9%

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

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

        \[\leadsto \frac{x \cdot x + \color{blue}{\left(y \cdot 4\right) \cdot \left(-y\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      3. cancel-sign-sub44.9%

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

        \[\leadsto \frac{x \cdot x - \color{blue}{\left(\left(-y\right) \cdot 4\right)} \cdot \left(-y\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      5. remove-double-neg44.9%

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} - 1 \]
      2. unpow250.6%

        \[\leadsto 0.5 \cdot \frac{x \cdot x}{\color{blue}{y \cdot y}} - 1 \]
      3. times-frac57.9%

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

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

    if 1.99999999999999997e-118 < x < 2.1500000000000001e120

    1. Initial program 77.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-sqrt77.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-squares77.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. *-commutative77.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*77.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-prod77.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-unprod29.1%

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

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

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

        \[\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*66.8%

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

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

        \[\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-sqrt77.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-eval77.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-rr77.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} \]

    if 2.1500000000000001e120 < x

    1. Initial program 18.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-sqrt18.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-squares18.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. *-commutative18.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*18.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-prod18.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-unprod4.0%

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

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

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

        \[\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*18.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-prod18.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-unprod4.0%

        \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      13. add-sqr-sqrt18.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-eval18.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-rr18.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-sqrt18.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-frac20.6%

        \[\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. +-commutative20.6%

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

        \[\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. +-commutative20.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(\color{blue}{y \cdot 2}, x\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(y \cdot 2, x\right)} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(y \cdot 2, x\right)}} \]
    7. Taylor expanded in x around inf 87.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{-118}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right) + -1\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{+120}:\\ \;\;\;\;\frac{\left(x + 2 \cdot y\right) \cdot \left(x - 2 \cdot y\right)}{x \cdot x + y \cdot \left(y \cdot 4\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 6: 72.8% accurate, 0.9× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 3.3 \cdot 10^{-96}:\\ \;\;\;\;0.5 \cdot \left(\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\right) + -1\\ \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
 (if (<= x_m 3.3e-96)
   (+ (* 0.5 (* (/ x_m y_m) (/ x_m y_m))) -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 tmp;
	if (x_m <= 3.3e-96) {
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -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) :: tmp
    if (x_m <= 3.3d-96) then
        tmp = (0.5d0 * ((x_m / y_m) * (x_m / y_m))) + (-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 tmp;
	if (x_m <= 3.3e-96) {
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -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):
	tmp = 0
	if x_m <= 3.3e-96:
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -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)
	tmp = 0.0
	if (x_m <= 3.3e-96)
		tmp = Float64(Float64(0.5 * Float64(Float64(x_m / y_m) * Float64(x_m / y_m))) + -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)
	tmp = 0.0;
	if (x_m <= 3.3e-96)
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -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_] := If[LessEqual[x$95$m, 3.3e-96], N[(N[(0.5 * N[(N[(x$95$m / y$95$m), $MachinePrecision] * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $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}
\mathbf{if}\;x\_m \leq 3.3 \cdot 10^{-96}:\\
\;\;\;\;0.5 \cdot \left(\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\right) + -1\\

\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 < 3.2999999999999999e-96

    1. Initial program 46.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
    6. Step-by-step derivation
      1. pow250.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} - 1 \]
      2. unpow250.7%

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

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

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

    if 3.2999999999999999e-96 < x

    1. Initial program 44.7%

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

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

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

        \[\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*44.7%

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

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

        \[\leadsto \frac{\left(x + \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      7. add-sqr-sqrt41.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-eval41.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. *-commutative41.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*41.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-prod41.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-unprod17.0%

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

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

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

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

        \[\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-frac46.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. +-commutative46.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-define46.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. +-commutative46.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(\color{blue}{y \cdot 2}, x\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(y \cdot 2, x\right)} \cdot \frac{x + y \cdot -2}{\mathsf{hypot}\left(y \cdot 2, x\right)}} \]
    7. Taylor expanded in x around inf 78.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.3 \cdot 10^{-96}:\\ \;\;\;\;0.5 \cdot \left(\frac{x}{y} \cdot \frac{x}{y}\right) + -1\\ \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 7: 72.2% 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 7.4 \cdot 10^{-98}:\\ \;\;\;\;0.5 \cdot \left(\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\right) + -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 7.4e-98) (+ (* 0.5 (* (/ x_m y_m) (/ x_m y_m))) -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 <= 7.4e-98) {
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -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 <= 7.4d-98) then
        tmp = (0.5d0 * ((x_m / y_m) * (x_m / y_m))) + (-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 <= 7.4e-98) {
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -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 <= 7.4e-98:
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -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 <= 7.4e-98)
		tmp = Float64(Float64(0.5 * Float64(Float64(x_m / y_m) * Float64(x_m / y_m))) + -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 <= 7.4e-98)
		tmp = (0.5 * ((x_m / y_m) * (x_m / y_m))) + -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, 7.4e-98], N[(N[(0.5 * N[(N[(x$95$m / y$95$m), $MachinePrecision] * N[(x$95$m / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], 1.0]
\begin{array}{l}
x_m = \left|x\right|
\\
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 7.4 \cdot 10^{-98}:\\
\;\;\;\;0.5 \cdot \left(\frac{x\_m}{y\_m} \cdot \frac{x\_m}{y\_m}\right) + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 7.400000000000001e-98

    1. Initial program 46.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
    6. Step-by-step derivation
      1. pow250.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} - 1 \]
      2. unpow250.7%

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

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

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

    if 7.400000000000001e-98 < x

    1. Initial program 44.7%

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

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

        \[\leadsto \frac{x \cdot x + \color{blue}{\left(y \cdot 4\right) \cdot \left(-y\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      3. cancel-sign-sub44.7%

        \[\leadsto \frac{\color{blue}{x \cdot x - \left(-y \cdot 4\right) \cdot \left(-y\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      4. distribute-lft-neg-out44.7%

        \[\leadsto \frac{x \cdot x - \color{blue}{\left(\left(-y\right) \cdot 4\right)} \cdot \left(-y\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      5. remove-double-neg44.7%

        \[\leadsto \frac{x \cdot x - \left(\left(-y\right) \cdot 4\right) \cdot \left(-y\right)}{x \cdot x + \color{blue}{\left(-\left(-y \cdot 4\right)\right)} \cdot y} \]
      6. distribute-lft-neg-out44.7%

        \[\leadsto \frac{x \cdot x - \left(\left(-y\right) \cdot 4\right) \cdot \left(-y\right)}{x \cdot x + \left(-\color{blue}{\left(-y\right) \cdot 4}\right) \cdot y} \]
      7. distribute-lft-neg-in44.7%

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

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

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

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

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

Alternative 8: 71.5% accurate, 3.2× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x\_m \leq 1.3 \cdot 10^{-105}:\\ \;\;\;\;-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 1.3e-105) -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 <= 1.3e-105) {
		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 <= 1.3d-105) 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 <= 1.3e-105) {
		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 <= 1.3e-105:
		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 <= 1.3e-105)
		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 <= 1.3e-105)
		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, 1.3e-105], -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 1.3 \cdot 10^{-105}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.2999999999999999e-105

    1. Initial program 45.9%

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

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

        \[\leadsto \frac{x \cdot x + \color{blue}{\left(y \cdot 4\right) \cdot \left(-y\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      3. cancel-sign-sub45.9%

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

        \[\leadsto \frac{x \cdot x - \color{blue}{\left(\left(-y\right) \cdot 4\right)} \cdot \left(-y\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      5. remove-double-neg45.9%

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

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

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

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

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

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

    if 1.2999999999999999e-105 < x

    1. Initial program 45.3%

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 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 45.7%

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

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

      \[\leadsto \frac{x \cdot x + \color{blue}{\left(y \cdot 4\right) \cdot \left(-y\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    3. cancel-sign-sub45.7%

      \[\leadsto \frac{\color{blue}{x \cdot x - \left(-y \cdot 4\right) \cdot \left(-y\right)}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    4. distribute-lft-neg-out45.7%

      \[\leadsto \frac{x \cdot x - \color{blue}{\left(\left(-y\right) \cdot 4\right)} \cdot \left(-y\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    5. remove-double-neg45.7%

      \[\leadsto \frac{x \cdot x - \left(\left(-y\right) \cdot 4\right) \cdot \left(-y\right)}{x \cdot x + \color{blue}{\left(-\left(-y \cdot 4\right)\right)} \cdot y} \]
    6. distribute-lft-neg-out45.7%

      \[\leadsto \frac{x \cdot x - \left(\left(-y\right) \cdot 4\right) \cdot \left(-y\right)}{x \cdot x + \left(-\color{blue}{\left(-y\right) \cdot 4}\right) \cdot y} \]
    7. distribute-lft-neg-in45.7%

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

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

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

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

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

  :alt
  (! :herbie-platform default (if (< (/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))) 9743233849626781/10000000000000000) (- (/ (* x x) (+ (* x x) (* (* y y) 4))) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4)))) 2) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4))))))

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