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

Percentage Accurate: 50.6% → 99.9%
Time: 12.8s
Alternatives: 11
Speedup: 2.6×

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 11 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.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.0× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\ \frac{\mathsf{fma}\left(y, 2, x\right)}{t_0 \cdot \frac{t_0}{\mathsf{fma}\left(y, -2, x\right)}} \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (hypot x (* y 2.0))))
   (/ (fma y 2.0 x) (* t_0 (/ t_0 (fma y -2.0 x))))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double t_0 = hypot(x, (y * 2.0));
	return fma(y, 2.0, x) / (t_0 * (t_0 / fma(y, -2.0, x)));
}
x = abs(x)
y = abs(y)
function code(x, y)
	t_0 = hypot(x, Float64(y * 2.0))
	return Float64(fma(y, 2.0, x) / Float64(t_0 * Float64(t_0 / fma(y, -2.0, x))))
end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(y * 2.0 + x), $MachinePrecision] / N[(t$95$0 * N[(t$95$0 / N[(y * -2.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\mathsf{fma}\left(y, 2, x\right)}{t_0 \cdot \frac{t_0}{\mathsf{fma}\left(y, -2, x\right)}}
\end{array}
\end{array}
Derivation
  1. Initial program 53.1%

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Step-by-step derivation
    1. add-sqr-sqrt53.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-squares53.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. *-commutative53.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*53.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-prod53.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-prod26.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-sqrt39.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-eval39.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. *-commutative39.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*39.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-prod39.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-prod26.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-sqrt53.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-eval53.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} \]
  3. Applied egg-rr53.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} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt53.1%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - y \cdot 2\right)}{\color{blue}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}}} \]
    2. times-frac54.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. +-commutative54.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-def54.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \sqrt[3]{{\left(\frac{x - \color{blue}{2 \cdot y}}{\mathsf{hypot}\left(x, y \cdot 2\right)}\right)}^{3}} \]
    4. cancel-sign-sub-inv100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.9% accurate, 0.1× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\ \frac{\mathsf{fma}\left(y, 2, x\right)}{t_0} \cdot \frac{x - y \cdot 2}{t_0} \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (hypot x (* y 2.0))))
   (* (/ (fma y 2.0 x) t_0) (/ (- x (* y 2.0)) t_0))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double t_0 = hypot(x, (y * 2.0));
	return (fma(y, 2.0, x) / t_0) * ((x - (y * 2.0)) / t_0);
}
x = abs(x)
y = abs(y)
function code(x, y)
	t_0 = hypot(x, Float64(y * 2.0))
	return Float64(Float64(fma(y, 2.0, x) / t_0) * Float64(Float64(x - Float64(y * 2.0)) / t_0))
end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(y * 2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\mathsf{fma}\left(y, 2, x\right)}{t_0} \cdot \frac{x - y \cdot 2}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 53.1%

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Step-by-step derivation
    1. add-sqr-sqrt53.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-squares53.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. *-commutative53.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*53.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-prod53.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-prod26.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-sqrt39.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-eval39.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. *-commutative39.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*39.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-prod39.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-prod26.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-sqrt53.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-eval53.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} \]
  3. Applied egg-rr53.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} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt53.1%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - y \cdot 2\right)}{\color{blue}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}}} \]
    2. times-frac54.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. +-commutative54.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-def54.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.9% accurate, 0.1× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\ \frac{\frac{\mathsf{fma}\left(y, 2, x\right)}{t_0} \cdot \left(x - y \cdot 2\right)}{t_0} \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (hypot x (* y 2.0))))
   (/ (* (/ (fma y 2.0 x) t_0) (- x (* y 2.0))) t_0)))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double t_0 = hypot(x, (y * 2.0));
	return ((fma(y, 2.0, x) / t_0) * (x - (y * 2.0))) / t_0;
}
x = abs(x)
y = abs(y)
function code(x, y)
	t_0 = hypot(x, Float64(y * 2.0))
	return Float64(Float64(Float64(fma(y, 2.0, x) / t_0) * Float64(x - Float64(y * 2.0))) / t_0)
end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(N[(y * 2.0 + x), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
\frac{\frac{\mathsf{fma}\left(y, 2, x\right)}{t_0} \cdot \left(x - y \cdot 2\right)}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 53.1%

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Step-by-step derivation
    1. add-sqr-sqrt53.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-squares53.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. *-commutative53.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*53.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-prod53.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-prod26.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-sqrt39.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-eval39.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. *-commutative39.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*39.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-prod39.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-prod26.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-sqrt53.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-eval53.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} \]
  3. Applied egg-rr53.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} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt53.1%

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - y \cdot 2\right)}{\color{blue}{\sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt{x \cdot x + \left(y \cdot 4\right) \cdot y}}} \]
    2. times-frac54.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. +-commutative54.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-def54.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 82.8% accurate, 0.1× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} t_0 := \frac{y}{x} \cdot \frac{y}{x}\\ \mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-267}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+261}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, 2, x\right)}{\frac{\mathsf{fma}\left(x, x, \left(y \cdot y\right) \cdot 4\right)}{x - y \cdot 2}}\\ \mathbf{else}:\\ \;\;\;\;-4 \cdot t_0 + \mathsf{fma}\left(-4, t_0, 1\right)\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (/ y x) (/ y x))))
   (if (<= (* x x) 2e-267)
     (fma 0.5 (* (/ x y) (/ x y)) -1.0)
     (if (<= (* x x) 2e+261)
       (/ (fma y 2.0 x) (/ (fma x x (* (* y y) 4.0)) (- x (* y 2.0))))
       (+ (* -4.0 t_0) (fma -4.0 t_0 1.0))))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double t_0 = (y / x) * (y / x);
	double tmp;
	if ((x * x) <= 2e-267) {
		tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
	} else if ((x * x) <= 2e+261) {
		tmp = fma(y, 2.0, x) / (fma(x, x, ((y * y) * 4.0)) / (x - (y * 2.0)));
	} else {
		tmp = (-4.0 * t_0) + fma(-4.0, t_0, 1.0);
	}
	return tmp;
}
x = abs(x)
y = abs(y)
function code(x, y)
	t_0 = Float64(Float64(y / x) * Float64(y / x))
	tmp = 0.0
	if (Float64(x * x) <= 2e-267)
		tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0);
	elseif (Float64(x * x) <= 2e+261)
		tmp = Float64(fma(y, 2.0, x) / Float64(fma(x, x, Float64(Float64(y * y) * 4.0)) / Float64(x - Float64(y * 2.0))));
	else
		tmp = Float64(Float64(-4.0 * t_0) + fma(-4.0, t_0, 1.0));
	end
	return tmp
end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 2e-267], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+261], N[(N[(y * 2.0 + x), $MachinePrecision] / N[(N[(x * x + N[(N[(y * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] / N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * t$95$0), $MachinePrecision] + N[(-4.0 * t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := \frac{y}{x} \cdot \frac{y}{x}\\
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{-267}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+261}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, 2, x\right)}{\frac{\mathsf{fma}\left(x, x, \left(y \cdot y\right) \cdot 4\right)}{x - y \cdot 2}}\\

\mathbf{else}:\\
\;\;\;\;-4 \cdot t_0 + \mathsf{fma}\left(-4, t_0, 1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 2e-267

    1. Initial program 57.5%

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

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

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

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

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

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

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

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

    if 2e-267 < (*.f64 x x) < 1.9999999999999999e261

    1. Initial program 82.8%

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

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

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

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

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

        \[\leadsto \frac{\left(x + \color{blue}{\sqrt{y \cdot y} \cdot \sqrt{4}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      6. sqrt-prod42.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-sqrt71.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-eval71.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. *-commutative71.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*71.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-prod71.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-prod42.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-sqrt82.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{x - y \cdot 2}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u99.9%

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\mathsf{fma}\left(y, 2, x\right)}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \frac{x - y \cdot 2}{\mathsf{hypot}\left(x, y \cdot 2\right)}\right)} - 1} \]
      3. frac-times82.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\mathsf{fma}\left(y, 2, x\right) \cdot \left(x - y \cdot 2\right)}{\mathsf{hypot}\left(x, y \cdot 2\right) \cdot \mathsf{hypot}\left(x, y \cdot 2\right)}}\right)} - 1 \]
      4. hypot-udef82.8%

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\mathsf{fma}\left(y, 2, x\right) \cdot \left(x - y \cdot 2\right)}{\sqrt{x \cdot x + \left(y \cdot 2\right) \cdot \left(y \cdot 2\right)} \cdot \color{blue}{\sqrt{x \cdot x + \left(y \cdot 2\right) \cdot \left(y \cdot 2\right)}}}\right)} - 1 \]
      6. add-sqr-sqrt82.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\mathsf{fma}\left(y, 2, x\right) \cdot \left(x - y \cdot 2\right)}{\color{blue}{x \cdot x + \left(y \cdot 2\right) \cdot \left(y \cdot 2\right)}}\right)} - 1 \]
      7. fma-def82.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\mathsf{fma}\left(y, 2, x\right) \cdot \left(x - y \cdot 2\right)}{\color{blue}{\mathsf{fma}\left(x, x, \left(y \cdot 2\right) \cdot \left(y \cdot 2\right)\right)}}\right)} - 1 \]
    7. Applied egg-rr82.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\mathsf{fma}\left(y, 2, x\right) \cdot \left(x - y \cdot 2\right)}{\mathsf{fma}\left(x, x, \left(y \cdot 2\right) \cdot \left(y \cdot 2\right)\right)}\right)} - 1} \]
    8. Step-by-step derivation
      1. expm1-def82.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\mathsf{fma}\left(y, 2, x\right) \cdot \left(x - y \cdot 2\right)}{\mathsf{fma}\left(x, x, \left(y \cdot 2\right) \cdot \left(y \cdot 2\right)\right)}\right)\right)} \]
      2. expm1-log1p82.8%

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

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

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

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

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

    if 1.9999999999999999e261 < (*.f64 x x)

    1. Initial program 9.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt9.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-squares9.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. *-commutative9.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*9.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-prod9.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-prod6.4%

        \[\leadsto \frac{\left(x + \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      7. add-sqr-sqrt9.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-eval9.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. *-commutative9.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*9.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-prod9.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-prod6.4%

        \[\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-sqrt9.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-eval9.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} \]
    3. Applied egg-rr9.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} \]
    4. Taylor expanded in x around inf 78.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot {\left(\frac{y}{x}\right)}^{2} + \left(1 + \left(\color{blue}{0} + -4 \cdot \frac{{y}^{2}}{{x}^{2}}\right)\right) \]
      12. associate-+r+78.4%

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

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

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

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

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

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

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

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

Alternative 5: 82.4% accurate, 0.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;-4 \cdot t_0 + \mathsf{fma}\left(-4, t_0, 1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 4.9999999999999998e-281

    1. Initial program 55.7%

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

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

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

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

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

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

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

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

    if 4.9999999999999998e-281 < (*.f64 x x) < 1.9999999999999999e261

    1. Initial program 83.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. add-sqr-sqrt83.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-squares83.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. *-commutative83.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*83.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-prod83.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-prod42.4%

        \[\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-sqrt70.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-eval70.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. *-commutative70.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*70.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-prod70.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-prod42.4%

        \[\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-sqrt83.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-eval83.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} \]
    3. Applied egg-rr83.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} \]

    if 1.9999999999999999e261 < (*.f64 x x)

    1. Initial program 9.0%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt9.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-squares9.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. *-commutative9.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*9.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-prod9.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-prod6.4%

        \[\leadsto \frac{\left(x + \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      7. add-sqr-sqrt9.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-eval9.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. *-commutative9.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*9.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-prod9.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-prod6.4%

        \[\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-sqrt9.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-eval9.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} \]
    3. Applied egg-rr9.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} \]
    4. Taylor expanded in x around inf 78.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot {\left(\frac{y}{x}\right)}^{2} + \left(1 + \left(\color{blue}{0} + -4 \cdot \frac{{y}^{2}}{{x}^{2}}\right)\right) \]
      12. associate-+r+78.4%

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

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

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

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

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

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

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

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

Alternative 6: 82.4% accurate, 0.2× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 6.5 \cdot 10^{-141}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+131}:\\ \;\;\;\;\frac{\left(x - y \cdot 2\right) \cdot \left(x + y \cdot 2\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot -8\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (if (<= x 6.5e-141)
   (fma 0.5 (* (/ x y) (/ x y)) -1.0)
   (if (<= x 1.7e+131)
     (/ (* (- x (* y 2.0)) (+ x (* y 2.0))) (+ (* x x) (* y (* y 4.0))))
     (+ 1.0 (* (* (/ y x) (/ y x)) -8.0)))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double tmp;
	if (x <= 6.5e-141) {
		tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
	} else if (x <= 1.7e+131) {
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((x * x) + (y * (y * 4.0)));
	} else {
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0);
	}
	return tmp;
}
x = abs(x)
y = abs(y)
function code(x, y)
	tmp = 0.0
	if (x <= 6.5e-141)
		tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0);
	elseif (x <= 1.7e+131)
		tmp = Float64(Float64(Float64(x - Float64(y * 2.0)) * Float64(x + Float64(y * 2.0))) / Float64(Float64(x * x) + Float64(y * Float64(y * 4.0))));
	else
		tmp = Float64(1.0 + Float64(Float64(Float64(y / x) * Float64(y / x)) * -8.0));
	end
	return tmp
end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := If[LessEqual[x, 6.5e-141], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 1.7e+131], N[(N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.5 \cdot 10^{-141}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 6.4999999999999995e-141

    1. Initial program 51.2%

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

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

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

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

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

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

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

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

    if 6.4999999999999995e-141 < x < 1.69999999999999993e131

    1. Initial program 81.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. add-sqr-sqrt81.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-squares81.4%

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

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

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

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

        \[\leadsto \frac{\left(x + \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      7. add-sqr-sqrt66.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-eval66.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. *-commutative66.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*66.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-prod66.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-prod42.3%

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

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

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

      \[\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 1.69999999999999993e131 < x

    1. Initial program 16.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 82.2% accurate, 0.7× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-281}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+261}:\\ \;\;\;\;\frac{x \cdot x - t_0}{x \cdot x + t_0}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot -8\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* y 4.0))))
   (if (<= (* x x) 5e-281)
     -1.0
     (if (<= (* x x) 2e+261)
       (/ (- (* x x) t_0) (+ (* x x) t_0))
       (+ 1.0 (* (* (/ y x) (/ y x)) -8.0))))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double tmp;
	if ((x * x) <= 5e-281) {
		tmp = -1.0;
	} else if ((x * x) <= 2e+261) {
		tmp = ((x * x) - t_0) / ((x * x) + t_0);
	} else {
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y * (y * 4.0d0)
    if ((x * x) <= 5d-281) then
        tmp = -1.0d0
    else if ((x * x) <= 2d+261) then
        tmp = ((x * x) - t_0) / ((x * x) + t_0)
    else
        tmp = 1.0d0 + (((y / x) * (y / x)) * (-8.0d0))
    end if
    code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double tmp;
	if ((x * x) <= 5e-281) {
		tmp = -1.0;
	} else if ((x * x) <= 2e+261) {
		tmp = ((x * x) - t_0) / ((x * x) + t_0);
	} else {
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0);
	}
	return tmp;
}
x = abs(x)
y = abs(y)
def code(x, y):
	t_0 = y * (y * 4.0)
	tmp = 0
	if (x * x) <= 5e-281:
		tmp = -1.0
	elif (x * x) <= 2e+261:
		tmp = ((x * x) - t_0) / ((x * x) + t_0)
	else:
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0)
	return tmp
x = abs(x)
y = abs(y)
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	tmp = 0.0
	if (Float64(x * x) <= 5e-281)
		tmp = -1.0;
	elseif (Float64(x * x) <= 2e+261)
		tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0));
	else
		tmp = Float64(1.0 + Float64(Float64(Float64(y / x) * Float64(y / x)) * -8.0));
	end
	return tmp
end
x = abs(x)
y = abs(y)
function tmp_2 = code(x, y)
	t_0 = y * (y * 4.0);
	tmp = 0.0;
	if ((x * x) <= 5e-281)
		tmp = -1.0;
	elseif ((x * x) <= 2e+261)
		tmp = ((x * x) - t_0) / ((x * x) + t_0);
	else
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e-281], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 2e+261], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-281}:\\
\;\;\;\;-1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 4.9999999999999998e-281

    1. Initial program 55.7%

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

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

    if 4.9999999999999998e-281 < (*.f64 x x) < 1.9999999999999999e261

    1. Initial program 83.3%

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

    if 1.9999999999999999e261 < (*.f64 x x)

    1. Initial program 9.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 82.2% accurate, 0.8× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 6.5 \cdot 10^{-141}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+130}:\\ \;\;\;\;\frac{\left(x - y \cdot 2\right) \cdot \left(x + y \cdot 2\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot -8\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (if (<= x 6.5e-141)
   -1.0
   (if (<= x 4.6e+130)
     (/ (* (- x (* y 2.0)) (+ x (* y 2.0))) (+ (* x x) (* y (* y 4.0))))
     (+ 1.0 (* (* (/ y x) (/ y x)) -8.0)))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double tmp;
	if (x <= 6.5e-141) {
		tmp = -1.0;
	} else if (x <= 4.6e+130) {
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((x * x) + (y * (y * 4.0)));
	} else {
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= 6.5d-141) then
        tmp = -1.0d0
    else if (x <= 4.6d+130) then
        tmp = ((x - (y * 2.0d0)) * (x + (y * 2.0d0))) / ((x * x) + (y * (y * 4.0d0)))
    else
        tmp = 1.0d0 + (((y / x) * (y / x)) * (-8.0d0))
    end if
    code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
	double tmp;
	if (x <= 6.5e-141) {
		tmp = -1.0;
	} else if (x <= 4.6e+130) {
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((x * x) + (y * (y * 4.0)));
	} else {
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0);
	}
	return tmp;
}
x = abs(x)
y = abs(y)
def code(x, y):
	tmp = 0
	if x <= 6.5e-141:
		tmp = -1.0
	elif x <= 4.6e+130:
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((x * x) + (y * (y * 4.0)))
	else:
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0)
	return tmp
x = abs(x)
y = abs(y)
function code(x, y)
	tmp = 0.0
	if (x <= 6.5e-141)
		tmp = -1.0;
	elseif (x <= 4.6e+130)
		tmp = Float64(Float64(Float64(x - Float64(y * 2.0)) * Float64(x + Float64(y * 2.0))) / Float64(Float64(x * x) + Float64(y * Float64(y * 4.0))));
	else
		tmp = Float64(1.0 + Float64(Float64(Float64(y / x) * Float64(y / x)) * -8.0));
	end
	return tmp
end
x = abs(x)
y = abs(y)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 6.5e-141)
		tmp = -1.0;
	elseif (x <= 4.6e+130)
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((x * x) + (y * (y * 4.0)));
	else
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := If[LessEqual[x, 6.5e-141], -1.0, If[LessEqual[x, 4.6e+130], N[(N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.5 \cdot 10^{-141}:\\
\;\;\;\;-1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 6.4999999999999995e-141

    1. Initial program 51.2%

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

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

    if 6.4999999999999995e-141 < x < 4.60000000000000042e130

    1. Initial program 81.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. add-sqr-sqrt81.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-squares81.4%

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

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

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

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

        \[\leadsto \frac{\left(x + \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      7. add-sqr-sqrt66.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-eval66.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. *-commutative66.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*66.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-prod66.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-prod42.3%

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

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

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

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

    if 4.60000000000000042e130 < x

    1. Initial program 16.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 74.4% accurate, 0.8× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-163}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-28} \lor \neg \left(x \cdot x \leq 10^{+37}\right):\\ \;\;\;\;1 + \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot -8\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (if (<= (* x x) 1e-163)
   -1.0
   (if (or (<= (* x x) 2e-28) (not (<= (* x x) 1e+37)))
     (+ 1.0 (* (* (/ y x) (/ y x)) -8.0))
     -1.0)))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double tmp;
	if ((x * x) <= 1e-163) {
		tmp = -1.0;
	} else if (((x * x) <= 2e-28) || !((x * x) <= 1e+37)) {
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0);
	} else {
		tmp = -1.0;
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x * x) <= 1d-163) then
        tmp = -1.0d0
    else if (((x * x) <= 2d-28) .or. (.not. ((x * x) <= 1d+37))) then
        tmp = 1.0d0 + (((y / x) * (y / x)) * (-8.0d0))
    else
        tmp = -1.0d0
    end if
    code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
	double tmp;
	if ((x * x) <= 1e-163) {
		tmp = -1.0;
	} else if (((x * x) <= 2e-28) || !((x * x) <= 1e+37)) {
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0);
	} else {
		tmp = -1.0;
	}
	return tmp;
}
x = abs(x)
y = abs(y)
def code(x, y):
	tmp = 0
	if (x * x) <= 1e-163:
		tmp = -1.0
	elif ((x * x) <= 2e-28) or not ((x * x) <= 1e+37):
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0)
	else:
		tmp = -1.0
	return tmp
x = abs(x)
y = abs(y)
function code(x, y)
	tmp = 0.0
	if (Float64(x * x) <= 1e-163)
		tmp = -1.0;
	elseif ((Float64(x * x) <= 2e-28) || !(Float64(x * x) <= 1e+37))
		tmp = Float64(1.0 + Float64(Float64(Float64(y / x) * Float64(y / x)) * -8.0));
	else
		tmp = -1.0;
	end
	return tmp
end
x = abs(x)
y = abs(y)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x * x) <= 1e-163)
		tmp = -1.0;
	elseif (((x * x) <= 2e-28) || ~(((x * x) <= 1e+37)))
		tmp = 1.0 + (((y / x) * (y / x)) * -8.0);
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e-163], -1.0, If[Or[LessEqual[N[(x * x), $MachinePrecision], 2e-28], N[Not[LessEqual[N[(x * x), $MachinePrecision], 1e+37]], $MachinePrecision]], N[(1.0 + N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision], -1.0]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{-163}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-28} \lor \neg \left(x \cdot x \leq 10^{+37}\right):\\
\;\;\;\;1 + \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot -8\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x x) < 9.99999999999999923e-164 or 1.99999999999999994e-28 < (*.f64 x x) < 9.99999999999999954e36

    1. Initial program 67.3%

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

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

    if 9.99999999999999923e-164 < (*.f64 x x) < 1.99999999999999994e-28 or 9.99999999999999954e36 < (*.f64 x x)

    1. Initial program 43.4%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-163}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-28} \lor \neg \left(x \cdot x \leq 10^{+37}\right):\\ \;\;\;\;1 + \left(\frac{y}{x} \cdot \frac{y}{x}\right) \cdot -8\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]

Alternative 10: 73.7% accurate, 2.6× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 6.6 \cdot 10^{-81}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-14}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+18}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (if (<= x 6.6e-81) -1.0 (if (<= x 6e-14) 1.0 (if (<= x 3e+18) -1.0 1.0))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double tmp;
	if (x <= 6.6e-81) {
		tmp = -1.0;
	} else if (x <= 6e-14) {
		tmp = 1.0;
	} else if (x <= 3e+18) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= 6.6d-81) then
        tmp = -1.0d0
    else if (x <= 6d-14) then
        tmp = 1.0d0
    else if (x <= 3d+18) then
        tmp = -1.0d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
	double tmp;
	if (x <= 6.6e-81) {
		tmp = -1.0;
	} else if (x <= 6e-14) {
		tmp = 1.0;
	} else if (x <= 3e+18) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
x = abs(x)
y = abs(y)
def code(x, y):
	tmp = 0
	if x <= 6.6e-81:
		tmp = -1.0
	elif x <= 6e-14:
		tmp = 1.0
	elif x <= 3e+18:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
x = abs(x)
y = abs(y)
function code(x, y)
	tmp = 0.0
	if (x <= 6.6e-81)
		tmp = -1.0;
	elseif (x <= 6e-14)
		tmp = 1.0;
	elseif (x <= 3e+18)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
x = abs(x)
y = abs(y)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 6.6e-81)
		tmp = -1.0;
	elseif (x <= 6e-14)
		tmp = 1.0;
	elseif (x <= 3e+18)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := If[LessEqual[x, 6.6e-81], -1.0, If[LessEqual[x, 6e-14], 1.0, If[LessEqual[x, 3e+18], -1.0, 1.0]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.6 \cdot 10^{-81}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq 6 \cdot 10^{-14}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 3 \cdot 10^{+18}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 6.59999999999999975e-81 or 5.9999999999999997e-14 < x < 3e18

    1. Initial program 54.5%

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

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

    if 6.59999999999999975e-81 < x < 5.9999999999999997e-14 or 3e18 < x

    1. Initial program 50.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.6 \cdot 10^{-81}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-14}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+18}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 11: 50.1% accurate, 19.0× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ -1 \end{array} \]
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
(FPCore (x y) :precision binary64 -1.0)
x = abs(x);
y = abs(y);
double code(double x, double y) {
	return -1.0;
}
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = -1.0d0
end function
x = Math.abs(x);
y = Math.abs(y);
public static double code(double x, double y) {
	return -1.0;
}
x = abs(x)
y = abs(y)
def code(x, y):
	return -1.0
x = abs(x)
y = abs(y)
function code(x, y)
	return -1.0
end
x = abs(x)
y = abs(y)
function tmp = code(x, y)
	tmp = -1.0;
end
NOTE: x should be positive before calling this function
NOTE: y should be positive before calling this function
code[x_, y_] := -1.0
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
-1
\end{array}
Derivation
  1. Initial program 53.1%

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

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

    \[\leadsto -1 \]

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

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

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