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

Percentage Accurate: 50.2% → 81.0%
Time: 9.4s
Alternatives: 9
Speedup: 2.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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.2% 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: 81.0% accurate, 0.1× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 5.8 \cdot 10^{-112}:\\ \;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{+139}:\\ \;\;\;\;\frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{{\left(\mathsf{hypot}\left(x, y \cdot 2\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (if (<= x 5.8e-112)
   (+ -1.0 (/ 0.5 (* (/ y x) (/ y x))))
   (if (<= x 5.8e+139)
     (/ (- (* x x) (* y (* y 4.0))) (pow (hypot x (* y 2.0)) 2.0))
     (+ (* (pow (/ y x) 2.0) -8.0) 1.0))))
x = abs(x);
double code(double x, double y) {
	double tmp;
	if (x <= 5.8e-112) {
		tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
	} else if (x <= 5.8e+139) {
		tmp = ((x * x) - (y * (y * 4.0))) / pow(hypot(x, (y * 2.0)), 2.0);
	} else {
		tmp = (pow((y / x), 2.0) * -8.0) + 1.0;
	}
	return tmp;
}
x = Math.abs(x);
public static double code(double x, double y) {
	double tmp;
	if (x <= 5.8e-112) {
		tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
	} else if (x <= 5.8e+139) {
		tmp = ((x * x) - (y * (y * 4.0))) / Math.pow(Math.hypot(x, (y * 2.0)), 2.0);
	} else {
		tmp = (Math.pow((y / x), 2.0) * -8.0) + 1.0;
	}
	return tmp;
}
x = abs(x)
def code(x, y):
	tmp = 0
	if x <= 5.8e-112:
		tmp = -1.0 + (0.5 / ((y / x) * (y / x)))
	elif x <= 5.8e+139:
		tmp = ((x * x) - (y * (y * 4.0))) / math.pow(math.hypot(x, (y * 2.0)), 2.0)
	else:
		tmp = (math.pow((y / x), 2.0) * -8.0) + 1.0
	return tmp
x = abs(x)
function code(x, y)
	tmp = 0.0
	if (x <= 5.8e-112)
		tmp = Float64(-1.0 + Float64(0.5 / Float64(Float64(y / x) * Float64(y / x))));
	elseif (x <= 5.8e+139)
		tmp = Float64(Float64(Float64(x * x) - Float64(y * Float64(y * 4.0))) / (hypot(x, Float64(y * 2.0)) ^ 2.0));
	else
		tmp = Float64(Float64((Float64(y / x) ^ 2.0) * -8.0) + 1.0);
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 5.8e-112)
		tmp = -1.0 + (0.5 / ((y / x) * (y / x)));
	elseif (x <= 5.8e+139)
		tmp = ((x * x) - (y * (y * 4.0))) / (hypot(x, (y * 2.0)) ^ 2.0);
	else
		tmp = (((y / x) ^ 2.0) * -8.0) + 1.0;
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_, y_] := If[LessEqual[x, 5.8e-112], N[(-1.0 + N[(0.5 / N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.8e+139], N[(N[(N[(x * x), $MachinePrecision] - N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[(y / x), $MachinePrecision], 2.0], $MachinePrecision] * -8.0), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.8 \cdot 10^{-112}:\\
\;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\

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

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


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

    1. Initial program 51.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. +-commutative51.7%

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

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

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

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

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

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

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

        \[\leadsto -1 + 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} \]
      5. associate-*r/56.4%

        \[\leadsto -1 + \color{blue}{\frac{0.5 \cdot \left(x \cdot x\right)}{{y}^{2}}} \]
      6. associate-/l*56.4%

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

        \[\leadsto -1 + \frac{0.5}{\frac{\color{blue}{y \cdot y}}{x \cdot x}} \]
      8. times-frac61.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{\frac{y}{x} \cdot \frac{y}{x}}} \]
      9. unpow261.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{{\left(\frac{y}{x}\right)}^{2}}} \]
    6. Simplified61.7%

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

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

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

    if 5.79999999999999985e-112 < x < 5.7999999999999998e139

    1. Initial program 91.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. *-commutative91.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-def91.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. *-commutative91.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. Simplified91.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. Step-by-step derivation
      1. fma-udef91.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{{\left(\mathsf{hypot}\left(x, \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right)\right)}^{2}} \]
      11. add-sqr-sqrt91.9%

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

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

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

    if 5.7999999999999998e139 < x

    1. Initial program 9.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. *-commutative9.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-def9.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. *-commutative9.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. Simplified9.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 inf 71.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 81.0% accurate, 0.2× speedup?

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

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

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


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

    1. Initial program 51.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. +-commutative51.7%

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

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

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

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

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

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

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

        \[\leadsto -1 + 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} \]
      5. associate-*r/56.4%

        \[\leadsto -1 + \color{blue}{\frac{0.5 \cdot \left(x \cdot x\right)}{{y}^{2}}} \]
      6. associate-/l*56.4%

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

        \[\leadsto -1 + \frac{0.5}{\frac{\color{blue}{y \cdot y}}{x \cdot x}} \]
      8. times-frac61.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{\frac{y}{x} \cdot \frac{y}{x}}} \]
      9. unpow261.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{{\left(\frac{y}{x}\right)}^{2}}} \]
    6. Simplified61.7%

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

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

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

    if 4.09999999999999996e-112 < x < 9.79999999999999966e138

    1. Initial program 91.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. *-commutative91.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-def91.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. *-commutative91.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. Simplified91.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)}} \]

    if 9.79999999999999966e138 < x

    1. Initial program 9.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. *-commutative9.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-def9.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. *-commutative9.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. Simplified9.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 inf 71.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.1 \cdot 10^{-112}:\\ \;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{+138}:\\ \;\;\;\;\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{else}:\\ \;\;\;\;{\left(\frac{y}{x}\right)}^{2} \cdot -8 + 1\\ \end{array} \]

Alternative 3: 81.0% accurate, 0.2× speedup?

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

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

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


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

    1. Initial program 59.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. +-commutative59.3%

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

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

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

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

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

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

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

        \[\leadsto -1 + 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} \]
      5. associate-*r/79.5%

        \[\leadsto -1 + \color{blue}{\frac{0.5 \cdot \left(x \cdot x\right)}{{y}^{2}}} \]
      6. associate-/l*79.5%

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

        \[\leadsto -1 + \frac{0.5}{\frac{\color{blue}{y \cdot y}}{x \cdot x}} \]
      8. times-frac88.0%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{\frac{y}{x} \cdot \frac{y}{x}}} \]
      9. unpow288.0%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{{\left(\frac{y}{x}\right)}^{2}}} \]
    6. Simplified88.0%

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

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

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

    if 1.9999999999999999e-223 < (*.f64 x x) < 2.0000000000000001e276

    1. Initial program 81.3%

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

    if 2.0000000000000001e276 < (*.f64 x x)

    1. Initial program 7.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. *-commutative7.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-def7.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. *-commutative7.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. Simplified7.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 inf 67.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 73.7% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x x) < 5.00000000000000019e-26 or 4.9999999999999998e-8 < (*.f64 x x) < 4.9999999999999999e149

    1. Initial program 68.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. +-commutative68.3%

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

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

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

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

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

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

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

        \[\leadsto -1 + 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} \]
      5. associate-*r/73.0%

        \[\leadsto -1 + \color{blue}{\frac{0.5 \cdot \left(x \cdot x\right)}{{y}^{2}}} \]
      6. associate-/l*73.0%

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

        \[\leadsto -1 + \frac{0.5}{\frac{\color{blue}{y \cdot y}}{x \cdot x}} \]
      8. times-frac77.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{\frac{y}{x} \cdot \frac{y}{x}}} \]
      9. unpow277.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{{\left(\frac{y}{x}\right)}^{2}}} \]
    6. Simplified77.7%

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

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

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

    if 5.00000000000000019e-26 < (*.f64 x x) < 4.9999999999999998e-8

    1. Initial program 85.7%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative85.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-def85.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. *-commutative85.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. Simplified85.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. Step-by-step derivation
      1. fma-udef85.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{{\left(\mathsf{hypot}\left(x, \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right)\right)}^{2}} \]
      11. add-sqr-sqrt85.7%

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

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{{\left(\mathsf{hypot}\left(x, y \cdot \color{blue}{2}\right)\right)}^{2}} \]
    5. Applied egg-rr85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999999e149 < (*.f64 x x)

    1. Initial program 27.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. *-commutative27.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-def27.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. *-commutative27.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. Simplified27.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 inf 87.0%

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

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

Alternative 5: 81.0% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 51.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. +-commutative51.7%

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

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

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

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

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

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

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

        \[\leadsto -1 + 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} \]
      5. associate-*r/56.4%

        \[\leadsto -1 + \color{blue}{\frac{0.5 \cdot \left(x \cdot x\right)}{{y}^{2}}} \]
      6. associate-/l*56.4%

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

        \[\leadsto -1 + \frac{0.5}{\frac{\color{blue}{y \cdot y}}{x \cdot x}} \]
      8. times-frac61.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{\frac{y}{x} \cdot \frac{y}{x}}} \]
      9. unpow261.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{{\left(\frac{y}{x}\right)}^{2}}} \]
    6. Simplified61.7%

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

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

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

    if 5.19999999999999983e-112 < x < 2.35e139

    1. Initial program 91.9%

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

    if 2.35e139 < x

    1. Initial program 9.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. *-commutative9.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-def9.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. *-commutative9.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. Simplified9.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. Step-by-step derivation
      1. fma-udef9.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{{\left(\mathsf{hypot}\left(x, \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot \sqrt{4}\right)\right)}^{2}} \]
      11. add-sqr-sqrt9.4%

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{{\left(\mathsf{hypot}\left(x, \color{blue}{y} \cdot \sqrt{4}\right)\right)}^{2}} \]
      12. metadata-eval9.4%

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{{\left(\mathsf{hypot}\left(x, y \cdot \color{blue}{2}\right)\right)}^{2}} \]
    5. Applied egg-rr9.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 + \color{blue}{{\left(\frac{x \cdot x}{\left(y \cdot y\right) \cdot -8}\right)}^{-1}} \]
      3. associate-*l*71.9%

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

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

        \[\leadsto 1 + \color{blue}{\frac{1}{\frac{x \cdot x}{y \cdot \left(y \cdot -8\right)}}} \]
      2. associate-/l*72.3%

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

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

        \[\leadsto 1 + \frac{1}{\frac{x}{\frac{\color{blue}{{y}^{2}} \cdot -8}{x}}} \]
      5. associate-*r/72.3%

        \[\leadsto 1 + \frac{1}{\frac{x}{\color{blue}{{y}^{2} \cdot \frac{-8}{x}}}} \]
      6. associate-/r/72.3%

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

        \[\leadsto 1 + \frac{1}{x} \cdot \color{blue}{\frac{{y}^{2} \cdot -8}{x}} \]
      8. associate-*l/72.3%

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

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

        \[\leadsto 1 + \frac{1}{x} \cdot \color{blue}{\left(-8 \cdot \frac{y \cdot y}{x}\right)} \]
      11. associate-*r/88.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.2 \cdot 10^{-112}:\\ \;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{+139}:\\ \;\;\;\;\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{1}{x} \cdot \left(-8 \cdot \left(y \cdot \frac{y}{x}\right)\right)\\ \end{array} \]

Alternative 6: 74.0% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 7.89999999999999966e-13 or 4.24999999999999976e-4 < x < 6e74

    1. Initial program 58.1%

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

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

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

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

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

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

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

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

        \[\leadsto -1 + 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} \]
      5. associate-*r/58.3%

        \[\leadsto -1 + \color{blue}{\frac{0.5 \cdot \left(x \cdot x\right)}{{y}^{2}}} \]
      6. associate-/l*58.3%

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

        \[\leadsto -1 + \frac{0.5}{\frac{\color{blue}{y \cdot y}}{x \cdot x}} \]
      8. times-frac62.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{\frac{y}{x} \cdot \frac{y}{x}}} \]
      9. unpow262.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{{\left(\frac{y}{x}\right)}^{2}}} \]
    6. Simplified62.7%

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

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

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

    if 7.89999999999999966e-13 < x < 4.24999999999999976e-4

    1. Initial program 100.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. *-commutative100.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-def100.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. *-commutative100.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. Simplified100.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. Step-by-step derivation
      1. fma-udef100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6e74 < x

    1. Initial program 29.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. *-commutative29.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-def29.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. *-commutative29.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. Simplified29.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. Step-by-step derivation
      1. fma-udef29.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x - y \cdot \left(y \cdot 4\right)}{{\left(\mathsf{hypot}\left(x, y \cdot \color{blue}{2}\right)\right)}^{2}} \]
    5. Applied egg-rr29.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 + \color{blue}{{\left(\frac{x \cdot x}{\left(y \cdot y\right) \cdot -8}\right)}^{-1}} \]
      3. associate-*l*73.7%

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

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

        \[\leadsto 1 + \color{blue}{\frac{1}{\frac{x \cdot x}{y \cdot \left(y \cdot -8\right)}}} \]
      2. associate-/l*74.0%

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

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

        \[\leadsto 1 + \frac{1}{\frac{x}{\frac{\color{blue}{{y}^{2}} \cdot -8}{x}}} \]
      5. associate-*r/74.0%

        \[\leadsto 1 + \frac{1}{\frac{x}{\color{blue}{{y}^{2} \cdot \frac{-8}{x}}}} \]
      6. associate-/r/74.0%

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

        \[\leadsto 1 + \frac{1}{x} \cdot \color{blue}{\frac{{y}^{2} \cdot -8}{x}} \]
      8. associate-*l/74.0%

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

        \[\leadsto 1 + \frac{1}{x} \cdot \left(\frac{\color{blue}{y \cdot y}}{x} \cdot -8\right) \]
      10. *-commutative74.0%

        \[\leadsto 1 + \frac{1}{x} \cdot \color{blue}{\left(-8 \cdot \frac{y \cdot y}{x}\right)} \]
      11. associate-*r/86.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7.9 \cdot 10^{-13}:\\ \;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\ \mathbf{elif}\;x \leq 0.000425:\\ \;\;\;\;1 + \frac{-8 \cdot \left(y \cdot y\right)}{x \cdot x}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+74}:\\ \;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{1}{x} \cdot \left(-8 \cdot \left(y \cdot \frac{y}{x}\right)\right)\\ \end{array} \]

Alternative 7: 73.6% accurate, 1.1× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.5500000000000001e-12 or 2.59999999999999977e-4 < x < 6.8999999999999996e74

    1. Initial program 58.1%

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

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

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

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

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

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

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

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

        \[\leadsto -1 + 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{y}^{2}} \]
      5. associate-*r/58.3%

        \[\leadsto -1 + \color{blue}{\frac{0.5 \cdot \left(x \cdot x\right)}{{y}^{2}}} \]
      6. associate-/l*58.3%

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

        \[\leadsto -1 + \frac{0.5}{\frac{\color{blue}{y \cdot y}}{x \cdot x}} \]
      8. times-frac62.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{\frac{y}{x} \cdot \frac{y}{x}}} \]
      9. unpow262.7%

        \[\leadsto -1 + \frac{0.5}{\color{blue}{{\left(\frac{y}{x}\right)}^{2}}} \]
    6. Simplified62.7%

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

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

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

    if 1.5500000000000001e-12 < x < 2.59999999999999977e-4 or 6.8999999999999996e74 < x

    1. Initial program 37.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. *-commutative37.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-def37.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. *-commutative37.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. Simplified37.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 87.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.55 \cdot 10^{-12} \lor \neg \left(x \leq 0.00026\right) \land x \leq 6.9 \cdot 10^{+74}:\\ \;\;\;\;-1 + \frac{0.5}{\frac{y}{x} \cdot \frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 8: 73.4% accurate, 2.6× speedup?

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

\mathbf{elif}\;x \leq 0.002:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq 4.8 \cdot 10^{+56}:\\
\;\;\;\;-1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.59999999999999983e-12 or 2e-3 < x < 4.80000000000000027e56

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

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

    if 2.59999999999999983e-12 < x < 2e-3 or 4.80000000000000027e56 < x

    1. Initial program 39.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.6 \cdot 10^{-12}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \leq 0.002:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{+56}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 9: 50.0% accurate, 19.0× speedup?

\[\begin{array}{l} x = |x|\\ \\ -1 \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x y) :precision binary64 -1.0)
x = abs(x);
double code(double x, double y) {
	return -1.0;
}
NOTE: x should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = -1.0d0
end function
x = Math.abs(x);
public static double code(double x, double y) {
	return -1.0;
}
x = abs(x)
def code(x, y):
	return -1.0
x = abs(x)
function code(x, y)
	return -1.0
end
x = abs(x)
function tmp = code(x, y)
	tmp = -1.0;
end
NOTE: x should be positive before calling this function
code[x_, y_] := -1.0
\begin{array}{l}
x = |x|\\
\\
-1
\end{array}
Derivation
  1. Initial program 54.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. *-commutative54.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-def54.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. *-commutative54.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. Simplified54.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 0 52.1%

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

    \[\leadsto -1 \]

Developer target: 50.7% 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 2023252 
(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))))