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

Percentage Accurate: 52.1% → 81.8%
Time: 7.2s
Alternatives: 8
Speedup: 6.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

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

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


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

    1. Initial program 51.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) + -1 \]
      3. un-div-inv87.5%

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

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

    if 1e-296 < (*.f64 x x) < 1e269

    1. Initial program 83.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. clear-num83.9%

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{\left(-\color{blue}{y \cdot \left(y \cdot 4\right)}\right) + x \cdot x}\right)}^{-1} \]
      8. distribute-rgt-neg-in83.9%

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

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{\color{blue}{\mathsf{fma}\left(y, -y \cdot 4, x \cdot x\right)}}\right)}^{-1} \]
      10. distribute-rgt-neg-in83.9%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{\mathsf{fma}\left(y, \color{blue}{y \cdot \left(-4\right)}, x \cdot x\right)}\right)}^{-1} \]
      11. metadata-eval83.9%

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

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

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

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

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{\mathsf{fma}\left(y, \sqrt{\color{blue}{\left(y \cdot y\right) \cdot \left(-4 \cdot -4\right)}}, x \cdot x\right)}\right)}^{-1} \]
      4. metadata-eval69.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{\mathsf{fma}\left(y, \sqrt{\left(y \cdot y\right) \cdot \color{blue}{16}}, x \cdot x\right)}\right)}^{-1} \]
      5. metadata-eval69.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{\mathsf{fma}\left(y, \sqrt{\left(y \cdot y\right) \cdot \color{blue}{\left(4 \cdot 4\right)}}, x \cdot x\right)}\right)}^{-1} \]
      6. swap-sqr69.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{\mathsf{fma}\left(y, \sqrt{\color{blue}{\left(y \cdot 4\right) \cdot \left(y \cdot 4\right)}}, x \cdot x\right)}\right)}^{-1} \]
      7. sqrt-unprod27.0%

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x \cdot x + y \cdot \color{blue}{\left(\sqrt{y \cdot 4} \cdot \sqrt{y \cdot 4}\right)}}\right)}^{-1} \]
      14. sqrt-unprod69.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x \cdot x + y \cdot \color{blue}{\sqrt{\left(y \cdot 4\right) \cdot \left(y \cdot 4\right)}}}\right)}^{-1} \]
      15. swap-sqr69.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x \cdot x + y \cdot \sqrt{\color{blue}{\left(y \cdot y\right) \cdot \left(4 \cdot 4\right)}}}\right)}^{-1} \]
      16. metadata-eval69.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x \cdot x + y \cdot \sqrt{\left(y \cdot y\right) \cdot \color{blue}{16}}}\right)}^{-1} \]
      17. metadata-eval69.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x \cdot x + y \cdot \sqrt{\left(y \cdot y\right) \cdot \color{blue}{\left(-4 \cdot -4\right)}}}\right)}^{-1} \]
      18. swap-sqr69.0%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x \cdot x + y \cdot \sqrt{\color{blue}{\left(y \cdot -4\right) \cdot \left(y \cdot -4\right)}}}\right)}^{-1} \]
      19. sqrt-unprod41.9%

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

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x \cdot x + y \cdot \color{blue}{\left(y \cdot -4\right)}}\right)}^{-1} \]
      21. associate-*r*83.9%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x \cdot x + \color{blue}{\left(y \cdot y\right) \cdot -4}}\right)}^{-1} \]
      22. metadata-eval83.9%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x \cdot x + \left(y \cdot y\right) \cdot \color{blue}{\left(-4\right)}}\right)}^{-1} \]
      23. distribute-rgt-neg-in83.9%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{x \cdot x + \color{blue}{\left(-\left(y \cdot y\right) \cdot 4\right)}}\right)}^{-1} \]
      24. associate-*r*83.9%

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

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

    if 1e269 < (*.f64 x x)

    1. Initial program 11.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 81.8% accurate, 0.2× speedup?

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

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

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

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


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

    1. Initial program 51.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) + -1 \]
      3. un-div-inv87.5%

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

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

    if 1e-296 < (*.f64 x x) < 1e269

    1. Initial program 83.9%

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

    if 1e269 < (*.f64 x x)

    1. Initial program 11.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 81.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := -4 \cdot \frac{\frac{y}{x}}{\frac{x}{y}}\\
\mathbf{if}\;x \cdot x \leq 10^{-296}:\\
\;\;\;\;0.5 \cdot \frac{\frac{x}{y}}{\frac{y}{x}} + -1\\

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

\mathbf{else}:\\
\;\;\;\;t_1 + \left(1 + t_1\right)\\


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

    1. Initial program 51.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) + -1 \]
      3. un-div-inv87.5%

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

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

    if 1e-296 < (*.f64 x x) < 1e269

    1. Initial program 83.9%

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

    if 1e269 < (*.f64 x x)

    1. Initial program 11.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. clear-num11.5%

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

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

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

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

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

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{\color{blue}{\left(-\left(y \cdot 4\right) \cdot y\right) + x \cdot x}}\right)}^{-1} \]
      7. *-commutative11.5%

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{\left(-\color{blue}{y \cdot \left(y \cdot 4\right)}\right) + x \cdot x}\right)}^{-1} \]
      8. distribute-rgt-neg-in11.5%

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

        \[\leadsto {\left(\frac{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}{\color{blue}{\mathsf{fma}\left(y, -y \cdot 4, x \cdot x\right)}}\right)}^{-1} \]
      10. distribute-rgt-neg-in11.5%

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

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

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

      \[\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. cancel-sign-sub-inv82.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 81.7% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 51.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) + -1 \]
      3. un-div-inv87.5%

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

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

    if 1e-296 < (*.f64 x x) < 1e269

    1. Initial program 83.9%

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

    if 1e269 < (*.f64 x x)

    1. Initial program 11.5%

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    5. Taylor expanded in x around inf 82.1%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 74.9% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-126}:\\
\;\;\;\;0.5 \cdot \frac{\frac{x}{y}}{\frac{y}{x}} + -1\\

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


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

    1. Initial program 61.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \left(\frac{x}{y} \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right) + -1 \]
      3. un-div-inv80.9%

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

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

    if 5.00000000000000006e-126 < (*.f64 x x)

    1. Initial program 48.3%

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    5. Taylor expanded in x around inf 74.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 63.1% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 56.1%

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

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

    if 5.50000000000000043e-63 < x

    1. Initial program 46.4%

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

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

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

      \[\leadsto \frac{\color{blue}{x \cdot x}}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    5. Taylor expanded in x around inf 67.3%

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

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

        \[\leadsto 1 + -4 \cdot \frac{y \cdot y}{\color{blue}{x \cdot x}} \]
      3. times-frac71.0%

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

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

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

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

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

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

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

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

Alternative 7: 63.1% accurate, 6.2× speedup?

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

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

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


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

    1. Initial program 56.7%

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

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

    if 5.0000000000000002e-27 < x

    1. Initial program 43.9%

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

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

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

Alternative 8: 50.4% accurate, 19.0× speedup?

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

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

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

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

    \[\leadsto -1 \]

Developer target: 52.5% 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 2023200 
(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))))