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

Percentage Accurate: 50.2% → 80.6%
Time: 5.2s
Alternatives: 7
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 7 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: 80.6% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;t_0 \leq 10^{-235}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;t_0 \leq 10^{+255}:\\
\;\;\;\;t_1\\

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


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

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

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

    if 1.9999999999999999e-280 < (*.f64 (*.f64 y 4) y) < 9.9999999999999996e-236 or 2e-174 < (*.f64 (*.f64 y 4) y) < 9.99999999999999988e254

    1. Initial program 82.9%

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

    if 9.9999999999999996e-236 < (*.f64 (*.f64 y 4) y) < 2e-174

    1. Initial program 54.5%

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
    2. Step-by-step derivation
      1. *-commutative54.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-def54.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. *-commutative54.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. Simplified54.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 91.6%

      \[\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+91.6%

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

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

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

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

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

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

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

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

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

    if 9.99999999999999988e254 < (*.f64 (*.f64 y 4) y)

    1. Initial program 13.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 80.6% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-174}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\

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

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


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

    1. Initial program 60.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. *-commutative60.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-def60.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. *-commutative60.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. Simplified60.9%

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

      \[\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+77.3%

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

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

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

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

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

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

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

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

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

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

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

    if 2e-174 < (*.f64 (*.f64 y 4) y) < 9.99999999999999988e254

    1. Initial program 81.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. *-commutative81.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-def81.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. *-commutative81.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. Simplified81.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)}} \]

    if 9.99999999999999988e254 < (*.f64 (*.f64 y 4) y)

    1. Initial program 13.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(y \cdot 4\right) \leq 2 \cdot 10^{-174}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\ \mathbf{elif}\;y \cdot \left(y \cdot 4\right) \leq 10^{+255}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{\frac{\frac{x}{y}}{\frac{y}{x}}}{4} + -1\\ \end{array} \]

Alternative 3: 80.6% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-174}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\

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

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


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

    1. Initial program 60.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. *-commutative60.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-def60.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. *-commutative60.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. Simplified60.9%

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

      \[\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+77.3%

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

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

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

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

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

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

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

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

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

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

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

    if 2e-174 < (*.f64 (*.f64 y 4) y) < 9.99999999999999988e254

    1. Initial program 81.4%

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

    if 9.99999999999999988e254 < (*.f64 (*.f64 y 4) y)

    1. Initial program 13.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 80.5% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;t_0 \leq 10^{-235}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-174}:\\
\;\;\;\;1\\

\mathbf{elif}\;t_0 \leq 10^{+255}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 y 4) y) < 1.9999999999999999e-280 or 9.9999999999999996e-236 < (*.f64 (*.f64 y 4) y) < 2e-174

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

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

    if 1.9999999999999999e-280 < (*.f64 (*.f64 y 4) y) < 9.9999999999999996e-236 or 2e-174 < (*.f64 (*.f64 y 4) y) < 9.99999999999999988e254

    1. Initial program 82.9%

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

    if 9.99999999999999988e254 < (*.f64 (*.f64 y 4) y)

    1. Initial program 13.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 62.4% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.2 \cdot 10^{-88}:\\
\;\;\;\;1\\

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


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

    1. Initial program 55.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. *-commutative55.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-def55.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. *-commutative55.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. Simplified55.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 55.1%

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

    if 9.19999999999999945e-88 < y

    1. Initial program 47.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 37.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}}}{4} - 1 \]
    8. Applied egg-rr75.9%

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

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

Alternative 6: 62.1% accurate, 6.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.65 \cdot 10^{-87}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
(FPCore (x y) :precision binary64 (if (<= y 1.65e-87) 1.0 -1.0))
double code(double x, double y) {
	double tmp;
	if (y <= 1.65e-87) {
		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 (y <= 1.65d-87) 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 (y <= 1.65e-87) {
		tmp = 1.0;
	} else {
		tmp = -1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 1.65e-87:
		tmp = 1.0
	else:
		tmp = -1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 1.65e-87)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 1.65e-87)
		tmp = 1.0;
	else
		tmp = -1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 1.65e-87], 1.0, -1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.65 \cdot 10^{-87}:\\
\;\;\;\;1\\

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


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

    1. Initial program 55.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. *-commutative55.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-def55.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. *-commutative55.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. Simplified55.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 55.1%

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

    if 1.65e-87 < y

    1. Initial program 47.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. *-commutative47.1%

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

        \[\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. *-commutative47.1%

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

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

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

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

Alternative 7: 49.9% 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 52.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. *-commutative52.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-def52.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. *-commutative52.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. Simplified52.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 55.4%

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

    \[\leadsto -1 \]

Developer target: 50.6% 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 2023290 
(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))))