ABCF->ab-angle b

Percentage Accurate: 19.1% → 47.6%
Time: 29.5s
Alternatives: 10
Speedup: 3.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: 19.1% 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(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\ \mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-133}:\\ \;\;\;\;\frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)\right)}^{0.5}}{t\_0}\\ \mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+27}:\\ \;\;\;\;\frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)\right)\right)\right)\right)}^{0.5}}{t\_0}\\ \mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+40}:\\ \;\;\;\;\frac{-\sqrt{\left(t\_0 \cdot F\right) \cdot \left(2 \cdot \left(A + \left(A + \frac{-0.5 \cdot \left({A}^{2} + \left({B\_m}^{2} - {\left(-A\right)}^{2}\right)\right)}{C}\right)\right)\right)}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B\_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\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 B_m B_m (* A (* C -4.0)))))
   (if (<= (pow B_m 2.0) 2e-133)
     (/ (- (pow (* t_0 (* F (* 2.0 (* 2.0 A)))) 0.5)) t_0)
     (if (<= (pow B_m 2.0) 2e+27)
       (/
        (- (pow (* t_0 (* F (* 2.0 (- (+ A C) (hypot B_m (- A C)))))) 0.5))
        t_0)
       (if (<= (pow B_m 2.0) 2e+40)
         (/
          (-
           (sqrt
            (*
             (* t_0 F)
             (*
              2.0
              (+
               A
               (+
                A
                (/
                 (* -0.5 (+ (pow A 2.0) (- (pow B_m 2.0) (pow (- A) 2.0))))
                 C)))))))
          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(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (pow(B_m, 2.0) <= 2e-133) {
		tmp = -pow((t_0 * (F * (2.0 * (2.0 * A)))), 0.5) / t_0;
	} else if (pow(B_m, 2.0) <= 2e+27) {
		tmp = -pow((t_0 * (F * (2.0 * ((A + C) - hypot(B_m, (A - C)))))), 0.5) / t_0;
	} else if (pow(B_m, 2.0) <= 2e+40) {
		tmp = -sqrt(((t_0 * F) * (2.0 * (A + (A + ((-0.5 * (pow(A, 2.0) + (pow(B_m, 2.0) - pow(-A, 2.0)))) / C)))))) / 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(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if ((B_m ^ 2.0) <= 2e-133)
		tmp = Float64(Float64(-(Float64(t_0 * Float64(F * Float64(2.0 * Float64(2.0 * A)))) ^ 0.5)) / t_0);
	elseif ((B_m ^ 2.0) <= 2e+27)
		tmp = Float64(Float64(-(Float64(t_0 * Float64(F * Float64(2.0 * Float64(Float64(A + C) - hypot(B_m, Float64(A - C)))))) ^ 0.5)) / t_0);
	elseif ((B_m ^ 2.0) <= 2e+40)
		tmp = Float64(Float64(-sqrt(Float64(Float64(t_0 * F) * Float64(2.0 * Float64(A + Float64(A + Float64(Float64(-0.5 * Float64((A ^ 2.0) + Float64((B_m ^ 2.0) - (Float64(-A) ^ 2.0)))) / C))))))) / t_0);
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * 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[(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], 2e-133], N[((-N[Power[N[(t$95$0 * N[(F * N[(2.0 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+27], N[((-N[Power[N[(t$95$0 * N[(F * N[(2.0 * N[(N[(A + C), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+40], N[((-N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * N[(A + N[(A + N[(N[(-0.5 * N[(N[Power[A, 2.0], $MachinePrecision] + N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[Power[(-A), 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-133}:\\
\;\;\;\;\frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)\right)}^{0.5}}{t\_0}\\

\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+27}:\\
\;\;\;\;\frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)\right)\right)\right)\right)}^{0.5}}{t\_0}\\

\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+40}:\\
\;\;\;\;\frac{-\sqrt{\left(t\_0 \cdot F\right) \cdot \left(2 \cdot \left(A + \left(A + \frac{-0.5 \cdot \left({A}^{2} + \left({B\_m}^{2} - {\left(-A\right)}^{2}\right)\right)}{C}\right)\right)\right)}}{t\_0}\\

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


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

    1. Initial program 22.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. Simplified33.0%

      \[\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. Step-by-step derivation
      1. pow1/233.0%

        \[\leadsto \frac{-\color{blue}{{\left(\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)\right)}^{0.5}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      2. associate-*l*33.0%

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

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

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

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

    if 2.0000000000000001e-133 < (pow.f64 B 2) < 2e27

    1. Initial program 52.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. Simplified60.6%

      \[\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. Step-by-step derivation
      1. pow1/260.6%

        \[\leadsto \frac{-\color{blue}{{\left(\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)\right)}^{0.5}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      2. associate-*l*64.0%

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

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

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

    if 2e27 < (pow.f64 B 2) < 2.00000000000000006e40

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

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

      \[\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(A + -0.5 \cdot \frac{\left({A}^{2} + {B}^{2}\right) - {\left(-1 \cdot A\right)}^{2}}{C}\right)}\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    5. Step-by-step derivation
      1. associate-*r/100.0%

        \[\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(A + \color{blue}{\frac{-0.5 \cdot \left(\left({A}^{2} + {B}^{2}\right) - {\left(-1 \cdot A\right)}^{2}\right)}{C}}\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      2. associate--l+100.0%

        \[\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(A + \frac{-0.5 \cdot \color{blue}{\left({A}^{2} + \left({B}^{2} - {\left(-1 \cdot A\right)}^{2}\right)\right)}}{C}\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      3. mul-1-neg100.0%

        \[\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(A + \frac{-0.5 \cdot \left({A}^{2} + \left({B}^{2} - {\color{blue}{\left(-A\right)}}^{2}\right)\right)}{C}\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    6. Simplified100.0%

      \[\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(A + \frac{-0.5 \cdot \left({A}^{2} + \left({B}^{2} - {\left(-A\right)}^{2}\right)\right)}{C}\right)}\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]

    if 2.00000000000000006e40 < (pow.f64 B 2)

    1. Initial program 17.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. Simplified14.0%

      \[\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. Add Preprocessing
    4. Taylor expanded in C around 0 14.7%

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

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

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

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

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

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

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

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

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

Alternative 2: 47.5% 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 2 \cdot 10^{-133}:\\ \;\;\;\;\frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)\right)}^{0.5}}{t\_0}\\ \mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+27}:\\ \;\;\;\;\frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)\right)\right)\right)\right)}^{0.5}}{t\_0}\\ \mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+40}:\\ \;\;\;\;\frac{-\sqrt{\left(t\_0 \cdot F\right) \cdot \left(2 \cdot \left(A + A\right)\right)}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B\_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\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 B_m B_m (* A (* C -4.0)))))
   (if (<= (pow B_m 2.0) 2e-133)
     (/ (- (pow (* t_0 (* F (* 2.0 (* 2.0 A)))) 0.5)) t_0)
     (if (<= (pow B_m 2.0) 2e+27)
       (/
        (- (pow (* t_0 (* F (* 2.0 (- (+ A C) (hypot B_m (- A C)))))) 0.5))
        t_0)
       (if (<= (pow B_m 2.0) 2e+40)
         (/ (- (sqrt (* (* t_0 F) (* 2.0 (+ A A))))) 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(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (pow(B_m, 2.0) <= 2e-133) {
		tmp = -pow((t_0 * (F * (2.0 * (2.0 * A)))), 0.5) / t_0;
	} else if (pow(B_m, 2.0) <= 2e+27) {
		tmp = -pow((t_0 * (F * (2.0 * ((A + C) - hypot(B_m, (A - C)))))), 0.5) / t_0;
	} else if (pow(B_m, 2.0) <= 2e+40) {
		tmp = -sqrt(((t_0 * F) * (2.0 * (A + A)))) / 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(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if ((B_m ^ 2.0) <= 2e-133)
		tmp = Float64(Float64(-(Float64(t_0 * Float64(F * Float64(2.0 * Float64(2.0 * A)))) ^ 0.5)) / t_0);
	elseif ((B_m ^ 2.0) <= 2e+27)
		tmp = Float64(Float64(-(Float64(t_0 * Float64(F * Float64(2.0 * Float64(Float64(A + C) - hypot(B_m, Float64(A - C)))))) ^ 0.5)) / t_0);
	elseif ((B_m ^ 2.0) <= 2e+40)
		tmp = Float64(Float64(-sqrt(Float64(Float64(t_0 * F) * Float64(2.0 * Float64(A + A))))) / t_0);
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * 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[(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], 2e-133], N[((-N[Power[N[(t$95$0 * N[(F * N[(2.0 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+27], N[((-N[Power[N[(t$95$0 * N[(F * N[(2.0 * N[(N[(A + C), $MachinePrecision] - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e+40], N[((-N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * N[(A + A), $MachinePrecision]), $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(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-133}:\\
\;\;\;\;\frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)\right)}^{0.5}}{t\_0}\\

\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+27}:\\
\;\;\;\;\frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B\_m, A - C\right)\right)\right)\right)\right)}^{0.5}}{t\_0}\\

\mathbf{elif}\;{B\_m}^{2} \leq 2 \cdot 10^{+40}:\\
\;\;\;\;\frac{-\sqrt{\left(t\_0 \cdot F\right) \cdot \left(2 \cdot \left(A + A\right)\right)}}{t\_0}\\

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


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

    1. Initial program 22.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. Simplified33.0%

      \[\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. Step-by-step derivation
      1. pow1/233.0%

        \[\leadsto \frac{-\color{blue}{{\left(\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)\right)}^{0.5}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      2. associate-*l*33.0%

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

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

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

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

    if 2.0000000000000001e-133 < (pow.f64 B 2) < 2e27

    1. Initial program 52.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. Simplified60.6%

      \[\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. Step-by-step derivation
      1. pow1/260.6%

        \[\leadsto \frac{-\color{blue}{{\left(\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)\right)}^{0.5}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      2. associate-*l*64.0%

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

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

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

    if 2e27 < (pow.f64 B 2) < 2.00000000000000006e40

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

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

      \[\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}{A}\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]

    if 2.00000000000000006e40 < (pow.f64 B 2)

    1. Initial program 17.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. Simplified14.0%

      \[\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. Add Preprocessing
    4. Taylor expanded in C around 0 14.7%

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

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

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

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

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

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

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

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

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

Alternative 3: 47.2% accurate, 1.4× 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)\\ t_1 := \frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)\right)}^{0.5}}{t\_0}\\ \mathbf{if}\;B\_m \leq 5.5 \cdot 10^{-67}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;B\_m \leq 1.05 \cdot 10^{-19}:\\ \;\;\;\;\frac{-\sqrt{\left(t\_0 \cdot F\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B\_m, A - C\right)\right)\right)\right)}}{t\_0}\\ \mathbf{elif}\;B\_m \leq 2.95 \cdot 10^{-5}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B\_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\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 B_m B_m (* A (* C -4.0))))
        (t_1 (/ (- (pow (* t_0 (* F (* 2.0 (* 2.0 A)))) 0.5)) t_0)))
   (if (<= B_m 5.5e-67)
     t_1
     (if (<= B_m 1.05e-19)
       (/ (- (sqrt (* (* t_0 F) (* 2.0 (+ A (- C (hypot B_m (- A C)))))))) t_0)
       (if (<= B_m 2.95e-5)
         t_1
         (* (/ (- (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(B_m, B_m, (A * (C * -4.0)));
	double t_1 = -pow((t_0 * (F * (2.0 * (2.0 * A)))), 0.5) / t_0;
	double tmp;
	if (B_m <= 5.5e-67) {
		tmp = t_1;
	} else if (B_m <= 1.05e-19) {
		tmp = -sqrt(((t_0 * F) * (2.0 * (A + (C - hypot(B_m, (A - C))))))) / t_0;
	} else if (B_m <= 2.95e-5) {
		tmp = t_1;
	} 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(B_m, B_m, Float64(A * Float64(C * -4.0)))
	t_1 = Float64(Float64(-(Float64(t_0 * Float64(F * Float64(2.0 * Float64(2.0 * A)))) ^ 0.5)) / t_0)
	tmp = 0.0
	if (B_m <= 5.5e-67)
		tmp = t_1;
	elseif (B_m <= 1.05e-19)
		tmp = Float64(Float64(-sqrt(Float64(Float64(t_0 * F) * Float64(2.0 * Float64(A + Float64(C - hypot(B_m, Float64(A - C)))))))) / t_0);
	elseif (B_m <= 2.95e-5)
		tmp = t_1;
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * 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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Power[N[(t$95$0 * N[(F * N[(2.0 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / t$95$0), $MachinePrecision]}, If[LessEqual[B$95$m, 5.5e-67], t$95$1, If[LessEqual[B$95$m, 1.05e-19], N[((-N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[B$95$m, 2.95e-5], t$95$1, 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(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := \frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)\right)}^{0.5}}{t\_0}\\
\mathbf{if}\;B\_m \leq 5.5 \cdot 10^{-67}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;B\_m \leq 2.95 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if B < 5.5000000000000003e-67 or 1.0499999999999999e-19 < B < 2.9499999999999999e-5

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

      \[\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. Step-by-step derivation
      1. pow1/229.1%

        \[\leadsto \frac{-\color{blue}{{\left(\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)\right)}^{0.5}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      2. associate-*l*29.6%

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

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

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

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

    if 5.5000000000000003e-67 < B < 1.0499999999999999e-19

    1. Initial program 56.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. Simplified67.6%

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

    if 2.9499999999999999e-5 < B

    1. Initial program 22.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. Simplified16.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. Add Preprocessing
    4. Taylor expanded in C around 0 27.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq 5.5 \cdot 10^{-67}:\\ \;\;\;\;\frac{-{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)\right)}^{0.5}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{elif}\;B \leq 1.05 \cdot 10^{-19}:\\ \;\;\;\;\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)}\\ \mathbf{elif}\;B \leq 2.95 \cdot 10^{-5}:\\ \;\;\;\;\frac{-{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)\right)}^{0.5}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 45.0% 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^{-132}:\\ \;\;\;\;\frac{-{\left(-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)\right)}^{0.5}}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B\_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\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
 (if (<= (pow B_m 2.0) 2e-132)
   (/
    (- (pow (* -8.0 (* A (* C (* F (+ A A))))) 0.5))
    (fma B_m B_m (* A (* C -4.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 tmp;
	if (pow(B_m, 2.0) <= 2e-132) {
		tmp = -pow((-8.0 * (A * (C * (F * (A + A))))), 0.5) / fma(B_m, B_m, (A * (C * -4.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)
	tmp = 0.0
	if ((B_m ^ 2.0) <= 2e-132)
		tmp = Float64(Float64(-(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A + A))))) ^ 0.5)) / fma(B_m, B_m, Float64(A * Float64(C * -4.0))));
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * 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_] := If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-132], N[((-N[Power[N[(-8.0 * N[(A * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;{B\_m}^{2} \leq 2 \cdot 10^{-132}:\\
\;\;\;\;\frac{-{\left(-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)\right)}^{0.5}}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\

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


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

    1. Initial program 24.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. Simplified34.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. Step-by-step derivation
      1. pow1/234.2%

        \[\leadsto \frac{-\color{blue}{{\left(\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)\right)}^{0.5}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      2. associate-*l*34.2%

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

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

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

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

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

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

    if 2e-132 < (pow.f64 B 2)

    1. Initial program 22.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. Simplified22.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. Add Preprocessing
    4. Taylor expanded in C around 0 16.3%

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

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

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

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

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

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

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

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

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

Alternative 5: 47.1% accurate, 1.9× 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 \leq 2.7 \cdot 10^{-5}:\\ \;\;\;\;\frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)\right)}^{0.5}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B\_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\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 B_m B_m (* A (* C -4.0)))))
   (if (<= B_m 2.7e-5)
     (/ (- (pow (* t_0 (* F (* 2.0 (* 2.0 A)))) 0.5)) 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(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (B_m <= 2.7e-5) {
		tmp = -pow((t_0 * (F * (2.0 * (2.0 * A)))), 0.5) / 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(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if (B_m <= 2.7e-5)
		tmp = Float64(Float64(-(Float64(t_0 * Float64(F * Float64(2.0 * Float64(2.0 * A)))) ^ 0.5)) / t_0);
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * 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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 2.7e-5], N[((-N[Power[N[(t$95$0 * N[(F * N[(2.0 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $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(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B\_m \leq 2.7 \cdot 10^{-5}:\\
\;\;\;\;\frac{-{\left(t\_0 \cdot \left(F \cdot \left(2 \cdot \left(2 \cdot A\right)\right)\right)\right)}^{0.5}}{t\_0}\\

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


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

    1. Initial program 23.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. Simplified30.9%

      \[\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. Step-by-step derivation
      1. pow1/230.9%

        \[\leadsto \frac{-\color{blue}{{\left(\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)\right)}^{0.5}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      2. associate-*l*31.4%

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

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

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

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

    if 2.6999999999999999e-5 < B

    1. Initial program 22.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. Simplified16.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. Add Preprocessing
    4. Taylor expanded in C around 0 27.3%

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

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

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

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

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

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

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

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

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

Alternative 6: 46.1% accurate, 1.9× 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 \leq 7.5 \cdot 10^{-64}:\\ \;\;\;\;\frac{-\sqrt{\left(t\_0 \cdot F\right) \cdot \left(2 \cdot \left(A + A\right)\right)}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B\_m} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\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 B_m B_m (* A (* C -4.0)))))
   (if (<= B_m 7.5e-64)
     (/ (- (sqrt (* (* t_0 F) (* 2.0 (+ A A))))) 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(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (B_m <= 7.5e-64) {
		tmp = -sqrt(((t_0 * F) * (2.0 * (A + A)))) / 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(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if (B_m <= 7.5e-64)
		tmp = Float64(Float64(-sqrt(Float64(Float64(t_0 * F) * Float64(2.0 * Float64(A + A))))) / t_0);
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * 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[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 7.5e-64], N[((-N[Sqrt[N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * N[(A + A), $MachinePrecision]), $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(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B\_m \leq 7.5 \cdot 10^{-64}:\\
\;\;\;\;\frac{-\sqrt{\left(t\_0 \cdot F\right) \cdot \left(2 \cdot \left(A + A\right)\right)}}{t\_0}\\

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


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

    1. Initial program 22.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. Simplified29.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 C around inf 21.6%

      \[\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}{A}\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]

    if 7.49999999999999949e-64 < B

    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. Simplified22.9%

      \[\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. Add Preprocessing
    4. Taylor expanded in C around 0 30.4%

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

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

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

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

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

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

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

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

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

Alternative 7: 41.0% accurate, 2.8× 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.6 \cdot 10^{-5}:\\ \;\;\;\;\frac{-{\left(-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)\right)}^{0.5}}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B\_m} \cdot \sqrt{B\_m \cdot \left(-F\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.6e-5)
   (/
    (- (pow (* -8.0 (* A (* C (* F (+ A A))))) 0.5))
    (fma B_m B_m (* A (* C -4.0))))
   (* (/ (- (sqrt 2.0)) B_m) (sqrt (* B_m (- 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) {
	double tmp;
	if (B_m <= 2.6e-5) {
		tmp = -pow((-8.0 * (A * (C * (F * (A + A))))), 0.5) / fma(B_m, B_m, (A * (C * -4.0)));
	} else {
		tmp = (-sqrt(2.0) / B_m) * sqrt((B_m * -F));
	}
	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.6e-5)
		tmp = Float64(Float64(-(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A + A))))) ^ 0.5)) / fma(B_m, B_m, Float64(A * Float64(C * -4.0))));
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(B_m * Float64(-F))));
	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[B$95$m, 2.6e-5], N[((-N[Power[N[(-8.0 * N[(A * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]) / N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(B$95$m * (-F)), $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 2.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{-{\left(-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)\right)}^{0.5}}{\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{2}}{B\_m} \cdot \sqrt{B\_m \cdot \left(-F\right)}\\


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

    1. Initial program 23.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. Simplified30.9%

      \[\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. Step-by-step derivation
      1. pow1/230.9%

        \[\leadsto \frac{-\color{blue}{{\left(\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)\right)}^{0.5}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      2. associate-*l*31.4%

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

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

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

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

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

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

    if 2.59999999999999984e-5 < B

    1. Initial program 22.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. Simplified16.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. Add Preprocessing
    4. Taylor expanded in A around 0 28.1%

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

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

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

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

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

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

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

      \[\leadsto \left(-\frac{\sqrt{2}}{B}\right) \cdot \sqrt{\color{blue}{-1 \cdot \left(B \cdot F\right)}} \]
    8. Step-by-step derivation
      1. associate-*r*35.6%

        \[\leadsto \left(-\frac{\sqrt{2}}{B}\right) \cdot \sqrt{\color{blue}{\left(-1 \cdot B\right) \cdot F}} \]
      2. mul-1-neg35.6%

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

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

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

Alternative 8: 26.5% accurate, 3.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \frac{-\sqrt{2}}{B\_m} \cdot \sqrt{B\_m \cdot \left(-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
 (* (/ (- (sqrt 2.0)) B_m) (sqrt (* B_m (- 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 (-sqrt(2.0) / B_m) * sqrt((B_m * -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 = (-sqrt(2.0d0) / b_m) * sqrt((b_m * -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 (-Math.sqrt(2.0) / B_m) * Math.sqrt((B_m * -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 (-math.sqrt(2.0) / B_m) * math.sqrt((B_m * -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(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(B_m * Float64(-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 = (-sqrt(2.0) / B_m) * sqrt((B_m * -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[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(B$95$m * (-F)), $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{2}}{B\_m} \cdot \sqrt{B\_m \cdot \left(-F\right)}
\end{array}
Derivation
  1. Initial program 23.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. Simplified24.0%

    \[\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. Add Preprocessing
  4. Taylor expanded in A around 0 10.9%

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

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

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

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

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

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

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

    \[\leadsto \left(-\frac{\sqrt{2}}{B}\right) \cdot \sqrt{\color{blue}{-1 \cdot \left(B \cdot F\right)}} \]
  8. Step-by-step derivation
    1. associate-*r*12.4%

      \[\leadsto \left(-\frac{\sqrt{2}}{B}\right) \cdot \sqrt{\color{blue}{\left(-1 \cdot B\right) \cdot F}} \]
    2. mul-1-neg12.4%

      \[\leadsto \left(-\frac{\sqrt{2}}{B}\right) \cdot \sqrt{\color{blue}{\left(-B\right)} \cdot F} \]
  9. Simplified12.4%

    \[\leadsto \left(-\frac{\sqrt{2}}{B}\right) \cdot \sqrt{\color{blue}{\left(-B\right) \cdot F}} \]
  10. Final simplification12.4%

    \[\leadsto \frac{-\sqrt{2}}{B} \cdot \sqrt{B \cdot \left(-F\right)} \]
  11. Add Preprocessing

Alternative 9: 0.6% accurate, 3.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{B\_m \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
 (* (/ (sqrt 2.0) B_m) (- (sqrt (* B_m 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 (sqrt(2.0) / B_m) * -sqrt((B_m * 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 = (sqrt(2.0d0) / b_m) * -sqrt((b_m * 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 (Math.sqrt(2.0) / B_m) * -Math.sqrt((B_m * 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 (math.sqrt(2.0) / B_m) * -math.sqrt((B_m * 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(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(B_m * 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 = (sqrt(2.0) / B_m) * -sqrt((B_m * 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[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(B$95$m * F), $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{2}}{B\_m} \cdot \left(-\sqrt{B\_m \cdot F}\right)
\end{array}
Derivation
  1. Initial program 23.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. Simplified24.0%

    \[\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. Add Preprocessing
  4. Taylor expanded in A around 0 10.9%

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

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

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

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

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

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

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

    \[\leadsto \left(-\frac{\sqrt{2}}{B}\right) \cdot \sqrt{\color{blue}{B \cdot F}} \]
  8. Final simplification1.5%

    \[\leadsto \frac{\sqrt{2}}{B} \cdot \left(-\sqrt{B \cdot F}\right) \]
  9. Add Preprocessing

Alternative 10: 0.0% accurate, 3.1× 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}} \cdot \left(-\sqrt{-1}\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 (/ F C)) (- (sqrt -1.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((F / C)) * -sqrt(-1.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((f / c)) * -sqrt((-1.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((F / C)) * -Math.sqrt(-1.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((F / C)) * -math.sqrt(-1.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(sqrt(Float64(F / C)) * Float64(-sqrt(-1.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((F / C)) * -sqrt(-1.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[(F / C), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[-1.0], $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}} \cdot \left(-\sqrt{-1}\right)
\end{array}
Derivation
  1. Initial program 23.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. Simplified29.9%

    \[\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. Step-by-step derivation
    1. pow1/229.9%

      \[\leadsto \frac{-\color{blue}{{\left(\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)\right)}^{0.5}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    2. associate-*l*30.3%

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{\frac{F}{C}} \cdot \sqrt{-1}\right)} \]
  7. Step-by-step derivation
    1. mul-1-neg0.0%

      \[\leadsto \color{blue}{-\sqrt{\frac{F}{C}} \cdot \sqrt{-1}} \]
  8. Simplified0.0%

    \[\leadsto \color{blue}{-\sqrt{\frac{F}{C}} \cdot \sqrt{-1}} \]
  9. Final simplification0.0%

    \[\leadsto \sqrt{\frac{F}{C}} \cdot \left(-\sqrt{-1}\right) \]
  10. Add Preprocessing

Reproduce

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