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

Percentage Accurate: 50.4% → 99.9%
Time: 8.3s
Alternatives: 12
Speedup: 6.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 50.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.1× speedup?

\[\begin{array}{l} 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)}{\frac{t_0}{\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(fma(y, 2.0, x) / Float64(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[(y * 2.0 + x), $MachinePrecision] / N[(t$95$0 / N[(N[(x + N[(y * -2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $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)}{\frac{t_0}{\frac{x + y \cdot -2}{t_0}}}
\end{array}
\end{array}
Derivation
  1. Initial program 52.9%

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

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

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

      \[\leadsto \frac{\left(x + \sqrt{\color{blue}{\left(4 \cdot y\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} \]
    4. associate-*r*52.7%

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

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

      \[\leadsto \frac{\left(x + \color{blue}{\sqrt{y \cdot y} \cdot \sqrt{4}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    7. sqrt-prod27.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} \]
    8. add-sqr-sqrt39.1%

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

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

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

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{4 \cdot \left(y \cdot y\right)}}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    12. *-commutative39.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} \]
    13. 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} \]
    14. sqrt-prod27.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} \]
    15. add-sqr-sqrt52.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. *-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)}} \]
    2. clear-num99.9%

      \[\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)} \]
    3. 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)}} \]
    4. *-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)} \]
  7. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{\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)}} \]
  8. Step-by-step derivation
    1. *-commutative100.0%

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

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

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

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

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

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

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

    \[\leadsto \frac{\mathsf{fma}\left(y, 2, x\right)}{\frac{\mathsf{hypot}\left(x, y \cdot 2\right)}{\frac{x + y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\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 52.9%

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

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

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

      \[\leadsto \frac{\left(x + \sqrt{\color{blue}{\left(4 \cdot y\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} \]
    4. associate-*r*52.7%

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

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

      \[\leadsto \frac{\left(x + \color{blue}{\sqrt{y \cdot y} \cdot \sqrt{4}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    7. sqrt-prod27.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} \]
    8. add-sqr-sqrt39.1%

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

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

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

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{4 \cdot \left(y \cdot y\right)}}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    12. *-commutative39.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} \]
    13. 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} \]
    14. sqrt-prod27.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} \]
    15. add-sqr-sqrt52.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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{\mathsf{fma}\left(y, 2, x\right)}{t_0 \cdot \frac{t_0}{x - y \cdot 2}} \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 (- x (* y 2.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 * (t_0 / (x - (y * 2.0))));
}
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 / Float64(x - Float64(y * 2.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[(y * 2.0 + x), $MachinePrecision] / N[(t$95$0 * N[(t$95$0 / N[(x - N[(y * 2.0), $MachinePrecision]), $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}{x - y \cdot 2}}
\end{array}
\end{array}
Derivation
  1. Initial program 52.9%

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

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

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

      \[\leadsto \frac{\left(x + \sqrt{\color{blue}{\left(4 \cdot y\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} \]
    4. associate-*r*52.7%

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

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

      \[\leadsto \frac{\left(x + \color{blue}{\sqrt{y \cdot y} \cdot \sqrt{4}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    7. sqrt-prod27.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} \]
    8. add-sqr-sqrt39.1%

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

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

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

      \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{4 \cdot \left(y \cdot y\right)}}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    12. *-commutative39.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} \]
    13. 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} \]
    14. sqrt-prod27.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} \]
    15. add-sqr-sqrt52.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. *-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)}} \]
    2. clear-num99.9%

      \[\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)} \]
    3. 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)}} \]
    4. *-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)} \]
  7. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{\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)}} \]
  8. 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)}{x - y \cdot 2}} \]

Alternative 4: 80.1% accurate, 0.1× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ \mathbf{if}\;t_0 \leq 10^{-218}:\\ \;\;\;\;1 + \left(e^{\mathsf{log1p}\left({\left(\frac{y}{x}\right)}^{2}\right)} + -1\right) \cdot -8\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+110}:\\ \;\;\;\;\frac{\left(x - y \cdot 2\right) \cdot \left(x + y \cdot 2\right)}{t_0 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -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 (* y 4.0))))
   (if (<= t_0 1e-218)
     (+ 1.0 (* (+ (exp (log1p (pow (/ y x) 2.0))) -1.0) -8.0))
     (if (<= t_0 5e+110)
       (/ (* (- x (* y 2.0)) (+ x (* y 2.0))) (+ t_0 (* x x)))
       (fma 0.5 (* (/ x y) (/ x y)) -1.0)))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double tmp;
	if (t_0 <= 1e-218) {
		tmp = 1.0 + ((exp(log1p(pow((y / x), 2.0))) + -1.0) * -8.0);
	} else if (t_0 <= 5e+110) {
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x));
	} else {
		tmp = fma(0.5, ((x / y) * (x / y)), -1.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 (t_0 <= 1e-218)
		tmp = Float64(1.0 + Float64(Float64(exp(log1p((Float64(y / x) ^ 2.0))) + -1.0) * -8.0));
	elseif (t_0 <= 5e+110)
		tmp = Float64(Float64(Float64(x - Float64(y * 2.0)) * Float64(x + Float64(y * 2.0))) / Float64(t_0 + Float64(x * x)));
	else
		tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -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[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-218], N[(1.0 + N[(N[(N[Exp[N[Log[1 + N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+110], N[(N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 10^{-218}:\\
\;\;\;\;1 + \left(e^{\mathsf{log1p}\left({\left(\frac{y}{x}\right)}^{2}\right)} + -1\right) \cdot -8\\

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

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


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

    1. Initial program 55.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 inf 76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e-218 < (*.f64 (*.f64 y 4) y) < 4.99999999999999978e110

    1. Initial program 85.7%

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

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

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

        \[\leadsto \frac{\left(x + \sqrt{\color{blue}{\left(4 \cdot y\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} \]
      4. associate-*r*85.7%

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

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

        \[\leadsto \frac{\left(x + \color{blue}{\sqrt{y \cdot y} \cdot \sqrt{4}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      7. sqrt-prod49.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} \]
      8. add-sqr-sqrt63.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} \]
      9. metadata-eval63.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} \]
      10. *-commutative63.8%

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

        \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{4 \cdot \left(y \cdot y\right)}}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      12. *-commutative63.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} \]
      13. sqrt-prod63.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} \]
      14. sqrt-prod49.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} \]
      15. add-sqr-sqrt85.7%

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

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

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

    if 4.99999999999999978e110 < (*.f64 (*.f64 y 4) y)

    1. Initial program 30.0%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 80.1% accurate, 0.2× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ \mathbf{if}\;t_0 \leq 10^{-218}:\\ \;\;\;\;1 + {\left(\frac{y}{x}\right)}^{2} \cdot -8\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+110}:\\ \;\;\;\;\frac{\left(x - y \cdot 2\right) \cdot \left(x + y \cdot 2\right)}{t_0 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -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 (* y 4.0))))
   (if (<= t_0 1e-218)
     (+ 1.0 (* (pow (/ y x) 2.0) -8.0))
     (if (<= t_0 5e+110)
       (/ (* (- x (* y 2.0)) (+ x (* y 2.0))) (+ t_0 (* x x)))
       (fma 0.5 (* (/ x y) (/ x y)) -1.0)))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double tmp;
	if (t_0 <= 1e-218) {
		tmp = 1.0 + (pow((y / x), 2.0) * -8.0);
	} else if (t_0 <= 5e+110) {
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x));
	} else {
		tmp = fma(0.5, ((x / y) * (x / y)), -1.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 (t_0 <= 1e-218)
		tmp = Float64(1.0 + Float64((Float64(y / x) ^ 2.0) * -8.0));
	elseif (t_0 <= 5e+110)
		tmp = Float64(Float64(Float64(x - Float64(y * 2.0)) * Float64(x + Float64(y * 2.0))) / Float64(t_0 + Float64(x * x)));
	else
		tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -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[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-218], N[(1.0 + N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+110], N[(N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 10^{-218}:\\
\;\;\;\;1 + {\left(\frac{y}{x}\right)}^{2} \cdot -8\\

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

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


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

    1. Initial program 55.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 inf 76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e-218 < (*.f64 (*.f64 y 4) y) < 4.99999999999999978e110

    1. Initial program 85.7%

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

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

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

        \[\leadsto \frac{\left(x + \sqrt{\color{blue}{\left(4 \cdot y\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} \]
      4. associate-*r*85.7%

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

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

        \[\leadsto \frac{\left(x + \color{blue}{\sqrt{y \cdot y} \cdot \sqrt{4}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      7. sqrt-prod49.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} \]
      8. add-sqr-sqrt63.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} \]
      9. metadata-eval63.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} \]
      10. *-commutative63.8%

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

        \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{4 \cdot \left(y \cdot y\right)}}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      12. *-commutative63.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} \]
      13. sqrt-prod63.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} \]
      14. sqrt-prod49.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} \]
      15. add-sqr-sqrt85.7%

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

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

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

    if 4.99999999999999978e110 < (*.f64 (*.f64 y 4) y)

    1. Initial program 30.0%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 80.9% accurate, 0.2× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ \mathbf{if}\;t_0 \leq 10^{-218}:\\ \;\;\;\;1 + {\left(\frac{y}{x}\right)}^{2} \cdot -8\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+208}:\\ \;\;\;\;\frac{\left(x - y \cdot 2\right) \cdot \left(x + y \cdot 2\right)}{t_0 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;-1 + 0.25 \cdot \frac{x}{y \cdot \frac{y}{x}}\\ \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 (<= t_0 1e-218)
     (+ 1.0 (* (pow (/ y x) 2.0) -8.0))
     (if (<= t_0 5e+208)
       (/ (* (- x (* y 2.0)) (+ x (* y 2.0))) (+ t_0 (* x x)))
       (+ -1.0 (* 0.25 (/ x (* y (/ y x)))))))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double tmp;
	if (t_0 <= 1e-218) {
		tmp = 1.0 + (pow((y / x), 2.0) * -8.0);
	} else if (t_0 <= 5e+208) {
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x));
	} else {
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	}
	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 (t_0 <= 1d-218) then
        tmp = 1.0d0 + (((y / x) ** 2.0d0) * (-8.0d0))
    else if (t_0 <= 5d+208) then
        tmp = ((x - (y * 2.0d0)) * (x + (y * 2.0d0))) / (t_0 + (x * x))
    else
        tmp = (-1.0d0) + (0.25d0 * (x / (y * (y / x))))
    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 (t_0 <= 1e-218) {
		tmp = 1.0 + (Math.pow((y / x), 2.0) * -8.0);
	} else if (t_0 <= 5e+208) {
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x));
	} else {
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	}
	return tmp;
}
x = abs(x)
y = abs(y)
def code(x, y):
	t_0 = y * (y * 4.0)
	tmp = 0
	if t_0 <= 1e-218:
		tmp = 1.0 + (math.pow((y / x), 2.0) * -8.0)
	elif t_0 <= 5e+208:
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x))
	else:
		tmp = -1.0 + (0.25 * (x / (y * (y / x))))
	return tmp
x = abs(x)
y = abs(y)
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	tmp = 0.0
	if (t_0 <= 1e-218)
		tmp = Float64(1.0 + Float64((Float64(y / x) ^ 2.0) * -8.0));
	elseif (t_0 <= 5e+208)
		tmp = Float64(Float64(Float64(x - Float64(y * 2.0)) * Float64(x + Float64(y * 2.0))) / Float64(t_0 + Float64(x * x)));
	else
		tmp = Float64(-1.0 + Float64(0.25 * Float64(x / Float64(y * Float64(y / x)))));
	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 (t_0 <= 1e-218)
		tmp = 1.0 + (((y / x) ^ 2.0) * -8.0);
	elseif (t_0 <= 5e+208)
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / (t_0 + (x * x));
	else
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	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[t$95$0, 1e-218], N[(1.0 + N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+208], N[(N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(0.25 * N[(x / N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 10^{-218}:\\
\;\;\;\;1 + {\left(\frac{y}{x}\right)}^{2} \cdot -8\\

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

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


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

    1. Initial program 55.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 inf 76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e-218 < (*.f64 (*.f64 y 4) y) < 5.0000000000000004e208

    1. Initial program 82.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-sqrt82.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-squares82.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. *-commutative82.0%

        \[\leadsto \frac{\left(x + \sqrt{\color{blue}{\left(4 \cdot y\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} \]
      4. associate-*r*82.0%

        \[\leadsto \frac{\left(x + \sqrt{\color{blue}{4 \cdot \left(y \cdot y\right)}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      5. *-commutative82.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} \]
      6. sqrt-prod82.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} \]
      7. sqrt-prod44.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} \]
      8. add-sqr-sqrt56.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} \]
      9. metadata-eval56.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} \]
      10. *-commutative56.8%

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

        \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \sqrt{\color{blue}{4 \cdot \left(y \cdot y\right)}}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      12. *-commutative56.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} \]
      13. sqrt-prod56.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} \]
      14. sqrt-prod44.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} \]
      15. add-sqr-sqrt82.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} \]
      16. metadata-eval82.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-rr82.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} \]

    if 5.0000000000000004e208 < (*.f64 (*.f64 y 4) y)

    1. Initial program 23.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 23.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\left(\frac{x}{y} \cdot \frac{x}{y}\right)} - 1 \]
      2. clear-num87.0%

        \[\leadsto 0.25 \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} \cdot \frac{x}{y}\right) - 1 \]
      3. frac-times87.0%

        \[\leadsto 0.25 \cdot \color{blue}{\frac{1 \cdot x}{\frac{y}{x} \cdot y}} - 1 \]
      4. *-un-lft-identity87.0%

        \[\leadsto 0.25 \cdot \frac{\color{blue}{x}}{\frac{y}{x} \cdot y} - 1 \]
    8. Applied egg-rr87.0%

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

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

Alternative 7: 80.9% accurate, 0.8× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 7.2 \cdot 10^{-110}:\\ \;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+104}:\\ \;\;\;\;\frac{\left(x - y \cdot 2\right) \cdot \left(x + y \cdot 2\right)}{y \cdot \left(y \cdot 4\right) + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;-1 + 0.25 \cdot \frac{x}{y \cdot \frac{y}{x}}\\ \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 (<= y 7.2e-110)
   (+ 1.0 (* -8.0 (/ y (* x (/ x y)))))
   (if (<= y 1.25e+104)
     (/ (* (- x (* y 2.0)) (+ x (* y 2.0))) (+ (* y (* y 4.0)) (* x x)))
     (+ -1.0 (* 0.25 (/ x (* y (/ y x))))))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double tmp;
	if (y <= 7.2e-110) {
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	} else if (y <= 1.25e+104) {
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((y * (y * 4.0)) + (x * x));
	} else {
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	}
	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 (y <= 7.2d-110) then
        tmp = 1.0d0 + ((-8.0d0) * (y / (x * (x / y))))
    else if (y <= 1.25d+104) then
        tmp = ((x - (y * 2.0d0)) * (x + (y * 2.0d0))) / ((y * (y * 4.0d0)) + (x * x))
    else
        tmp = (-1.0d0) + (0.25d0 * (x / (y * (y / x))))
    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 (y <= 7.2e-110) {
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	} else if (y <= 1.25e+104) {
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((y * (y * 4.0)) + (x * x));
	} else {
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	}
	return tmp;
}
x = abs(x)
y = abs(y)
def code(x, y):
	tmp = 0
	if y <= 7.2e-110:
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))))
	elif y <= 1.25e+104:
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((y * (y * 4.0)) + (x * x))
	else:
		tmp = -1.0 + (0.25 * (x / (y * (y / x))))
	return tmp
x = abs(x)
y = abs(y)
function code(x, y)
	tmp = 0.0
	if (y <= 7.2e-110)
		tmp = Float64(1.0 + Float64(-8.0 * Float64(y / Float64(x * Float64(x / y)))));
	elseif (y <= 1.25e+104)
		tmp = Float64(Float64(Float64(x - Float64(y * 2.0)) * Float64(x + Float64(y * 2.0))) / Float64(Float64(y * Float64(y * 4.0)) + Float64(x * x)));
	else
		tmp = Float64(-1.0 + Float64(0.25 * Float64(x / Float64(y * Float64(y / x)))));
	end
	return tmp
end
x = abs(x)
y = abs(y)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 7.2e-110)
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	elseif (y <= 1.25e+104)
		tmp = ((x - (y * 2.0)) * (x + (y * 2.0))) / ((y * (y * 4.0)) + (x * x));
	else
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	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[y, 7.2e-110], N[(1.0 + N[(-8.0 * N[(y / N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.25e+104], N[(N[(N[(x - N[(y * 2.0), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(0.25 * N[(x / N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.2 \cdot 10^{-110}:\\
\;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 7.1999999999999999e-110

    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 inf 50.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot y}{\frac{x}{y} \cdot x}} \cdot -8 + 1 \]
      4. *-un-lft-identity58.4%

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

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

    if 7.1999999999999999e-110 < y < 1.2499999999999999e104

    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.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. *-commutative81.3%

        \[\leadsto \frac{\left(x + \sqrt{\color{blue}{\left(4 \cdot y\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} \]
      4. associate-*r*81.3%

        \[\leadsto \frac{\left(x + \sqrt{\color{blue}{4 \cdot \left(y \cdot y\right)}}\right) \cdot \left(x - \sqrt{\left(y \cdot 4\right) \cdot y}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      5. *-commutative81.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} \]
      6. sqrt-prod81.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} \]
      7. sqrt-prod81.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(x + y \cdot 2\right) \cdot \left(x - \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right)}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
      15. add-sqr-sqrt81.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} \]
      16. metadata-eval81.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-rr81.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.2499999999999999e104 < y

    1. Initial program 18.9%

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot x}{4 \cdot \left(y \cdot y\right)} - \frac{\left(y \cdot 4\right) \cdot y}{4 \cdot \left(y \cdot y\right)}} \]
      2. *-un-lft-identity18.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} \cdot \frac{x}{y}\right) - 1 \]
      3. frac-times87.7%

        \[\leadsto 0.25 \cdot \color{blue}{\frac{1 \cdot x}{\frac{y}{x} \cdot y}} - 1 \]
      4. *-un-lft-identity87.7%

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

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

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

Alternative 8: 80.9% accurate, 0.8× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ \mathbf{if}\;y \leq 4.3 \cdot 10^{-110}:\\ \;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+104}:\\ \;\;\;\;\frac{x \cdot x - t_0}{t_0 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;-1 + 0.25 \cdot \frac{x}{y \cdot \frac{y}{x}}\\ \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 (<= y 4.3e-110)
     (+ 1.0 (* -8.0 (/ y (* x (/ x y)))))
     (if (<= y 1.35e+104)
       (/ (- (* x x) t_0) (+ t_0 (* x x)))
       (+ -1.0 (* 0.25 (/ x (* y (/ y x)))))))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double tmp;
	if (y <= 4.3e-110) {
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	} else if (y <= 1.35e+104) {
		tmp = ((x * x) - t_0) / (t_0 + (x * x));
	} else {
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	}
	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 (y <= 4.3d-110) then
        tmp = 1.0d0 + ((-8.0d0) * (y / (x * (x / y))))
    else if (y <= 1.35d+104) then
        tmp = ((x * x) - t_0) / (t_0 + (x * x))
    else
        tmp = (-1.0d0) + (0.25d0 * (x / (y * (y / x))))
    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 (y <= 4.3e-110) {
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	} else if (y <= 1.35e+104) {
		tmp = ((x * x) - t_0) / (t_0 + (x * x));
	} else {
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	}
	return tmp;
}
x = abs(x)
y = abs(y)
def code(x, y):
	t_0 = y * (y * 4.0)
	tmp = 0
	if y <= 4.3e-110:
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))))
	elif y <= 1.35e+104:
		tmp = ((x * x) - t_0) / (t_0 + (x * x))
	else:
		tmp = -1.0 + (0.25 * (x / (y * (y / x))))
	return tmp
x = abs(x)
y = abs(y)
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	tmp = 0.0
	if (y <= 4.3e-110)
		tmp = Float64(1.0 + Float64(-8.0 * Float64(y / Float64(x * Float64(x / y)))));
	elseif (y <= 1.35e+104)
		tmp = Float64(Float64(Float64(x * x) - t_0) / Float64(t_0 + Float64(x * x)));
	else
		tmp = Float64(-1.0 + Float64(0.25 * Float64(x / Float64(y * Float64(y / x)))));
	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 (y <= 4.3e-110)
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	elseif (y <= 1.35e+104)
		tmp = ((x * x) - t_0) / (t_0 + (x * x));
	else
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	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[y, 4.3e-110], N[(1.0 + N[(-8.0 * N[(y / N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+104], N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(t$95$0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(0.25 * N[(x / N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;y \leq 4.3 \cdot 10^{-110}:\\
\;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{+104}:\\
\;\;\;\;\frac{x \cdot x - t_0}{t_0 + x \cdot x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 4.30000000000000025e-110

    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 inf 50.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot y}{\frac{x}{y} \cdot x}} \cdot -8 + 1 \]
      4. *-un-lft-identity58.4%

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

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

    if 4.30000000000000025e-110 < y < 1.34999999999999992e104

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

    if 1.34999999999999992e104 < y

    1. Initial program 18.9%

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot x}{4 \cdot \left(y \cdot y\right)} - \frac{\left(y \cdot 4\right) \cdot y}{4 \cdot \left(y \cdot y\right)}} \]
      2. *-un-lft-identity18.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} \cdot \frac{x}{y}\right) - 1 \]
      3. frac-times87.7%

        \[\leadsto 0.25 \cdot \color{blue}{\frac{1 \cdot x}{\frac{y}{x} \cdot y}} - 1 \]
      4. *-un-lft-identity87.7%

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

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

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

Alternative 9: 74.5% accurate, 1.5× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 6.2 \cdot 10^{-6}:\\ \;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\ \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 (<= y 6.2e-6) (+ 1.0 (* -8.0 (/ y (* x (/ x y))))) -1.0))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double tmp;
	if (y <= 6.2e-6) {
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	} 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 (y <= 6.2d-6) then
        tmp = 1.0d0 + ((-8.0d0) * (y / (x * (x / y))))
    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 (y <= 6.2e-6) {
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	} else {
		tmp = -1.0;
	}
	return tmp;
}
x = abs(x)
y = abs(y)
def code(x, y):
	tmp = 0
	if y <= 6.2e-6:
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))))
	else:
		tmp = -1.0
	return tmp
x = abs(x)
y = abs(y)
function code(x, y)
	tmp = 0.0
	if (y <= 6.2e-6)
		tmp = Float64(1.0 + Float64(-8.0 * Float64(y / Float64(x * Float64(x / y)))));
	else
		tmp = -1.0;
	end
	return tmp
end
x = abs(x)
y = abs(y)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 6.2e-6)
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	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[y, 6.2e-6], N[(1.0 + N[(-8.0 * N[(y / N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{-6}:\\
\;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\

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


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

    1. Initial program 57.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 52.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot y}{\frac{x}{y} \cdot x}} \cdot -8 + 1 \]
      4. *-un-lft-identity59.1%

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

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

    if 6.1999999999999999e-6 < y

    1. Initial program 37.4%

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

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

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

Alternative 10: 74.9% accurate, 1.5× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 4.7 \cdot 10^{-7}:\\ \;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;-1 + 0.25 \cdot \frac{x}{y \cdot \frac{y}{x}}\\ \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 (<= y 4.7e-7)
   (+ 1.0 (* -8.0 (/ y (* x (/ x y)))))
   (+ -1.0 (* 0.25 (/ x (* y (/ y x)))))))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double tmp;
	if (y <= 4.7e-7) {
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	} else {
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	}
	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 (y <= 4.7d-7) then
        tmp = 1.0d0 + ((-8.0d0) * (y / (x * (x / y))))
    else
        tmp = (-1.0d0) + (0.25d0 * (x / (y * (y / x))))
    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 (y <= 4.7e-7) {
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	} else {
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	}
	return tmp;
}
x = abs(x)
y = abs(y)
def code(x, y):
	tmp = 0
	if y <= 4.7e-7:
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))))
	else:
		tmp = -1.0 + (0.25 * (x / (y * (y / x))))
	return tmp
x = abs(x)
y = abs(y)
function code(x, y)
	tmp = 0.0
	if (y <= 4.7e-7)
		tmp = Float64(1.0 + Float64(-8.0 * Float64(y / Float64(x * Float64(x / y)))));
	else
		tmp = Float64(-1.0 + Float64(0.25 * Float64(x / Float64(y * Float64(y / x)))));
	end
	return tmp
end
x = abs(x)
y = abs(y)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 4.7e-7)
		tmp = 1.0 + (-8.0 * (y / (x * (x / y))));
	else
		tmp = -1.0 + (0.25 * (x / (y * (y / x))));
	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[y, 4.7e-7], N[(1.0 + N[(-8.0 * N[(y / N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(0.25 * N[(x / N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.7 \cdot 10^{-7}:\\
\;\;\;\;1 + -8 \cdot \frac{y}{x \cdot \frac{x}{y}}\\

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


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

    1. Initial program 57.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 52.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot y}{\frac{x}{y} \cdot x}} \cdot -8 + 1 \]
      4. *-un-lft-identity59.1%

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

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

    if 4.7e-7 < y

    1. Initial program 37.4%

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot x}{4 \cdot \left(y \cdot y\right)} - \frac{\left(y \cdot 4\right) \cdot y}{4 \cdot \left(y \cdot y\right)}} \]
      2. *-un-lft-identity32.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.25 \cdot \color{blue}{\frac{1 \cdot x}{\frac{y}{x} \cdot y}} - 1 \]
      4. *-un-lft-identity78.4%

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

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

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

Alternative 11: 73.9% accurate, 6.2× speedup?

\[\begin{array}{l} x = |x|\\ y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 5 \cdot 10^{-7}:\\ \;\;\;\;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 (<= y 5e-7) 1.0 -1.0))
x = abs(x);
y = abs(y);
double code(double x, double y) {
	double tmp;
	if (y <= 5e-7) {
		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 (y <= 5d-7) 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 (y <= 5e-7) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
x = abs(x)
y = abs(y)
def code(x, y):
	tmp = 0
	if y <= 5e-7:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
x = abs(x)
y = abs(y)
function code(x, y)
	tmp = 0.0
	if (y <= 5e-7)
		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 (y <= 5e-7)
		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[y, 5e-7], 1.0, -1.0]
\begin{array}{l}
x = |x|\\
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-7}:\\
\;\;\;\;1\\

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


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

    1. Initial program 57.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 57.6%

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

    if 4.99999999999999977e-7 < y

    1. Initial program 37.4%

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

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

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

Alternative 12: 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 52.9%

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

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

    \[\leadsto -1 \]

Developer target: 50.9% 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 2023257 
(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))))