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

Percentage Accurate: 50.4% → 76.4%
Time: 15.8s
Alternatives: 9
Speedup: 19.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 50.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: 76.4% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\ t_1 := y \cdot \left(y \cdot 4\right)\\ t_2 := x \cdot x - t_1\\ \mathbf{if}\;x \cdot x \leq 0:\\ \;\;\;\;\mathsf{fma}\left(\log \left(e^{{\left(\frac{x}{y}\right)}^{2}}\right), 0.5, -1\right) + -0.125 \cdot {\left(\frac{x}{y}\right)}^{4}\\ \mathbf{elif}\;x \cdot x \leq 10^{-17}:\\ \;\;\;\;\frac{t_2}{\mathsf{fma}\left(x, x, t_1\right)}\\ \mathbf{elif}\;x \cdot x \leq 10^{+105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10^{+150}:\\ \;\;\;\;\frac{t_2}{x \cdot x + t_1}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0)))
        (t_1 (* y (* y 4.0)))
        (t_2 (- (* x x) t_1)))
   (if (<= (* x x) 0.0)
     (+
      (fma (log (exp (pow (/ x y) 2.0))) 0.5 -1.0)
      (* -0.125 (pow (/ x y) 4.0)))
     (if (<= (* x x) 1e-17)
       (/ t_2 (fma x x t_1))
       (if (<= (* x x) 1e+105)
         t_0
         (if (<= (* x x) 1e+150)
           (/ t_2 (+ (* x x) t_1))
           (if (<= (* x x) 2e+193) t_0 1.0)))))))
double code(double x, double y) {
	double t_0 = -1.0 + (((x / y) / (y / x)) / 4.0);
	double t_1 = y * (y * 4.0);
	double t_2 = (x * x) - t_1;
	double tmp;
	if ((x * x) <= 0.0) {
		tmp = fma(log(exp(pow((x / y), 2.0))), 0.5, -1.0) + (-0.125 * pow((x / y), 4.0));
	} else if ((x * x) <= 1e-17) {
		tmp = t_2 / fma(x, x, t_1);
	} else if ((x * x) <= 1e+105) {
		tmp = t_0;
	} else if ((x * x) <= 1e+150) {
		tmp = t_2 / ((x * x) + t_1);
	} else if ((x * x) <= 2e+193) {
		tmp = t_0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0))
	t_1 = Float64(y * Float64(y * 4.0))
	t_2 = Float64(Float64(x * x) - t_1)
	tmp = 0.0
	if (Float64(x * x) <= 0.0)
		tmp = Float64(fma(log(exp((Float64(x / y) ^ 2.0))), 0.5, -1.0) + Float64(-0.125 * (Float64(x / y) ^ 4.0)));
	elseif (Float64(x * x) <= 1e-17)
		tmp = Float64(t_2 / fma(x, x, t_1));
	elseif (Float64(x * x) <= 1e+105)
		tmp = t_0;
	elseif (Float64(x * x) <= 1e+150)
		tmp = Float64(t_2 / Float64(Float64(x * x) + t_1));
	elseif (Float64(x * x) <= 2e+193)
		tmp = t_0;
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * x), $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 0.0], N[(N[(N[Log[N[Exp[N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * 0.5 + -1.0), $MachinePrecision] + N[(-0.125 * N[Power[N[(x / y), $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e-17], N[(t$95$2 / N[(x * x + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+105], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 1e+150], N[(t$95$2 / N[(N[(x * x), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+193], t$95$0, 1.0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \cdot x \leq 10^{-17}:\\
\;\;\;\;\frac{t_2}{\mathsf{fma}\left(x, x, t_1\right)}\\

\mathbf{elif}\;x \cdot x \leq 10^{+105}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \cdot x \leq 10^{+150}:\\
\;\;\;\;\frac{t_2}{x \cdot x + t_1}\\

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (*.f64 x x) < 0.0

    1. Initial program 46.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. *-commutative46.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{{x}^{\color{blue}{\left(3 + 1\right)}}}{{y}^{4}}, 0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1\right) \]
      4. pow-plus55.0%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left(\left(x \cdot x\right) \cdot x\right)} \cdot x}{{y}^{4}}, 0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1\right) \]
      6. associate-*r*55.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, \mathsf{fma}\left(0.5, {\left(\frac{x}{y}\right)}^{2}, -1\right)\right)} \]
    10. Step-by-step derivation
      1. fma-udef86.6%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, 0.5, -1\right)} + -0.125 \cdot {\left(\frac{x}{y}\right)}^{4} \]
    11. Applied egg-rr86.6%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log \left(e^{{\left(\frac{x}{y}\right)}^{2}}\right)}, 0.5, -1\right) + -0.125 \cdot {\left(\frac{x}{y}\right)}^{4} \]
    13. Applied egg-rr86.7%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\log \left(e^{{\left(\frac{x}{y}\right)}^{2}}\right)}, 0.5, -1\right) + -0.125 \cdot {\left(\frac{x}{y}\right)}^{4} \]

    if 0.0 < (*.f64 x x) < 1.00000000000000007e-17

    1. Initial program 83.8%

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

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

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

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

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

    if 1.00000000000000007e-17 < (*.f64 x x) < 9.9999999999999994e104 or 9.99999999999999981e149 < (*.f64 x x) < 2.00000000000000013e193

    1. Initial program 39.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    10. Applied egg-rr80.0%

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

    if 9.9999999999999994e104 < (*.f64 x x) < 9.99999999999999981e149

    1. Initial program 92.9%

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

    if 2.00000000000000013e193 < (*.f64 x x)

    1. Initial program 22.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. *-commutative22.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 0:\\ \;\;\;\;\mathsf{fma}\left(\log \left(e^{{\left(\frac{x}{y}\right)}^{2}}\right), 0.5, -1\right) + -0.125 \cdot {\left(\frac{x}{y}\right)}^{4}\\ \mathbf{elif}\;x \cdot x \leq 10^{-17}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\ \mathbf{elif}\;x \cdot x \leq 10^{+105}:\\ \;\;\;\;-1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\ \mathbf{elif}\;x \cdot x \leq 10^{+150}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\ \;\;\;\;-1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 2: 76.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ t_1 := x \cdot x - t_0\\ t_2 := \frac{\frac{x}{y}}{\frac{y}{x}}\\ t_3 := -1 + \frac{t_2}{4}\\ \mathbf{if}\;x \cdot x \leq 0:\\ \;\;\;\;-0.125 \cdot {\left(\frac{x}{y}\right)}^{4} + \mathsf{fma}\left(t_2, 0.5, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 10^{-17}:\\ \;\;\;\;\frac{t_1}{\mathsf{fma}\left(x, x, t_0\right)}\\ \mathbf{elif}\;x \cdot x \leq 10^{+105}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \cdot x \leq 10^{+150}:\\ \;\;\;\;\frac{t_1}{x \cdot x + t_0}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* y 4.0)))
        (t_1 (- (* x x) t_0))
        (t_2 (/ (/ x y) (/ y x)))
        (t_3 (+ -1.0 (/ t_2 4.0))))
   (if (<= (* x x) 0.0)
     (+ (* -0.125 (pow (/ x y) 4.0)) (fma t_2 0.5 -1.0))
     (if (<= (* x x) 1e-17)
       (/ t_1 (fma x x t_0))
       (if (<= (* x x) 1e+105)
         t_3
         (if (<= (* x x) 1e+150)
           (/ t_1 (+ (* x x) t_0))
           (if (<= (* x x) 2e+193) t_3 1.0)))))))
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double t_1 = (x * x) - t_0;
	double t_2 = (x / y) / (y / x);
	double t_3 = -1.0 + (t_2 / 4.0);
	double tmp;
	if ((x * x) <= 0.0) {
		tmp = (-0.125 * pow((x / y), 4.0)) + fma(t_2, 0.5, -1.0);
	} else if ((x * x) <= 1e-17) {
		tmp = t_1 / fma(x, x, t_0);
	} else if ((x * x) <= 1e+105) {
		tmp = t_3;
	} else if ((x * x) <= 1e+150) {
		tmp = t_1 / ((x * x) + t_0);
	} else if ((x * x) <= 2e+193) {
		tmp = t_3;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	t_1 = Float64(Float64(x * x) - t_0)
	t_2 = Float64(Float64(x / y) / Float64(y / x))
	t_3 = Float64(-1.0 + Float64(t_2 / 4.0))
	tmp = 0.0
	if (Float64(x * x) <= 0.0)
		tmp = Float64(Float64(-0.125 * (Float64(x / y) ^ 4.0)) + fma(t_2, 0.5, -1.0));
	elseif (Float64(x * x) <= 1e-17)
		tmp = Float64(t_1 / fma(x, x, t_0));
	elseif (Float64(x * x) <= 1e+105)
		tmp = t_3;
	elseif (Float64(x * x) <= 1e+150)
		tmp = Float64(t_1 / Float64(Float64(x * x) + t_0));
	elseif (Float64(x * x) <= 2e+193)
		tmp = t_3;
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(-1.0 + N[(t$95$2 / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 0.0], N[(N[(-0.125 * N[Power[N[(x / y), $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * 0.5 + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e-17], N[(t$95$1 / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+105], t$95$3, If[LessEqual[N[(x * x), $MachinePrecision], 1e+150], N[(t$95$1 / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+193], t$95$3, 1.0]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \cdot x \leq 10^{-17}:\\
\;\;\;\;\frac{t_1}{\mathsf{fma}\left(x, x, t_0\right)}\\

\mathbf{elif}\;x \cdot x \leq 10^{+105}:\\
\;\;\;\;t_3\\

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

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\
\;\;\;\;t_3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (*.f64 x x) < 0.0

    1. Initial program 46.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. *-commutative46.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{{x}^{\color{blue}{\left(3 + 1\right)}}}{{y}^{4}}, 0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1\right) \]
      4. pow-plus55.0%

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

        \[\leadsto \mathsf{fma}\left(-0.125, \frac{\color{blue}{\left(\left(x \cdot x\right) \cdot x\right)} \cdot x}{{y}^{4}}, 0.5 \cdot \frac{{x}^{2}}{{y}^{2}} - 1\right) \]
      6. associate-*r*55.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125, {\left(\frac{x}{y}\right)}^{4}, \mathsf{fma}\left(0.5, {\left(\frac{x}{y}\right)}^{2}, -1\right)\right)} \]
    10. Step-by-step derivation
      1. fma-udef86.6%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\frac{x}{y}\right)}^{2}, 0.5, -1\right)} + -0.125 \cdot {\left(\frac{x}{y}\right)}^{4} \]
    11. Applied egg-rr86.6%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    13. Applied egg-rr86.6%

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

    if 0.0 < (*.f64 x x) < 1.00000000000000007e-17

    1. Initial program 83.8%

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

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

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

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

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

    if 1.00000000000000007e-17 < (*.f64 x x) < 9.9999999999999994e104 or 9.99999999999999981e149 < (*.f64 x x) < 2.00000000000000013e193

    1. Initial program 39.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    10. Applied egg-rr80.0%

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

    if 9.9999999999999994e104 < (*.f64 x x) < 9.99999999999999981e149

    1. Initial program 92.9%

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

    if 2.00000000000000013e193 < (*.f64 x x)

    1. Initial program 22.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. *-commutative22.0%

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

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

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

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

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

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

Alternative 3: 76.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ t_1 := x \cdot x - t_0\\ t_2 := -1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\ \mathbf{if}\;x \cdot x \leq 0:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 10^{-17}:\\ \;\;\;\;\frac{t_1}{\mathsf{fma}\left(x, x, t_0\right)}\\ \mathbf{elif}\;x \cdot x \leq 10^{+105}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot x \leq 10^{+150}:\\ \;\;\;\;\frac{t_1}{x \cdot x + t_0}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* y 4.0)))
        (t_1 (- (* x x) t_0))
        (t_2 (+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0))))
   (if (<= (* x x) 0.0)
     (fma 0.5 (* (/ x y) (/ x y)) -1.0)
     (if (<= (* x x) 1e-17)
       (/ t_1 (fma x x t_0))
       (if (<= (* x x) 1e+105)
         t_2
         (if (<= (* x x) 1e+150)
           (/ t_1 (+ (* x x) t_0))
           (if (<= (* x x) 2e+193) t_2 1.0)))))))
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double t_1 = (x * x) - t_0;
	double t_2 = -1.0 + (((x / y) / (y / x)) / 4.0);
	double tmp;
	if ((x * x) <= 0.0) {
		tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
	} else if ((x * x) <= 1e-17) {
		tmp = t_1 / fma(x, x, t_0);
	} else if ((x * x) <= 1e+105) {
		tmp = t_2;
	} else if ((x * x) <= 1e+150) {
		tmp = t_1 / ((x * x) + t_0);
	} else if ((x * x) <= 2e+193) {
		tmp = t_2;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	t_1 = Float64(Float64(x * x) - t_0)
	t_2 = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0))
	tmp = 0.0
	if (Float64(x * x) <= 0.0)
		tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0);
	elseif (Float64(x * x) <= 1e-17)
		tmp = Float64(t_1 / fma(x, x, t_0));
	elseif (Float64(x * x) <= 1e+105)
		tmp = t_2;
	elseif (Float64(x * x) <= 1e+150)
		tmp = Float64(t_1 / Float64(Float64(x * x) + t_0));
	elseif (Float64(x * x) <= 2e+193)
		tmp = t_2;
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 0.0], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e-17], N[(t$95$1 / N[(x * x + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e+105], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 1e+150], N[(t$95$1 / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2e+193], t$95$2, 1.0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \cdot x \leq 10^{-17}:\\
\;\;\;\;\frac{t_1}{\mathsf{fma}\left(x, x, t_0\right)}\\

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

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

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (*.f64 x x) < 0.0

    1. Initial program 46.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. *-commutative46.7%

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

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

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

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

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

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

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

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

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

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

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

    if 0.0 < (*.f64 x x) < 1.00000000000000007e-17

    1. Initial program 83.8%

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

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

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

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

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

    if 1.00000000000000007e-17 < (*.f64 x x) < 9.9999999999999994e104 or 9.99999999999999981e149 < (*.f64 x x) < 2.00000000000000013e193

    1. Initial program 39.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    10. Applied egg-rr80.0%

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

    if 9.9999999999999994e104 < (*.f64 x x) < 9.99999999999999981e149

    1. Initial program 92.9%

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

    if 2.00000000000000013e193 < (*.f64 x x)

    1. Initial program 22.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. *-commutative22.0%

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

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

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

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

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

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

Alternative 4: 76.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot 4\right)\\ t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\ t_2 := -1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\ \mathbf{if}\;x \cdot x \leq 0:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 10^{-17}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 10^{+105}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot x \leq 10^{+150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* y 4.0)))
        (t_1 (/ (- (* x x) t_0) (+ (* x x) t_0)))
        (t_2 (+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0))))
   (if (<= (* x x) 0.0)
     (fma 0.5 (* (/ x y) (/ x y)) -1.0)
     (if (<= (* x x) 1e-17)
       t_1
       (if (<= (* x x) 1e+105)
         t_2
         (if (<= (* x x) 1e+150) t_1 (if (<= (* x x) 2e+193) t_2 1.0)))))))
double code(double x, double y) {
	double t_0 = y * (y * 4.0);
	double t_1 = ((x * x) - t_0) / ((x * x) + t_0);
	double t_2 = -1.0 + (((x / y) / (y / x)) / 4.0);
	double tmp;
	if ((x * x) <= 0.0) {
		tmp = fma(0.5, ((x / y) * (x / y)), -1.0);
	} else if ((x * x) <= 1e-17) {
		tmp = t_1;
	} else if ((x * x) <= 1e+105) {
		tmp = t_2;
	} else if ((x * x) <= 1e+150) {
		tmp = t_1;
	} else if ((x * x) <= 2e+193) {
		tmp = t_2;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(y * Float64(y * 4.0))
	t_1 = Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0))
	t_2 = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0))
	tmp = 0.0
	if (Float64(x * x) <= 0.0)
		tmp = fma(0.5, Float64(Float64(x / y) * Float64(x / y)), -1.0);
	elseif (Float64(x * x) <= 1e-17)
		tmp = t_1;
	elseif (Float64(x * x) <= 1e+105)
		tmp = t_2;
	elseif (Float64(x * x) <= 1e+150)
		tmp = t_1;
	elseif (Float64(x * x) <= 2e+193)
		tmp = t_2;
	else
		tmp = 1.0;
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 0.0], N[(0.5 * N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 1e-17], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 1e+105], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 1e+150], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 2e+193], t$95$2, 1.0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \cdot x \leq 10^{-17}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\
\;\;\;\;t_2\\

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


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

    1. Initial program 46.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. *-commutative46.7%

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

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

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

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

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

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

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

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

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

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

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

    if 0.0 < (*.f64 x x) < 1.00000000000000007e-17 or 9.9999999999999994e104 < (*.f64 x x) < 9.99999999999999981e149

    1. Initial program 85.5%

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

    if 1.00000000000000007e-17 < (*.f64 x x) < 9.9999999999999994e104 or 9.99999999999999981e149 < (*.f64 x x) < 2.00000000000000013e193

    1. Initial program 39.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    10. Applied egg-rr80.0%

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

    if 2.00000000000000013e193 < (*.f64 x x)

    1. Initial program 22.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. *-commutative22.0%

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

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

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

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

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

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

Alternative 5: 71.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + -4 \cdot \frac{y \cdot y}{x \cdot x}\\ \mathbf{if}\;x \cdot x \leq 3.9 \cdot 10^{-170}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 1.2 \cdot 10^{-96}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 3.3 \cdot 10^{+109}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2.8 \cdot 10^{+150}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ 1.0 (* -4.0 (/ (* y y) (* x x))))))
   (if (<= (* x x) 3.9e-170)
     -1.0
     (if (<= (* x x) 1.2e-96)
       t_0
       (if (<= (* x x) 3.3e+109)
         -1.0
         (if (<= (* x x) 2.8e+150) t_0 (if (<= (* x x) 2e+193) -1.0 1.0)))))))
double code(double x, double y) {
	double t_0 = 1.0 + (-4.0 * ((y * y) / (x * x)));
	double tmp;
	if ((x * x) <= 3.9e-170) {
		tmp = -1.0;
	} else if ((x * x) <= 1.2e-96) {
		tmp = t_0;
	} else if ((x * x) <= 3.3e+109) {
		tmp = -1.0;
	} else if ((x * x) <= 2.8e+150) {
		tmp = t_0;
	} else if ((x * x) <= 2e+193) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 + ((-4.0d0) * ((y * y) / (x * x)))
    if ((x * x) <= 3.9d-170) then
        tmp = -1.0d0
    else if ((x * x) <= 1.2d-96) then
        tmp = t_0
    else if ((x * x) <= 3.3d+109) then
        tmp = -1.0d0
    else if ((x * x) <= 2.8d+150) then
        tmp = t_0
    else if ((x * x) <= 2d+193) then
        tmp = -1.0d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 + (-4.0 * ((y * y) / (x * x)));
	double tmp;
	if ((x * x) <= 3.9e-170) {
		tmp = -1.0;
	} else if ((x * x) <= 1.2e-96) {
		tmp = t_0;
	} else if ((x * x) <= 3.3e+109) {
		tmp = -1.0;
	} else if ((x * x) <= 2.8e+150) {
		tmp = t_0;
	} else if ((x * x) <= 2e+193) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 + (-4.0 * ((y * y) / (x * x)))
	tmp = 0
	if (x * x) <= 3.9e-170:
		tmp = -1.0
	elif (x * x) <= 1.2e-96:
		tmp = t_0
	elif (x * x) <= 3.3e+109:
		tmp = -1.0
	elif (x * x) <= 2.8e+150:
		tmp = t_0
	elif (x * x) <= 2e+193:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 + Float64(-4.0 * Float64(Float64(y * y) / Float64(x * x))))
	tmp = 0.0
	if (Float64(x * x) <= 3.9e-170)
		tmp = -1.0;
	elseif (Float64(x * x) <= 1.2e-96)
		tmp = t_0;
	elseif (Float64(x * x) <= 3.3e+109)
		tmp = -1.0;
	elseif (Float64(x * x) <= 2.8e+150)
		tmp = t_0;
	elseif (Float64(x * x) <= 2e+193)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 + (-4.0 * ((y * y) / (x * x)));
	tmp = 0.0;
	if ((x * x) <= 3.9e-170)
		tmp = -1.0;
	elseif ((x * x) <= 1.2e-96)
		tmp = t_0;
	elseif ((x * x) <= 3.3e+109)
		tmp = -1.0;
	elseif ((x * x) <= 2.8e+150)
		tmp = t_0;
	elseif ((x * x) <= 2e+193)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(-4.0 * N[(N[(y * y), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 3.9e-170], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 1.2e-96], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 3.3e+109], -1.0, If[LessEqual[N[(x * x), $MachinePrecision], 2.8e+150], t$95$0, If[LessEqual[N[(x * x), $MachinePrecision], 2e+193], -1.0, 1.0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + -4 \cdot \frac{y \cdot y}{x \cdot x}\\
\mathbf{if}\;x \cdot x \leq 3.9 \cdot 10^{-170}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \cdot x \leq 1.2 \cdot 10^{-96}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \cdot x \leq 3.3 \cdot 10^{+109}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \cdot x \leq 2.8 \cdot 10^{+150}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 3.90000000000000021e-170 or 1.2000000000000001e-96 < (*.f64 x x) < 3.2999999999999999e109 or 2.80000000000000009e150 < (*.f64 x x) < 2.00000000000000013e193

    1. Initial program 54.9%

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

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

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

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

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

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

    if 3.90000000000000021e-170 < (*.f64 x x) < 1.2000000000000001e-96 or 3.2999999999999999e109 < (*.f64 x x) < 2.80000000000000009e150

    1. Initial program 93.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. *-commutative93.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{\color{blue}{x \cdot x}} \]
    10. Taylor expanded in x around 0 73.5%

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

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

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

        \[\leadsto -4 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} + 1 \]
    12. Simplified73.5%

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

    if 2.00000000000000013e193 < (*.f64 x x)

    1. Initial program 22.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. *-commutative22.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \leq 3.9 \cdot 10^{-170}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 1.2 \cdot 10^{-96}:\\ \;\;\;\;1 + -4 \cdot \frac{y \cdot y}{x \cdot x}\\ \mathbf{elif}\;x \cdot x \leq 3.3 \cdot 10^{+109}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2.8 \cdot 10^{+150}:\\ \;\;\;\;1 + -4 \cdot \frac{y \cdot y}{x \cdot x}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+193}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 6: 64.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;y \leq 10^{-162}:\\
\;\;\;\;1\\

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

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


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

    1. Initial program 53.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. *-commutative53.7%

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

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

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

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

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

    if 9.99999999999999954e-163 < y < 1.99999999999999995e102

    1. Initial program 76.6%

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

    if 1.99999999999999995e102 < y

    1. Initial program 6.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 61.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{+14}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1 + \frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y 1.9e+14) 1.0 (+ -1.0 (/ (/ (/ x y) (/ y x)) 4.0))))
double code(double x, double y) {
	double tmp;
	if (y <= 1.9e+14) {
		tmp = 1.0;
	} else {
		tmp = -1.0 + (((x / y) / (y / x)) / 4.0);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= 1.9d+14) then
        tmp = 1.0d0
    else
        tmp = (-1.0d0) + (((x / y) / (y / x)) / 4.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= 1.9e+14) {
		tmp = 1.0;
	} else {
		tmp = -1.0 + (((x / y) / (y / x)) / 4.0);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 1.9e+14:
		tmp = 1.0
	else:
		tmp = -1.0 + (((x / y) / (y / x)) / 4.0)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 1.9e+14)
		tmp = 1.0;
	else
		tmp = Float64(-1.0 + Float64(Float64(Float64(x / y) / Float64(y / x)) / 4.0));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 1.9e+14)
		tmp = 1.0;
	else
		tmp = -1.0 + (((x / y) / (y / x)) / 4.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 1.9e+14], 1.0, N[(-1.0 + N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{+14}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.9e14

    1. Initial program 57.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. *-commutative57.3%

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

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

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

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

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

    if 1.9e14 < y

    1. Initial program 25.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. *-commutative25.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    10. Applied egg-rr72.3%

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

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

Alternative 8: 61.4% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.9 \cdot 10^{-85}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-50}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{+52}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+75}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+96}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x 1.9e-85)
   -1.0
   (if (<= x 5e-50)
     1.0
     (if (<= x 3.3e+52)
       -1.0
       (if (<= x 1.35e+75) 1.0 (if (<= x 3.4e+96) -1.0 1.0))))))
double code(double x, double y) {
	double tmp;
	if (x <= 1.9e-85) {
		tmp = -1.0;
	} else if (x <= 5e-50) {
		tmp = 1.0;
	} else if (x <= 3.3e+52) {
		tmp = -1.0;
	} else if (x <= 1.35e+75) {
		tmp = 1.0;
	} else if (x <= 3.4e+96) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= 1.9d-85) then
        tmp = -1.0d0
    else if (x <= 5d-50) then
        tmp = 1.0d0
    else if (x <= 3.3d+52) then
        tmp = -1.0d0
    else if (x <= 1.35d+75) then
        tmp = 1.0d0
    else if (x <= 3.4d+96) then
        tmp = -1.0d0
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= 1.9e-85) {
		tmp = -1.0;
	} else if (x <= 5e-50) {
		tmp = 1.0;
	} else if (x <= 3.3e+52) {
		tmp = -1.0;
	} else if (x <= 1.35e+75) {
		tmp = 1.0;
	} else if (x <= 3.4e+96) {
		tmp = -1.0;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= 1.9e-85:
		tmp = -1.0
	elif x <= 5e-50:
		tmp = 1.0
	elif x <= 3.3e+52:
		tmp = -1.0
	elif x <= 1.35e+75:
		tmp = 1.0
	elif x <= 3.4e+96:
		tmp = -1.0
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= 1.9e-85)
		tmp = -1.0;
	elseif (x <= 5e-50)
		tmp = 1.0;
	elseif (x <= 3.3e+52)
		tmp = -1.0;
	elseif (x <= 1.35e+75)
		tmp = 1.0;
	elseif (x <= 3.4e+96)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 1.9e-85)
		tmp = -1.0;
	elseif (x <= 5e-50)
		tmp = 1.0;
	elseif (x <= 3.3e+52)
		tmp = -1.0;
	elseif (x <= 1.35e+75)
		tmp = 1.0;
	elseif (x <= 3.4e+96)
		tmp = -1.0;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, 1.9e-85], -1.0, If[LessEqual[x, 5e-50], 1.0, If[LessEqual[x, 3.3e+52], -1.0, If[LessEqual[x, 1.35e+75], 1.0, If[LessEqual[x, 3.4e+96], -1.0, 1.0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9 \cdot 10^{-85}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq 5 \cdot 10^{-50}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 3.3 \cdot 10^{+52}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \leq 1.35 \cdot 10^{+75}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 3.4 \cdot 10^{+96}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.8999999999999999e-85 or 4.99999999999999968e-50 < x < 3.3e52 or 1.34999999999999999e75 < x < 3.4000000000000001e96

    1. Initial program 50.2%

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

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

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

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

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

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

    if 1.8999999999999999e-85 < x < 4.99999999999999968e-50 or 3.3e52 < x < 1.34999999999999999e75 or 3.4000000000000001e96 < x

    1. Initial program 45.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.9 \cdot 10^{-85}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-50}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{+52}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+75}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+96}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 9: 50.6% accurate, 19.0× speedup?

\[\begin{array}{l} \\ -1 \end{array} \]
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
	return -1.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = -1.0d0
end function
public static double code(double x, double y) {
	return -1.0;
}
def code(x, y):
	return -1.0
function code(x, y)
	return -1.0
end
function tmp = code(x, y)
	tmp = -1.0;
end
code[x_, y_] := -1.0
\begin{array}{l}

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification50.8%

    \[\leadsto -1 \]

Developer target: 50.8% 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 2023287 
(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))))