ABCF->ab-angle b

Percentage Accurate: 18.5% → 47.6%
Time: 24.0s
Alternatives: 7
Speedup: 5.4×

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 7 alternatives:

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

Initial Program: 18.5% 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: 47.6% accurate, 0.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} t_0 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\ \mathbf{if}\;{B_m}^{2} \leq 10^{-82}:\\ \;\;\;\;\frac{1}{\frac{t_0}{-\sqrt{A \cdot \left(-8 \cdot \left(F \cdot \left(C \cdot \left(2 \cdot A\right)\right)\right)\right)}}}\\ \mathbf{elif}\;{B_m}^{2} \leq 10^{+305}:\\ \;\;\;\;\frac{\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)} \cdot \left(-\sqrt{2 \cdot t_0}\right)}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)\\ \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 A (* C -4.0) (pow B_m 2.0))))
   (if (<= (pow B_m 2.0) 1e-82)
     (/ 1.0 (/ t_0 (- (sqrt (* A (* -8.0 (* F (* C (* 2.0 A)))))))))
     (if (<= (pow B_m 2.0) 1e+305)
       (/
        (* (sqrt (* F (+ A (- C (hypot B_m (- A C)))))) (- (sqrt (* 2.0 t_0))))
        t_0)
       (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m 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) {
	double t_0 = fma(A, (C * -4.0), pow(B_m, 2.0));
	double tmp;
	if (pow(B_m, 2.0) <= 1e-82) {
		tmp = 1.0 / (t_0 / -sqrt((A * (-8.0 * (F * (C * (2.0 * A)))))));
	} else if (pow(B_m, 2.0) <= 1e+305) {
		tmp = (sqrt((F * (A + (C - hypot(B_m, (A - C)))))) * -sqrt((2.0 * t_0))) / t_0;
	} else {
		tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
	}
	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(A, Float64(C * -4.0), (B_m ^ 2.0))
	tmp = 0.0
	if ((B_m ^ 2.0) <= 1e-82)
		tmp = Float64(1.0 / Float64(t_0 / Float64(-sqrt(Float64(A * Float64(-8.0 * Float64(F * Float64(C * Float64(2.0 * A)))))))));
	elseif ((B_m ^ 2.0) <= 1e+305)
		tmp = Float64(Float64(sqrt(Float64(F * Float64(A + Float64(C - hypot(B_m, Float64(A - C)))))) * Float64(-sqrt(Float64(2.0 * t_0)))) / t_0);
	else
		tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A))))));
	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[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-82], N[(1.0 / N[(t$95$0 / (-N[Sqrt[N[(A * N[(-8.0 * N[(F * N[(C * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+305], N[(N[(N[Sqrt[N[(F * N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$0), $MachinePrecision], 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]]]]
\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(A, C \cdot -4, {B_m}^{2}\right)\\
\mathbf{if}\;{B_m}^{2} \leq 10^{-82}:\\
\;\;\;\;\frac{1}{\frac{t_0}{-\sqrt{A \cdot \left(-8 \cdot \left(F \cdot \left(C \cdot \left(2 \cdot A\right)\right)\right)\right)}}}\\

\mathbf{elif}\;{B_m}^{2} \leq 10^{+305}:\\
\;\;\;\;\frac{\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)} \cdot \left(-\sqrt{2 \cdot t_0}\right)}{t_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2}}{B_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (pow.f64 B 2) < 1e-82

    1. Initial program 22.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. Simplified27.6%

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

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

        \[\leadsto \frac{-\sqrt{\color{blue}{\left(-8 \cdot A\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      2. rem-square-sqrt0.0%

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

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

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

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

        \[\leadsto \frac{-\sqrt{\left(A \cdot \color{blue}{-8}\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      7. associate-*r*23.0%

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

        \[\leadsto \frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\color{blue}{\left(F \cdot C\right)} \cdot \left(A - -1 \cdot A\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      9. sub-neg23.0%

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}{-\sqrt{A \cdot \left(-8 \cdot \left(\left(F \cdot C\right) \cdot \color{blue}{\left(2 \cdot A\right)}\right)\right)}}\right)}^{-1} \]
    7. Applied egg-rr23.0%

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

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

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

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

    if 1e-82 < (pow.f64 B 2) < 9.9999999999999994e304

    1. Initial program 25.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. Simplified23.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999994e304 < (pow.f64 B 2)

    1. Initial program 0.1%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 10^{-82}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}{-\sqrt{A \cdot \left(-8 \cdot \left(F \cdot \left(C \cdot \left(2 \cdot A\right)\right)\right)\right)}}}\\ \mathbf{elif}\;{B}^{2} \leq 10^{+305}:\\ \;\;\;\;\frac{\sqrt{F \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)} \cdot \left(-\sqrt{2 \cdot \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)\\ \end{array} \]

Alternative 2: 46.3% 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 2 \cdot 10^{-89}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}{-\sqrt{A \cdot \left(-8 \cdot \left(F \cdot \left(C \cdot \left(2 \cdot A\right)\right)\right)\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B_m}\right)\\ \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) 2e-89)
   (/
    1.0
    (/
     (fma A (* C -4.0) (pow B_m 2.0))
     (- (sqrt (* A (* -8.0 (* F (* C (* 2.0 A)))))))))
   (* (sqrt (* F (- A (hypot B_m A)))) (- (/ (sqrt 2.0) 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) <= 2e-89) {
		tmp = 1.0 / (fma(A, (C * -4.0), pow(B_m, 2.0)) / -sqrt((A * (-8.0 * (F * (C * (2.0 * A)))))));
	} else {
		tmp = sqrt((F * (A - hypot(B_m, A)))) * -(sqrt(2.0) / 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) <= 2e-89)
		tmp = Float64(1.0 / Float64(fma(A, Float64(C * -4.0), (B_m ^ 2.0)) / Float64(-sqrt(Float64(A * Float64(-8.0 * Float64(F * Float64(C * Float64(2.0 * A)))))))));
	else
		tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(-Float64(sqrt(2.0) / 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], 2e-89], N[(1.0 / N[(N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[N[(A * N[(-8.0 * N[(F * N[(C * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[(N[Sqrt[2.0], $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 2 \cdot 10^{-89}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}{-\sqrt{A \cdot \left(-8 \cdot \left(F \cdot \left(C \cdot \left(2 \cdot A\right)\right)\right)\right)}}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B_m}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 B 2) < 2.00000000000000008e-89

    1. Initial program 23.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. Simplified28.3%

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

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

        \[\leadsto \frac{-\sqrt{\color{blue}{\left(-8 \cdot A\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      2. rem-square-sqrt0.0%

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

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

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

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

        \[\leadsto \frac{-\sqrt{\left(A \cdot \color{blue}{-8}\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      7. associate-*r*23.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000008e-89 < (pow.f64 B 2)

    1. Initial program 13.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. Simplified12.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-89}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}{-\sqrt{A \cdot \left(-8 \cdot \left(F \cdot \left(C \cdot \left(2 \cdot A\right)\right)\right)\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)\\ \end{array} \]

Alternative 3: 46.3% 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 2 \cdot 10^{-89}:\\ \;\;\;\;-\frac{\sqrt{A \cdot \left(-8 \cdot \left(F \cdot \left(C \cdot \left(2 \cdot A\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B_m}\right)\\ \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) 2e-89)
   (-
    (/
     (sqrt (* A (* -8.0 (* F (* C (* 2.0 A))))))
     (fma A (* C -4.0) (pow B_m 2.0))))
   (* (sqrt (* F (- A (hypot B_m A)))) (- (/ (sqrt 2.0) 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) <= 2e-89) {
		tmp = -(sqrt((A * (-8.0 * (F * (C * (2.0 * A)))))) / fma(A, (C * -4.0), pow(B_m, 2.0)));
	} else {
		tmp = sqrt((F * (A - hypot(B_m, A)))) * -(sqrt(2.0) / 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) <= 2e-89)
		tmp = Float64(-Float64(sqrt(Float64(A * Float64(-8.0 * Float64(F * Float64(C * Float64(2.0 * A)))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0))));
	else
		tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(-Float64(sqrt(2.0) / 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], 2e-89], (-N[(N[Sqrt[N[(A * N[(-8.0 * N[(F * N[(C * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[(N[Sqrt[2.0], $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 2 \cdot 10^{-89}:\\
\;\;\;\;-\frac{\sqrt{A \cdot \left(-8 \cdot \left(F \cdot \left(C \cdot \left(2 \cdot A\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B_m}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 B 2) < 2.00000000000000008e-89

    1. Initial program 23.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. Simplified28.3%

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

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

        \[\leadsto \frac{-\sqrt{\color{blue}{\left(-8 \cdot A\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      2. rem-square-sqrt0.0%

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

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

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

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

        \[\leadsto \frac{-\sqrt{\left(A \cdot \color{blue}{-8}\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      7. associate-*r*23.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{-\color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\left(A \cdot -8\right) \cdot \left(\left(F \cdot C\right) \cdot \left(A + A\right)\right)}\right)} - 1\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      3. associate-*l*13.9%

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

        \[\leadsto \frac{-\left(e^{\mathsf{log1p}\left(\sqrt{A \cdot \left(-8 \cdot \left(\left(F \cdot C\right) \cdot \color{blue}{\left(2 \cdot A\right)}\right)\right)}\right)} - 1\right)}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
    7. Applied egg-rr13.9%

      \[\leadsto \frac{-\color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{A \cdot \left(-8 \cdot \left(\left(F \cdot C\right) \cdot \left(2 \cdot A\right)\right)\right)}\right)} - 1\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
    8. Step-by-step derivation
      1. expm1-def22.6%

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

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

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

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

    if 2.00000000000000008e-89 < (pow.f64 B 2)

    1. Initial program 13.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. Simplified12.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-89}:\\ \;\;\;\;-\frac{\sqrt{A \cdot \left(-8 \cdot \left(F \cdot \left(C \cdot \left(2 \cdot A\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)\\ \end{array} \]

Alternative 4: 39.2% 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 \leq 3 \cdot 10^{-37}:\\ \;\;\;\;\frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(A + A\right) \cdot \left(C \cdot F\right)\right)}}{{B_m}^{2} + A \cdot \left(C \cdot -4\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(C - \mathsf{hypot}\left(B_m, C\right)\right)} \cdot \frac{-\sqrt{2}}{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 3e-37)
   (/
    (- (sqrt (* (* A -8.0) (* (+ A A) (* C F)))))
    (+ (pow B_m 2.0) (* A (* C -4.0))))
   (* (sqrt (* F (- C (hypot B_m C)))) (/ (- (sqrt 2.0)) 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 <= 3e-37) {
		tmp = -sqrt(((A * -8.0) * ((A + A) * (C * F)))) / (pow(B_m, 2.0) + (A * (C * -4.0)));
	} else {
		tmp = sqrt((F * (C - hypot(B_m, C)))) * (-sqrt(2.0) / B_m);
	}
	return tmp;
}
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 <= 3e-37) {
		tmp = -Math.sqrt(((A * -8.0) * ((A + A) * (C * F)))) / (Math.pow(B_m, 2.0) + (A * (C * -4.0)));
	} else {
		tmp = Math.sqrt((F * (C - Math.hypot(B_m, C)))) * (-Math.sqrt(2.0) / 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 <= 3e-37:
		tmp = -math.sqrt(((A * -8.0) * ((A + A) * (C * F)))) / (math.pow(B_m, 2.0) + (A * (C * -4.0)))
	else:
		tmp = math.sqrt((F * (C - math.hypot(B_m, C)))) * (-math.sqrt(2.0) / 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 <= 3e-37)
		tmp = Float64(Float64(-sqrt(Float64(Float64(A * -8.0) * Float64(Float64(A + A) * Float64(C * F))))) / Float64((B_m ^ 2.0) + Float64(A * Float64(C * -4.0))));
	else
		tmp = Float64(sqrt(Float64(F * Float64(C - hypot(B_m, C)))) * Float64(Float64(-sqrt(2.0)) / 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 <= 3e-37)
		tmp = -sqrt(((A * -8.0) * ((A + A) * (C * F)))) / ((B_m ^ 2.0) + (A * (C * -4.0)));
	else
		tmp = sqrt((F * (C - hypot(B_m, C)))) * (-sqrt(2.0) / 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, 3e-37], N[((-N[Sqrt[N[(N[(A * -8.0), $MachinePrecision] * N[(N[(A + A), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(C - N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $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 \leq 3 \cdot 10^{-37}:\\
\;\;\;\;\frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(A + A\right) \cdot \left(C \cdot F\right)\right)}}{{B_m}^{2} + A \cdot \left(C \cdot -4\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(C - \mathsf{hypot}\left(B_m, C\right)\right)} \cdot \frac{-\sqrt{2}}{B_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < 3e-37

    1. Initial program 17.1%

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

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

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

        \[\leadsto \frac{-\sqrt{\color{blue}{\left(-8 \cdot A\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      2. rem-square-sqrt0.0%

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

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

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

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

        \[\leadsto \frac{-\sqrt{\left(A \cdot \color{blue}{-8}\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      7. associate-*r*14.8%

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

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

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

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

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

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

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

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

    if 3e-37 < B

    1. Initial program 19.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. Simplified16.1%

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

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

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

        \[\leadsto -\color{blue}{\sqrt{F \cdot \left(C - \sqrt{{B}^{2} + {C}^{2}}\right)} \cdot \frac{\sqrt{2}}{B}} \]
      3. distribute-rgt-neg-in28.5%

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

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

        \[\leadsto \sqrt{F \cdot \left(C - \sqrt{B \cdot B + \color{blue}{C \cdot C}}\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right) \]
      6. hypot-def48.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq 3 \cdot 10^{-37}:\\ \;\;\;\;\frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(A + A\right) \cdot \left(C \cdot F\right)\right)}}{{B}^{2} + A \cdot \left(C \cdot -4\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(C - \mathsf{hypot}\left(B, C\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\ \end{array} \]

Alternative 5: 42.9% 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 \leq 2.4 \cdot 10^{-37}:\\ \;\;\;\;\frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(A + A\right) \cdot \left(C \cdot F\right)\right)}}{{B_m}^{2} + A \cdot \left(C \cdot -4\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B_m}\right)\\ \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 2.4e-37)
   (/
    (- (sqrt (* (* A -8.0) (* (+ A A) (* C F)))))
    (+ (pow B_m 2.0) (* A (* C -4.0))))
   (* (sqrt (* F (- A (hypot B_m A)))) (- (/ (sqrt 2.0) 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 <= 2.4e-37) {
		tmp = -sqrt(((A * -8.0) * ((A + A) * (C * F)))) / (pow(B_m, 2.0) + (A * (C * -4.0)));
	} else {
		tmp = sqrt((F * (A - hypot(B_m, A)))) * -(sqrt(2.0) / B_m);
	}
	return tmp;
}
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 <= 2.4e-37) {
		tmp = -Math.sqrt(((A * -8.0) * ((A + A) * (C * F)))) / (Math.pow(B_m, 2.0) + (A * (C * -4.0)));
	} else {
		tmp = Math.sqrt((F * (A - Math.hypot(B_m, A)))) * -(Math.sqrt(2.0) / 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 <= 2.4e-37:
		tmp = -math.sqrt(((A * -8.0) * ((A + A) * (C * F)))) / (math.pow(B_m, 2.0) + (A * (C * -4.0)))
	else:
		tmp = math.sqrt((F * (A - math.hypot(B_m, A)))) * -(math.sqrt(2.0) / 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.4e-37)
		tmp = Float64(Float64(-sqrt(Float64(Float64(A * -8.0) * Float64(Float64(A + A) * Float64(C * F))))) / Float64((B_m ^ 2.0) + Float64(A * Float64(C * -4.0))));
	else
		tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(-Float64(sqrt(2.0) / 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 <= 2.4e-37)
		tmp = -sqrt(((A * -8.0) * ((A + A) * (C * F)))) / ((B_m ^ 2.0) + (A * (C * -4.0)));
	else
		tmp = sqrt((F * (A - hypot(B_m, A)))) * -(sqrt(2.0) / 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, 2.4e-37], N[((-N[Sqrt[N[(N[(A * -8.0), $MachinePrecision] * N[(N[(A + A), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[(N[Sqrt[2.0], $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 \leq 2.4 \cdot 10^{-37}:\\
\;\;\;\;\frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(A + A\right) \cdot \left(C \cdot F\right)\right)}}{{B_m}^{2} + A \cdot \left(C \cdot -4\right)}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B_m, A\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B_m}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if B < 2.39999999999999991e-37

    1. Initial program 17.1%

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

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

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

        \[\leadsto \frac{-\sqrt{\color{blue}{\left(-8 \cdot A\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      2. rem-square-sqrt0.0%

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

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

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

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

        \[\leadsto \frac{-\sqrt{\left(A \cdot \color{blue}{-8}\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
      7. associate-*r*14.8%

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

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

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

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

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

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

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

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

    if 2.39999999999999991e-37 < B

    1. Initial program 19.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. Simplified16.1%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq 2.4 \cdot 10^{-37}:\\ \;\;\;\;\frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(A + A\right) \cdot \left(C \cdot F\right)\right)}}{{B}^{2} + A \cdot \left(C \cdot -4\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)\\ \end{array} \]

Alternative 6: 21.5% accurate, 5.4× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(A + A\right) \cdot \left(C \cdot F\right)\right)}}{C \cdot \left(A \cdot -4\right)} \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 (* (* A -8.0) (* (+ A A) (* C F))))) (* C (* A -4.0))))
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(((A * -8.0) * ((A + A) * (C * F)))) / (C * (A * -4.0));
}
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(((a * (-8.0d0)) * ((a + a) * (c * f)))) / (c * (a * (-4.0d0)))
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(((A * -8.0) * ((A + A) * (C * F)))) / (C * (A * -4.0));
}
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(((A * -8.0) * ((A + A) * (C * F)))) / (C * (A * -4.0))
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	return Float64(Float64(-sqrt(Float64(Float64(A * -8.0) * Float64(Float64(A + A) * Float64(C * F))))) / Float64(C * Float64(A * -4.0)))
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(((A * -8.0) * ((A + A) * (C * F)))) / (C * (A * -4.0));
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[((-N[Sqrt[N[(N[(A * -8.0), $MachinePrecision] * N[(N[(A + A), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(A + A\right) \cdot \left(C \cdot F\right)\right)}}{C \cdot \left(A \cdot -4\right)}
\end{array}
Derivation
  1. Initial program 17.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. Simplified19.2%

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

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

      \[\leadsto \frac{-\sqrt{\color{blue}{\left(-8 \cdot A\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
    2. rem-square-sqrt0.0%

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

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

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

      \[\leadsto \frac{-\sqrt{\left(A \cdot \color{blue}{\left(\sqrt{-8} \cdot \sqrt{-8}\right)}\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
    6. rem-square-sqrt12.0%

      \[\leadsto \frac{-\sqrt{\left(A \cdot \color{blue}{-8}\right) \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
    7. associate-*r*11.8%

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

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

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

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

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

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

    \[\leadsto \frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(F \cdot C\right) \cdot \left(A + A\right)\right)}}{\color{blue}{-4 \cdot \left(A \cdot C\right)}} \]
  7. Step-by-step derivation
    1. associate-*r*11.6%

      \[\leadsto \frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(F \cdot C\right) \cdot \left(A + A\right)\right)}}{\color{blue}{\left(-4 \cdot A\right) \cdot C}} \]
  8. Simplified11.6%

    \[\leadsto \frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(F \cdot C\right) \cdot \left(A + A\right)\right)}}{\color{blue}{\left(-4 \cdot A\right) \cdot C}} \]
  9. Final simplification11.6%

    \[\leadsto \frac{-\sqrt{\left(A \cdot -8\right) \cdot \left(\left(A + A\right) \cdot \left(C \cdot F\right)\right)}}{C \cdot \left(A \cdot -4\right)} \]

Alternative 7: 1.0% accurate, 5.8× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ -2 \cdot \left(\frac{1}{B_m} \cdot \sqrt{C \cdot F}\right) \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
 (* -2.0 (* (/ 1.0 B_m) (sqrt (* C F)))))
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 -2.0 * ((1.0 / B_m) * sqrt((C * F)));
}
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 = (-2.0d0) * ((1.0d0 / b_m) * sqrt((c * f)))
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 -2.0 * ((1.0 / B_m) * Math.sqrt((C * F)));
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	return -2.0 * ((1.0 / B_m) * math.sqrt((C * F)))
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	return Float64(-2.0 * Float64(Float64(1.0 / B_m) * sqrt(Float64(C * F))))
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 = -2.0 * ((1.0 / B_m) * sqrt((C * F)));
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[(-2.0 * N[(N[(1.0 / B$95$m), $MachinePrecision] * N[Sqrt[N[(C * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
-2 \cdot \left(\frac{1}{B_m} \cdot \sqrt{C \cdot F}\right)
\end{array}
Derivation
  1. Initial program 17.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. Simplified19.2%

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

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

    \[\leadsto \color{blue}{-2 \cdot \left(\frac{1}{B} \cdot \sqrt{C \cdot F}\right)} \]
  5. Final simplification3.0%

    \[\leadsto -2 \cdot \left(\frac{1}{B} \cdot \sqrt{C \cdot F}\right) \]

Reproduce

?
herbie shell --seed 2023337 
(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))))