ABCF->ab-angle b

Percentage Accurate: 20.7% → 48.7%
Time: 20.0s
Alternatives: 10
Speedup: 6.0×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\ \frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0} \end{array} \end{array} \]
(FPCore (A B C F)
 :precision binary64
 (let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
   (/
    (-
     (sqrt
      (*
       (* 2.0 (* t_0 F))
       (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
    t_0)))
double code(double A, double B, double C, double F) {
	double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
	return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    real(8) :: t_0
    t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
    code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
	double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
	return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F):
	t_0 = math.pow(B, 2.0) - ((4.0 * A) * C)
	return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F)
	t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))
	return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0)
end
function tmp = code(A, B, C, F)
	t_0 = (B ^ 2.0) - ((4.0 * A) * C);
	tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0;
end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{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 10 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: 20.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\ \frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0} \end{array} \end{array} \]
(FPCore (A B C F)
 :precision binary64
 (let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
   (/
    (-
     (sqrt
      (*
       (* 2.0 (* t_0 F))
       (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
    t_0)))
double code(double A, double B, double C, double F) {
	double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
	return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
real(8) function code(a, b, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    real(8) :: t_0
    t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
    code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
	double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
	return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F):
	t_0 = math.pow(B, 2.0) - ((4.0 * A) * C)
	return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F)
	t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))
	return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0)
end
function tmp = code(A, B, C, F)
	t_0 = (B ^ 2.0) - ((4.0 * A) * C);
	tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0;
end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}

Alternative 1: 48.7% accurate, 1.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\ \mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-40}:\\ \;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B\_m}^{2}}{C}\right)\right)\right)}}{-t\_0}\\ \mathbf{elif}\;{B\_m}^{2} \leq 10^{+292}:\\ \;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B\_m}^{2}\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
   (if (<= (pow B_m 2.0) 5e-40)
     (/
      (sqrt (* (* t_0 F) (* 2.0 (+ A (+ A (* -0.5 (/ (pow B_m 2.0) C)))))))
      (- t_0))
     (if (<= (pow B_m 2.0) 1e+292)
       (-
        (sqrt
         (*
          2.0
          (*
           F
           (/
            (- (+ A C) (hypot B_m (- A C)))
            (fma A (* C -4.0) (pow B_m 2.0)))))))
       (- (sqrt (* -2.0 (/ F B_m))))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (pow(B_m, 2.0) <= 5e-40) {
		tmp = sqrt(((t_0 * F) * (2.0 * (A + (A + (-0.5 * (pow(B_m, 2.0) / C))))))) / -t_0;
	} else if (pow(B_m, 2.0) <= 1e+292) {
		tmp = -sqrt((2.0 * (F * (((A + C) - hypot(B_m, (A - C))) / fma(A, (C * -4.0), pow(B_m, 2.0))))));
	} else {
		tmp = -sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if ((B_m ^ 2.0) <= 5e-40)
		tmp = Float64(sqrt(Float64(Float64(t_0 * F) * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64((B_m ^ 2.0) / C))))))) / Float64(-t_0));
	elseif ((B_m ^ 2.0) <= 1e+292)
		tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(Float64(A + C) - hypot(B_m, Float64(A - C))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0)))))));
	else
		tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-40], N[(N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * N[(A + N[(A + N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+292], (-N[Sqrt[N[(2.0 * N[(F * N[(N[(N[(A + C), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-40}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B\_m}^{2}}{C}\right)\right)\right)}}{-t\_0}\\

\mathbf{elif}\;{B\_m}^{2} \leq 10^{+292}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B\_m}^{2}\right)}\right)}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999965e-40

    1. Initial program 29.3%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified40.3%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}} \]
    3. Add Preprocessing
    4. Taylor expanded in C around inf 36.8%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \color{blue}{\left(-0.5 \cdot \frac{{B}^{2}}{C} - -1 \cdot A\right)}\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg36.8%

        \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \left(-0.5 \cdot \frac{{B}^{2}}{C} - \color{blue}{\left(-A\right)}\right)\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    6. Simplified36.8%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \color{blue}{\left(-0.5 \cdot \frac{{B}^{2}}{C} - \left(-A\right)\right)}\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]

    if 4.99999999999999965e-40 < (pow.f64 B #s(literal 2 binary64)) < 1e292

    1. Initial program 27.5%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 33.4%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified46.4%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod46.5%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*59.6%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-60.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine60.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative60.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*60.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define60.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr60.5%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]

    if 1e292 < (pow.f64 B #s(literal 2 binary64))

    1. Initial program 1.8%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 5.1%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified9.2%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod9.2%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*10.4%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-10.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine10.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative10.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*10.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define10.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr10.6%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in B around inf 31.0%

      \[\leadsto -\sqrt{\color{blue}{-2 \cdot \frac{F}{B}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification42.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-40}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B}^{2}}{C}\right)\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{elif}\;{B}^{2} \leq 10^{+292}:\\ \;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 48.8% accurate, 1.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\ \mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-40}:\\ \;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(A \cdot 4\right)}}{-t\_0}\\ \mathbf{elif}\;{B\_m}^{2} \leq 10^{+292}:\\ \;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B\_m}^{2}\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
   (if (<= (pow B_m 2.0) 5e-40)
     (/ (sqrt (* (* t_0 F) (* A 4.0))) (- t_0))
     (if (<= (pow B_m 2.0) 1e+292)
       (-
        (sqrt
         (*
          2.0
          (*
           F
           (/
            (- (+ A C) (hypot B_m (- A C)))
            (fma A (* C -4.0) (pow B_m 2.0)))))))
       (- (sqrt (* -2.0 (/ F B_m))))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (pow(B_m, 2.0) <= 5e-40) {
		tmp = sqrt(((t_0 * F) * (A * 4.0))) / -t_0;
	} else if (pow(B_m, 2.0) <= 1e+292) {
		tmp = -sqrt((2.0 * (F * (((A + C) - hypot(B_m, (A - C))) / fma(A, (C * -4.0), pow(B_m, 2.0))))));
	} else {
		tmp = -sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if ((B_m ^ 2.0) <= 5e-40)
		tmp = Float64(sqrt(Float64(Float64(t_0 * F) * Float64(A * 4.0))) / Float64(-t_0));
	elseif ((B_m ^ 2.0) <= 1e+292)
		tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(Float64(A + C) - hypot(B_m, Float64(A - C))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0)))))));
	else
		tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-40], N[(N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+292], (-N[Sqrt[N[(2.0 * N[(F * N[(N[(N[(A + C), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-40}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(A \cdot 4\right)}}{-t\_0}\\

\mathbf{elif}\;{B\_m}^{2} \leq 10^{+292}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B\_m}^{2}\right)}\right)}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (pow.f64 B #s(literal 2 binary64)) < 4.99999999999999965e-40

    1. Initial program 29.3%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified40.3%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}} \]
    3. Add Preprocessing
    4. Taylor expanded in A around -inf 36.5%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \color{blue}{\left(4 \cdot A\right)}}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]

    if 4.99999999999999965e-40 < (pow.f64 B #s(literal 2 binary64)) < 1e292

    1. Initial program 27.5%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 33.4%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified46.4%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod46.5%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*59.6%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-60.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine60.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative60.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*60.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define60.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr60.5%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]

    if 1e292 < (pow.f64 B #s(literal 2 binary64))

    1. Initial program 1.8%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 5.1%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified9.2%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod9.2%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*10.4%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-10.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine10.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative10.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*10.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define10.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr10.6%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in B around inf 31.0%

      \[\leadsto -\sqrt{\color{blue}{-2 \cdot \frac{F}{B}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification42.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-40}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{elif}\;{B}^{2} \leq 10^{+292}:\\ \;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 45.6% accurate, 1.2× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\ \mathbf{if}\;{B\_m}^{2} \leq 10^{-7}:\\ \;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(A \cdot 4\right)}}{-t\_0}\\ \mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+266}:\\ \;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{A - \mathsf{hypot}\left(A, B\_m\right)}{{B\_m}^{2}}\right)}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
   (if (<= (pow B_m 2.0) 1e-7)
     (/ (sqrt (* (* t_0 F) (* A 4.0))) (- t_0))
     (if (<= (pow B_m 2.0) 2e+266)
       (- (sqrt (* 2.0 (* F (/ (- A (hypot A B_m)) (pow B_m 2.0))))))
       (- (sqrt (* -2.0 (/ F B_m))))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (pow(B_m, 2.0) <= 1e-7) {
		tmp = sqrt(((t_0 * F) * (A * 4.0))) / -t_0;
	} else if (pow(B_m, 2.0) <= 2e+266) {
		tmp = -sqrt((2.0 * (F * ((A - hypot(A, B_m)) / pow(B_m, 2.0)))));
	} else {
		tmp = -sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if ((B_m ^ 2.0) <= 1e-7)
		tmp = Float64(sqrt(Float64(Float64(t_0 * F) * Float64(A * 4.0))) / Float64(-t_0));
	elseif ((B_m ^ 2.0) <= 2e+266)
		tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(A - hypot(A, B_m)) / (B_m ^ 2.0))))));
	else
		tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-7], N[(N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+266], (-N[Sqrt[N[(2.0 * N[(F * N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 10^{-7}:\\
\;\;\;\;\frac{\sqrt{\left(t\_0 \cdot F\right) \cdot \left(A \cdot 4\right)}}{-t\_0}\\

\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+266}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{A - \mathsf{hypot}\left(A, B\_m\right)}{{B\_m}^{2}}\right)}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999995e-8

    1. Initial program 30.6%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified42.7%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}} \]
    3. Add Preprocessing
    4. Taylor expanded in A around -inf 36.0%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \color{blue}{\left(4 \cdot A\right)}}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]

    if 9.9999999999999995e-8 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e266

    1. Initial program 24.6%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 31.7%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified43.3%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod43.5%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*56.6%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-57.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine57.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative57.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*57.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define57.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr57.7%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in C around 0 25.9%

      \[\leadsto -\sqrt{\color{blue}{\frac{F \cdot \left(A - \sqrt{{A}^{2} + {B}^{2}}\right)}{{B}^{2}}} \cdot 2} \]
    8. Step-by-step derivation
      1. associate-/l*30.2%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A - \sqrt{{A}^{2} + {B}^{2}}}{{B}^{2}}\right)} \cdot 2} \]
      2. unpow230.2%

        \[\leadsto -\sqrt{\left(F \cdot \frac{A - \sqrt{\color{blue}{A \cdot A} + {B}^{2}}}{{B}^{2}}\right) \cdot 2} \]
      3. unpow230.2%

        \[\leadsto -\sqrt{\left(F \cdot \frac{A - \sqrt{A \cdot A + \color{blue}{B \cdot B}}}{{B}^{2}}\right) \cdot 2} \]
      4. hypot-define33.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{A - \color{blue}{\mathsf{hypot}\left(A, B\right)}}{{B}^{2}}\right) \cdot 2} \]
    9. Simplified33.6%

      \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A - \mathsf{hypot}\left(A, B\right)}{{B}^{2}}\right)} \cdot 2} \]

    if 2.0000000000000001e266 < (pow.f64 B #s(literal 2 binary64))

    1. Initial program 3.4%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 7.5%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified11.5%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod11.4%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*14.1%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-14.1%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine14.1%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative14.1%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*14.1%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define14.3%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr14.3%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in B around inf 32.5%

      \[\leadsto -\sqrt{\color{blue}{-2 \cdot \frac{F}{B}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification34.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 10^{-7}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{+266}:\\ \;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{A - \mathsf{hypot}\left(A, B\right)}{{B}^{2}}\right)}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 44.4% accurate, 1.2× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;{B\_m}^{2} \leq 10^{-7}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+266}:\\ \;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{A - \mathsf{hypot}\left(A, B\_m\right)}{{B\_m}^{2}}\right)}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (if (<= (pow B_m 2.0) 1e-7)
   (/
    (sqrt (* (* (fma B_m B_m (* A (* C -4.0))) F) (* A 4.0)))
    (* C (* A 4.0)))
   (if (<= (pow B_m 2.0) 2e+266)
     (- (sqrt (* 2.0 (* F (/ (- A (hypot A B_m)) (pow B_m 2.0))))))
     (- (sqrt (* -2.0 (/ F B_m)))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (pow(B_m, 2.0) <= 1e-7) {
		tmp = sqrt(((fma(B_m, B_m, (A * (C * -4.0))) * F) * (A * 4.0))) / (C * (A * 4.0));
	} else if (pow(B_m, 2.0) <= 2e+266) {
		tmp = -sqrt((2.0 * (F * ((A - hypot(A, B_m)) / pow(B_m, 2.0)))));
	} else {
		tmp = -sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if ((B_m ^ 2.0) <= 1e-7)
		tmp = Float64(sqrt(Float64(Float64(fma(B_m, B_m, Float64(A * Float64(C * -4.0))) * F) * Float64(A * 4.0))) / Float64(C * Float64(A * 4.0)));
	elseif ((B_m ^ 2.0) <= 2e+266)
		tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(A - hypot(A, B_m)) / (B_m ^ 2.0))))));
	else
		tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-7], N[(N[Sqrt[N[(N[(N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+266], (-N[Sqrt[N[(2.0 * N[(F * N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 10^{-7}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\

\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+266}:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{A - \mathsf{hypot}\left(A, B\_m\right)}{{B\_m}^{2}}\right)}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999995e-8

    1. Initial program 30.6%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified42.7%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}} \]
    3. Add Preprocessing
    4. Taylor expanded in A around -inf 36.0%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \color{blue}{\left(4 \cdot A\right)}}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    5. Taylor expanded in B around 0 35.3%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(4 \cdot A\right)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    6. Step-by-step derivation
      1. associate-*r*35.3%

        \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(4 \cdot A\right)}}{\color{blue}{\left(4 \cdot A\right) \cdot C}} \]
    7. Simplified35.3%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(4 \cdot A\right)}}{\color{blue}{\left(4 \cdot A\right) \cdot C}} \]

    if 9.9999999999999995e-8 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e266

    1. Initial program 24.6%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 31.7%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified43.3%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod43.5%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*56.6%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-57.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine57.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative57.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*57.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define57.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr57.7%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in C around 0 25.9%

      \[\leadsto -\sqrt{\color{blue}{\frac{F \cdot \left(A - \sqrt{{A}^{2} + {B}^{2}}\right)}{{B}^{2}}} \cdot 2} \]
    8. Step-by-step derivation
      1. associate-/l*30.2%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A - \sqrt{{A}^{2} + {B}^{2}}}{{B}^{2}}\right)} \cdot 2} \]
      2. unpow230.2%

        \[\leadsto -\sqrt{\left(F \cdot \frac{A - \sqrt{\color{blue}{A \cdot A} + {B}^{2}}}{{B}^{2}}\right) \cdot 2} \]
      3. unpow230.2%

        \[\leadsto -\sqrt{\left(F \cdot \frac{A - \sqrt{A \cdot A + \color{blue}{B \cdot B}}}{{B}^{2}}\right) \cdot 2} \]
      4. hypot-define33.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{A - \color{blue}{\mathsf{hypot}\left(A, B\right)}}{{B}^{2}}\right) \cdot 2} \]
    9. Simplified33.6%

      \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A - \mathsf{hypot}\left(A, B\right)}{{B}^{2}}\right)} \cdot 2} \]

    if 2.0000000000000001e266 < (pow.f64 B #s(literal 2 binary64))

    1. Initial program 3.4%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 7.5%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified11.5%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod11.4%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*14.1%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-14.1%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine14.1%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative14.1%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*14.1%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define14.3%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr14.3%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in B around inf 32.5%

      \[\leadsto -\sqrt{\color{blue}{-2 \cdot \frac{F}{B}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification34.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 10^{-7}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{+266}:\\ \;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{A - \mathsf{hypot}\left(A, B\right)}{{B}^{2}}\right)}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 44.0% accurate, 1.2× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;{B\_m}^{2} \leq 10^{-7}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+306}:\\ \;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (if (<= (pow B_m 2.0) 1e-7)
   (/
    (sqrt (* (* (fma B_m B_m (* A (* C -4.0))) F) (* A 4.0)))
    (* C (* A 4.0)))
   (if (<= (pow B_m 2.0) 2e+306)
     (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A))))))
     (- (sqrt (* -2.0 (/ F B_m)))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (pow(B_m, 2.0) <= 1e-7) {
		tmp = sqrt(((fma(B_m, B_m, (A * (C * -4.0))) * F) * (A * 4.0))) / (C * (A * 4.0));
	} else if (pow(B_m, 2.0) <= 2e+306) {
		tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
	} else {
		tmp = -sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if ((B_m ^ 2.0) <= 1e-7)
		tmp = Float64(sqrt(Float64(Float64(fma(B_m, B_m, Float64(A * Float64(C * -4.0))) * F) * Float64(A * 4.0))) / Float64(C * Float64(A * 4.0)));
	elseif ((B_m ^ 2.0) <= 2e+306)
		tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A))))));
	else
		tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-7], N[(N[Sqrt[N[(N[(N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+306], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], (-N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 10^{-7}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\

\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+306}:\\
\;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999995e-8

    1. Initial program 30.6%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified42.7%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}} \]
    3. Add Preprocessing
    4. Taylor expanded in A around -inf 36.0%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \color{blue}{\left(4 \cdot A\right)}}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    5. Taylor expanded in B around 0 35.3%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(4 \cdot A\right)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    6. Step-by-step derivation
      1. associate-*r*35.3%

        \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(4 \cdot A\right)}}{\color{blue}{\left(4 \cdot A\right) \cdot C}} \]
    7. Simplified35.3%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(4 \cdot A\right)}}{\color{blue}{\left(4 \cdot A\right) \cdot C}} \]

    if 9.9999999999999995e-8 < (pow.f64 B #s(literal 2 binary64)) < 2.00000000000000003e306

    1. Initial program 24.9%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in C around 0 19.4%

      \[\leadsto \color{blue}{-1 \cdot \left(\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \sqrt{{A}^{2} + {B}^{2}}\right)}\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg19.4%

        \[\leadsto \color{blue}{-\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \sqrt{{A}^{2} + {B}^{2}}\right)}} \]
      2. +-commutative19.4%

        \[\leadsto -\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \sqrt{\color{blue}{{B}^{2} + {A}^{2}}}\right)} \]
      3. unpow219.4%

        \[\leadsto -\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \sqrt{\color{blue}{B \cdot B} + {A}^{2}}\right)} \]
      4. unpow219.4%

        \[\leadsto -\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \sqrt{B \cdot B + \color{blue}{A \cdot A}}\right)} \]
      5. hypot-define21.2%

        \[\leadsto -\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \color{blue}{\mathsf{hypot}\left(B, A\right)}\right)} \]
    5. Simplified21.2%

      \[\leadsto \color{blue}{-\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}} \]

    if 2.00000000000000003e306 < (pow.f64 B #s(literal 2 binary64))

    1. Initial program 0.0%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 1.8%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified6.2%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod6.2%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*7.5%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-7.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine7.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative7.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*7.5%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define7.8%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr7.8%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in B around inf 30.0%

      \[\leadsto -\sqrt{\color{blue}{-2 \cdot \frac{F}{B}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification30.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 10^{-7}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{+306}:\\ \;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 41.8% accurate, 1.5× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;{B\_m}^{2} \leq 10^{-109}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+132}:\\ \;\;\;\;-\sqrt{\frac{F}{-C}}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \left(F \cdot \frac{A + C}{B\_m}\right)\right)}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (if (<= (pow B_m 2.0) 1e-109)
   (/
    (sqrt (* (* (fma B_m B_m (* A (* C -4.0))) F) (* A 4.0)))
    (* C (* A 4.0)))
   (if (<= (pow B_m 2.0) 5e+132)
     (- (sqrt (/ F (- C))))
     (- (sqrt (/ (fma -2.0 F (* 2.0 (* F (/ (+ A C) B_m)))) B_m))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (pow(B_m, 2.0) <= 1e-109) {
		tmp = sqrt(((fma(B_m, B_m, (A * (C * -4.0))) * F) * (A * 4.0))) / (C * (A * 4.0));
	} else if (pow(B_m, 2.0) <= 5e+132) {
		tmp = -sqrt((F / -C));
	} else {
		tmp = -sqrt((fma(-2.0, F, (2.0 * (F * ((A + C) / B_m)))) / B_m));
	}
	return tmp;
}
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if ((B_m ^ 2.0) <= 1e-109)
		tmp = Float64(sqrt(Float64(Float64(fma(B_m, B_m, Float64(A * Float64(C * -4.0))) * F) * Float64(A * 4.0))) / Float64(C * Float64(A * 4.0)));
	elseif ((B_m ^ 2.0) <= 5e+132)
		tmp = Float64(-sqrt(Float64(F / Float64(-C))));
	else
		tmp = Float64(-sqrt(Float64(fma(-2.0, F, Float64(2.0 * Float64(F * Float64(Float64(A + C) / B_m)))) / B_m)));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-109], N[(N[Sqrt[N[(N[(N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+132], (-N[Sqrt[N[(F / (-C)), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(N[(-2.0 * F + N[(2.0 * N[(F * N[(N[(A + C), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 10^{-109}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\

\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+132}:\\
\;\;\;\;-\sqrt{\frac{F}{-C}}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \left(F \cdot \frac{A + C}{B\_m}\right)\right)}{B\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (pow.f64 B #s(literal 2 binary64)) < 9.9999999999999999e-110

    1. Initial program 31.3%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified42.2%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}} \]
    3. Add Preprocessing
    4. Taylor expanded in A around -inf 37.6%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \color{blue}{\left(4 \cdot A\right)}}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    5. Taylor expanded in B around 0 36.9%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(4 \cdot A\right)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    6. Step-by-step derivation
      1. associate-*r*36.9%

        \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(4 \cdot A\right)}}{\color{blue}{\left(4 \cdot A\right) \cdot C}} \]
    7. Simplified36.9%

      \[\leadsto \frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(4 \cdot A\right)}}{\color{blue}{\left(4 \cdot A\right) \cdot C}} \]

    if 9.9999999999999999e-110 < (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000001e132

    1. Initial program 25.9%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 29.2%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified41.3%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod41.3%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*46.9%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-48.3%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine48.3%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative48.3%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*48.3%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define48.3%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr48.3%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in A around -inf 24.3%

      \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{C}}} \]
    8. Step-by-step derivation
      1. associate-*r/24.3%

        \[\leadsto -\sqrt{\color{blue}{\frac{-1 \cdot F}{C}}} \]
      2. mul-1-neg24.3%

        \[\leadsto -\sqrt{\frac{\color{blue}{-F}}{C}} \]
    9. Simplified24.3%

      \[\leadsto -\sqrt{\color{blue}{\frac{-F}{C}}} \]

    if 5.0000000000000001e132 < (pow.f64 B #s(literal 2 binary64))

    1. Initial program 9.4%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 15.4%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified22.7%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod22.7%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*31.7%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-31.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine31.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative31.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*31.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define31.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr31.7%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in B around inf 26.2%

      \[\leadsto -\sqrt{\color{blue}{\frac{-2 \cdot F + 2 \cdot \frac{F \cdot \left(A + C\right)}{B}}{B}}} \]
    8. Step-by-step derivation
      1. fma-define26.2%

        \[\leadsto -\sqrt{\frac{\color{blue}{\mathsf{fma}\left(-2, F, 2 \cdot \frac{F \cdot \left(A + C\right)}{B}\right)}}{B}} \]
      2. associate-/l*31.3%

        \[\leadsto -\sqrt{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \color{blue}{\left(F \cdot \frac{A + C}{B}\right)}\right)}{B}} \]
    9. Simplified31.3%

      \[\leadsto -\sqrt{\color{blue}{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \left(F \cdot \frac{A + C}{B}\right)\right)}{B}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification32.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 10^{-109}:\\ \;\;\;\;\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(A \cdot 4\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{elif}\;{B}^{2} \leq 5 \cdot 10^{+132}:\\ \;\;\;\;-\sqrt{\frac{F}{-C}}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \left(F \cdot \frac{A + C}{B}\right)\right)}{B}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 39.5% accurate, 2.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{+132}:\\ \;\;\;\;-\sqrt{\frac{F}{-C}}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \left(F \cdot \frac{A + C}{B\_m}\right)\right)}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (if (<= (pow B_m 2.0) 5e+132)
   (- (sqrt (/ F (- C))))
   (- (sqrt (/ (fma -2.0 F (* 2.0 (* F (/ (+ A C) B_m)))) B_m)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (pow(B_m, 2.0) <= 5e+132) {
		tmp = -sqrt((F / -C));
	} else {
		tmp = -sqrt((fma(-2.0, F, (2.0 * (F * ((A + C) / B_m)))) / B_m));
	}
	return tmp;
}
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if ((B_m ^ 2.0) <= 5e+132)
		tmp = Float64(-sqrt(Float64(F / Float64(-C))));
	else
		tmp = Float64(-sqrt(Float64(fma(-2.0, F, Float64(2.0 * Float64(F * Float64(Float64(A + C) / B_m)))) / B_m)));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+132], (-N[Sqrt[N[(F / (-C)), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(N[(-2.0 * F + N[(2.0 * N[(F * N[(N[(A + C), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{+132}:\\
\;\;\;\;-\sqrt{\frac{F}{-C}}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \left(F \cdot \frac{A + C}{B\_m}\right)\right)}{B\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000001e132

    1. Initial program 29.5%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 21.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified29.5%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod29.6%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*31.8%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-35.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine35.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative35.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*35.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define35.4%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr35.4%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in A around -inf 18.9%

      \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{C}}} \]
    8. Step-by-step derivation
      1. associate-*r/18.9%

        \[\leadsto -\sqrt{\color{blue}{\frac{-1 \cdot F}{C}}} \]
      2. mul-1-neg18.9%

        \[\leadsto -\sqrt{\frac{\color{blue}{-F}}{C}} \]
    9. Simplified18.9%

      \[\leadsto -\sqrt{\color{blue}{\frac{-F}{C}}} \]

    if 5.0000000000000001e132 < (pow.f64 B #s(literal 2 binary64))

    1. Initial program 9.4%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 15.4%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified22.7%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod22.7%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*31.7%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-31.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine31.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative31.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*31.6%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define31.7%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr31.7%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in B around inf 26.2%

      \[\leadsto -\sqrt{\color{blue}{\frac{-2 \cdot F + 2 \cdot \frac{F \cdot \left(A + C\right)}{B}}{B}}} \]
    8. Step-by-step derivation
      1. fma-define26.2%

        \[\leadsto -\sqrt{\frac{\color{blue}{\mathsf{fma}\left(-2, F, 2 \cdot \frac{F \cdot \left(A + C\right)}{B}\right)}}{B}} \]
      2. associate-/l*31.3%

        \[\leadsto -\sqrt{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \color{blue}{\left(F \cdot \frac{A + C}{B}\right)}\right)}{B}} \]
    9. Simplified31.3%

      \[\leadsto -\sqrt{\color{blue}{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \left(F \cdot \frac{A + C}{B}\right)\right)}{B}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification23.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{+132}:\\ \;\;\;\;-\sqrt{\frac{F}{-C}}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{\frac{\mathsf{fma}\left(-2, F, 2 \cdot \left(F \cdot \frac{A + C}{B}\right)\right)}{B}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 39.4% accurate, 5.7× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;B\_m \leq 1.85 \cdot 10^{+66}:\\ \;\;\;\;-\sqrt{\frac{F}{-C}}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (if (<= B_m 1.85e+66) (- (sqrt (/ F (- C)))) (- (sqrt (* -2.0 (/ F B_m))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 1.85e+66) {
		tmp = -sqrt((F / -C));
	} else {
		tmp = -sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    real(8) :: tmp
    if (b_m <= 1.85d+66) then
        tmp = -sqrt((f / -c))
    else
        tmp = -sqrt(((-2.0d0) * (f / b_m)))
    end if
    code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 1.85e+66) {
		tmp = -Math.sqrt((F / -C));
	} else {
		tmp = -Math.sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	tmp = 0
	if B_m <= 1.85e+66:
		tmp = -math.sqrt((F / -C))
	else:
		tmp = -math.sqrt((-2.0 * (F / B_m)))
	return tmp
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if (B_m <= 1.85e+66)
		tmp = Float64(-sqrt(Float64(F / Float64(-C))));
	else
		tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / B_m))));
	end
	return tmp
end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
	tmp = 0.0;
	if (B_m <= 1.85e+66)
		tmp = -sqrt((F / -C));
	else
		tmp = -sqrt((-2.0 * (F / B_m)));
	end
	tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 1.85e+66], (-N[Sqrt[N[(F / (-C)), $MachinePrecision]], $MachinePrecision]), (-N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 1.85 \cdot 10^{+66}:\\
\;\;\;\;-\sqrt{\frac{F}{-C}}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < 1.85e66

    1. Initial program 24.7%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 18.9%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified26.5%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod26.6%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*29.3%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-32.0%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine32.0%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative32.0%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*32.0%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define32.1%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr32.1%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in A around -inf 15.7%

      \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{C}}} \]
    8. Step-by-step derivation
      1. associate-*r/15.7%

        \[\leadsto -\sqrt{\color{blue}{\frac{-1 \cdot F}{C}}} \]
      2. mul-1-neg15.7%

        \[\leadsto -\sqrt{\frac{\color{blue}{-F}}{C}} \]
    9. Simplified15.7%

      \[\leadsto -\sqrt{\color{blue}{\frac{-F}{C}}} \]

    if 1.85e66 < B

    1. Initial program 10.3%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in F around 0 19.4%

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
    4. Simplified29.7%

      \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
    5. Step-by-step derivation
      1. sqrt-unprod29.7%

        \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
      2. associate-/l*43.9%

        \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
      3. associate-+r-43.9%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
      4. fma-undefine43.9%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
      5. *-commutative43.9%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
      6. associate-*r*43.9%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
      7. fma-define44.0%

        \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
    6. Applied egg-rr44.0%

      \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
    7. Taylor expanded in B around inf 63.9%

      \[\leadsto -\sqrt{\color{blue}{-2 \cdot \frac{F}{B}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification23.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq 1.85 \cdot 10^{+66}:\\ \;\;\;\;-\sqrt{\frac{F}{-C}}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 27.1% accurate, 6.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ -\sqrt{\frac{F}{-C}} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F) :precision binary64 (- (sqrt (/ F (- C)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	return -sqrt((F / -C));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    code = -sqrt((f / -c))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	return -Math.sqrt((F / -C));
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	return -math.sqrt((F / -C))
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	return Float64(-sqrt(Float64(F / Float64(-C))))
end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
	tmp = -sqrt((F / -C));
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := (-N[Sqrt[N[(F / (-C)), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
-\sqrt{\frac{F}{-C}}
\end{array}
Derivation
  1. Initial program 22.2%

    \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
  2. Add Preprocessing
  3. Taylor expanded in F around 0 19.0%

    \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
  4. Simplified27.0%

    \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
  5. Step-by-step derivation
    1. sqrt-unprod27.1%

      \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
    2. associate-/l*31.8%

      \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
    3. associate-+r-34.0%

      \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
    4. fma-undefine34.0%

      \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
    5. *-commutative34.0%

      \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
    6. associate-*r*34.0%

      \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
    7. fma-define34.1%

      \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
  6. Applied egg-rr34.1%

    \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
  7. Taylor expanded in A around -inf 14.3%

    \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{C}}} \]
  8. Step-by-step derivation
    1. associate-*r/14.3%

      \[\leadsto -\sqrt{\color{blue}{\frac{-1 \cdot F}{C}}} \]
    2. mul-1-neg14.3%

      \[\leadsto -\sqrt{\frac{\color{blue}{-F}}{C}} \]
  9. Simplified14.3%

    \[\leadsto -\sqrt{\color{blue}{\frac{-F}{C}}} \]
  10. Final simplification14.3%

    \[\leadsto -\sqrt{\frac{F}{-C}} \]
  11. Add Preprocessing

Alternative 10: 1.8% accurate, 6.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ -\sqrt{\frac{F}{-A}} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F) :precision binary64 (- (sqrt (/ F (- A)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	return -sqrt((F / -A));
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    code = -sqrt((f / -a))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	return -Math.sqrt((F / -A));
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	return -math.sqrt((F / -A))
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	return Float64(-sqrt(Float64(F / Float64(-A))))
end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
	tmp = -sqrt((F / -A));
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := (-N[Sqrt[N[(F / (-A)), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
-\sqrt{\frac{F}{-A}}
\end{array}
Derivation
  1. Initial program 22.2%

    \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
  2. Add Preprocessing
  3. Taylor expanded in F around 0 19.0%

    \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
  4. Simplified27.0%

    \[\leadsto \color{blue}{-\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}} \cdot \sqrt{2}} \]
  5. Step-by-step derivation
    1. sqrt-unprod27.1%

      \[\leadsto -\color{blue}{\sqrt{\frac{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)} \cdot 2}} \]
    2. associate-/l*31.8%

      \[\leadsto -\sqrt{\color{blue}{\left(F \cdot \frac{A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right)} \cdot 2} \]
    3. associate-+r-34.0%

      \[\leadsto -\sqrt{\left(F \cdot \frac{\color{blue}{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}}{\mathsf{fma}\left(-4, A \cdot C, {B}^{2}\right)}\right) \cdot 2} \]
    4. fma-undefine34.0%

      \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{-4 \cdot \left(A \cdot C\right) + {B}^{2}}}\right) \cdot 2} \]
    5. *-commutative34.0%

      \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\left(A \cdot C\right) \cdot -4} + {B}^{2}}\right) \cdot 2} \]
    6. associate-*r*34.0%

      \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{A \cdot \left(C \cdot -4\right)} + {B}^{2}}\right) \cdot 2} \]
    7. fma-define34.1%

      \[\leadsto -\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\color{blue}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}}\right) \cdot 2} \]
  6. Applied egg-rr34.1%

    \[\leadsto -\color{blue}{\sqrt{\left(F \cdot \frac{\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right) \cdot 2}} \]
  7. Taylor expanded in C around -inf 10.5%

    \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{A}}} \]
  8. Step-by-step derivation
    1. associate-*r/10.5%

      \[\leadsto -\sqrt{\color{blue}{\frac{-1 \cdot F}{A}}} \]
    2. mul-1-neg10.5%

      \[\leadsto -\sqrt{\frac{\color{blue}{-F}}{A}} \]
  9. Simplified10.5%

    \[\leadsto -\sqrt{\color{blue}{\frac{-F}{A}}} \]
  10. Final simplification10.5%

    \[\leadsto -\sqrt{\frac{F}{-A}} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024181 
(FPCore (A B C F)
  :name "ABCF->ab-angle b"
  :precision binary64
  (/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))