ABCF->ab-angle b

Percentage Accurate: 19.0% → 48.7%
Time: 25.7s
Alternatives: 14
Speedup: 3.1×

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 14 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.0% accurate, 1.0× speedup?

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999999e-49 < (pow.f64 B #s(literal 2 binary64)) < 1e308

    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. Simplified17.2%

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 46.9% 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} 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^{-8}:\\ \;\;\;\;\frac{\sqrt{t\_0 \cdot \left(F \cdot \left(A \cdot 4\right)\right)}}{-t\_0}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\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
 (let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
   (if (<= (pow B_m 2.0) 2e-8)
     (/ (sqrt (* t_0 (* F (* A 4.0)))) (- t_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 t_0 = fma(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (pow(B_m, 2.0) <= 2e-8) {
		tmp = sqrt((t_0 * (F * (A * 4.0)))) / -t_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)
	t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if ((B_m ^ 2.0) <= 2e-8)
		tmp = Float64(sqrt(Float64(t_0 * Float64(F * Float64(A * 4.0)))) / Float64(-t_0));
	else
		tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m)));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 2e-8], N[(N[Sqrt[N[(t$95$0 * N[(F * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $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}
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^{-8}:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot \left(F \cdot \left(A \cdot 4\right)\right)}}{-t\_0}\\

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


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

    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. Simplified31.3%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot F\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}} \]
    3. Add Preprocessing
    4. Taylor expanded in C around inf 17.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}{\left(-0.5 \cdot \frac{{B}^{2}}{C} - -1 \cdot A\right)}\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg17.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 + \left(-0.5 \cdot \frac{{B}^{2}}{C} - \color{blue}{\left(-A\right)}\right)\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    6. Simplified17.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}{\left(-0.5 \cdot \frac{{B}^{2}}{C} - \left(-A\right)\right)}\right)\right)}}{-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    7. Taylor expanded in A around -inf 17.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 14.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. Add Preprocessing
    3. Taylor expanded in C around 0 11.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-neg11.5%

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

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

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

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

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

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

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

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

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


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

    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. Simplified27.5%

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

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

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

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

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

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

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

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

    1. Initial program 14.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. Add Preprocessing
    3. Taylor expanded in C around 0 11.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-neg11.5%

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

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

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

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

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

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

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

Alternative 4: 46.7% 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 0.0058:\\ \;\;\;\;\frac{\sqrt{\left(A \cdot 4\right) \cdot \left(t\_0 \cdot F\right)}}{-t\_0}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\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
 (let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
   (if (<= B_m 0.0058)
     (/ (sqrt (* (* A 4.0) (* t_0 F))) (- t_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 t_0 = fma(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (B_m <= 0.0058) {
		tmp = sqrt(((A * 4.0) * (t_0 * F))) / -t_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)
	t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if (B_m <= 0.0058)
		tmp = Float64(sqrt(Float64(Float64(A * 4.0) * Float64(t_0 * F))) / Float64(-t_0));
	else
		tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-B_m)));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 0.0058], N[(N[Sqrt[N[(N[(A * 4.0), $MachinePrecision] * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $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}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;B\_m \leq 0.0058:\\
\;\;\;\;\frac{\sqrt{\left(A \cdot 4\right) \cdot \left(t\_0 \cdot F\right)}}{-t\_0}\\

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


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

    1. Initial program 18.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. Simplified25.7%

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

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

    if 0.0058 < B

    1. Initial program 17.4%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in C around 0 20.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-neg20.1%

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

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

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

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

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

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

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

Alternative 5: 44.5% accurate, 2.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;B\_m \leq 0.000125:\\ \;\;\;\;\frac{\sqrt{\left(A \cdot -8\right) \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B\_m}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\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 0.000125)
   (/
    (sqrt (* (* A -8.0) (* C (* F (+ A A)))))
    (- (fma C (* A -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 (B_m <= 0.000125) {
		tmp = sqrt(((A * -8.0) * (C * (F * (A + A))))) / -fma(C, (A * -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 <= 0.000125)
		tmp = Float64(sqrt(Float64(Float64(A * -8.0) * Float64(C * Float64(F * Float64(A + A))))) / Float64(-fma(C, Float64(A * -4.0), (B_m ^ 2.0))));
	else
		tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B_m, A)))) * Float64(sqrt(2.0) / Float64(-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[B$95$m, 0.000125], N[(N[Sqrt[N[(N[(A * -8.0), $MachinePrecision] * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(C * N[(A * -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 \leq 0.000125:\\
\;\;\;\;\frac{\sqrt{\left(A \cdot -8\right) \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B\_m}^{2}\right)}\\

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


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

    1. Initial program 18.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. Simplified20.9%

      \[\leadsto \color{blue}{\frac{\sqrt{F \cdot \left(\left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right) \cdot \left(2 \cdot \mathsf{fma}\left(C, A \cdot -4, {B}^{2}\right)\right)\right)}}{-\mathsf{fma}\left(C, A \cdot -4, {B}^{2}\right)}} \]
    3. Add Preprocessing
    4. Taylor expanded in C around inf 13.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(C, A \cdot -4, {B}^{2}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*13.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(C, A \cdot -4, {B}^{2}\right)} \]
      2. mul-1-neg13.2%

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

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

    if 1.25e-4 < B

    1. Initial program 17.4%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Add Preprocessing
    3. Taylor expanded in C around 0 20.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-neg20.1%

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

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

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

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

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

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

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

Alternative 6: 35.7% accurate, 2.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} \mathbf{if}\;B\_m \leq 0.0042:\\ \;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{\left(\frac{A}{B\_m} + \frac{C}{B\_m}\right) + -1}{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 0.0042)
   (/ (sqrt (* (* -16.0 (pow A 2.0)) (* C F))) (* C (* A 4.0)))
   (* (sqrt 2.0) (- (sqrt (* F (/ (+ (+ (/ A B_m) (/ C B_m)) -1.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 <= 0.0042) {
		tmp = sqrt(((-16.0 * pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
	} else {
		tmp = sqrt(2.0) * -sqrt((F * ((((A / B_m) + (C / B_m)) + -1.0) / B_m)));
	}
	return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    real(8) :: tmp
    if (b_m <= 0.0042d0) then
        tmp = sqrt((((-16.0d0) * (a ** 2.0d0)) * (c * f))) / (c * (a * 4.0d0))
    else
        tmp = sqrt(2.0d0) * -sqrt((f * ((((a / b_m) + (c / b_m)) + (-1.0d0)) / b_m)))
    end if
    code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 0.0042) {
		tmp = Math.sqrt(((-16.0 * Math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
	} else {
		tmp = Math.sqrt(2.0) * -Math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.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 <= 0.0042:
		tmp = math.sqrt(((-16.0 * math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0))
	else:
		tmp = math.sqrt(2.0) * -math.sqrt((F * ((((A / B_m) + (C / B_m)) + -1.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 <= 0.0042)
		tmp = Float64(sqrt(Float64(Float64(-16.0 * (A ^ 2.0)) * Float64(C * F))) / Float64(C * Float64(A * 4.0)));
	else
		tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(F * Float64(Float64(Float64(Float64(A / B_m) + Float64(C / B_m)) + -1.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 <= 0.0042)
		tmp = sqrt(((-16.0 * (A ^ 2.0)) * (C * F))) / (C * (A * 4.0));
	else
		tmp = sqrt(2.0) * -sqrt((F * ((((A / B_m) + (C / B_m)) + -1.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, 0.0042], N[(N[Sqrt[N[(N[(-16.0 * N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(F * N[(N[(N[(N[(A / B$95$m), $MachinePrecision] + N[(C / B$95$m), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / B$95$m), $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 \leq 0.0042:\\
\;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\

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


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

    1. Initial program 18.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. Simplified20.9%

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{\color{blue}{\left(4 \cdot A\right) \cdot C}} \]
    9. Simplified8.6%

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

    if 0.00419999999999999974 < B

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq 0.0042:\\ \;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{F \cdot \frac{\left(\frac{A}{B} + \frac{C}{B}\right) + -1}{B}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 35.6% accurate, 2.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} \mathbf{if}\;B\_m \leq 0.000145:\\ \;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{F \cdot \frac{A + C}{B\_m} - F}{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 0.000145)
   (/ (sqrt (* (* -16.0 (pow A 2.0)) (* C F))) (* C (* A 4.0)))
   (* (sqrt 2.0) (- (sqrt (/ (- (* F (/ (+ A C) B_m)) F) B_m))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 0.000145) {
		tmp = sqrt(((-16.0 * pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
	} else {
		tmp = sqrt(2.0) * -sqrt((((F * ((A + C) / B_m)) - F) / B_m));
	}
	return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    real(8) :: tmp
    if (b_m <= 0.000145d0) then
        tmp = sqrt((((-16.0d0) * (a ** 2.0d0)) * (c * f))) / (c * (a * 4.0d0))
    else
        tmp = sqrt(2.0d0) * -sqrt((((f * ((a + c) / b_m)) - f) / b_m))
    end if
    code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 0.000145) {
		tmp = Math.sqrt(((-16.0 * Math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
	} else {
		tmp = Math.sqrt(2.0) * -Math.sqrt((((F * ((A + C) / B_m)) - F) / B_m));
	}
	return tmp;
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	tmp = 0
	if B_m <= 0.000145:
		tmp = math.sqrt(((-16.0 * math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0))
	else:
		tmp = math.sqrt(2.0) * -math.sqrt((((F * ((A + C) / B_m)) - F) / B_m))
	return tmp
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if (B_m <= 0.000145)
		tmp = Float64(sqrt(Float64(Float64(-16.0 * (A ^ 2.0)) * Float64(C * F))) / Float64(C * Float64(A * 4.0)));
	else
		tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(Float64(Float64(F * Float64(Float64(A + C) / B_m)) - F) / B_m))));
	end
	return tmp
end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
	tmp = 0.0;
	if (B_m <= 0.000145)
		tmp = sqrt(((-16.0 * (A ^ 2.0)) * (C * F))) / (C * (A * 4.0));
	else
		tmp = sqrt(2.0) * -sqrt((((F * ((A + C) / B_m)) - F) / B_m));
	end
	tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 0.000145], N[(N[Sqrt[N[(N[(-16.0 * N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(N[(N[(F * N[(N[(A + C), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] - F), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 0.000145:\\
\;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\

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


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

    1. Initial program 18.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. Simplified20.9%

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{\color{blue}{\left(4 \cdot A\right) \cdot C}} \]
    9. Simplified8.6%

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

    if 1.45e-4 < B

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 35.5% accurate, 2.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} \mathbf{if}\;B\_m \leq 0.0071:\\ \;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{-F}{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 0.0071)
   (/ (sqrt (* (* -16.0 (pow A 2.0)) (* C F))) (* C (* A 4.0)))
   (* (sqrt 2.0) (- (sqrt (/ (- F) B_m))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 0.0071) {
		tmp = sqrt(((-16.0 * pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
	} else {
		tmp = sqrt(2.0) * -sqrt((-F / B_m));
	}
	return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    real(8) :: tmp
    if (b_m <= 0.0071d0) then
        tmp = sqrt((((-16.0d0) * (a ** 2.0d0)) * (c * f))) / (c * (a * 4.0d0))
    else
        tmp = sqrt(2.0d0) * -sqrt((-f / b_m))
    end if
    code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 0.0071) {
		tmp = Math.sqrt(((-16.0 * Math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0));
	} else {
		tmp = Math.sqrt(2.0) * -Math.sqrt((-F / B_m));
	}
	return tmp;
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	tmp = 0
	if B_m <= 0.0071:
		tmp = math.sqrt(((-16.0 * math.pow(A, 2.0)) * (C * F))) / (C * (A * 4.0))
	else:
		tmp = math.sqrt(2.0) * -math.sqrt((-F / B_m))
	return tmp
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if (B_m <= 0.0071)
		tmp = Float64(sqrt(Float64(Float64(-16.0 * (A ^ 2.0)) * Float64(C * F))) / Float64(C * Float64(A * 4.0)));
	else
		tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(Float64(-F) / B_m))));
	end
	return tmp
end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
	tmp = 0.0;
	if (B_m <= 0.0071)
		tmp = sqrt(((-16.0 * (A ^ 2.0)) * (C * F))) / (C * (A * 4.0));
	else
		tmp = sqrt(2.0) * -sqrt((-F / B_m));
	end
	tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 0.0071], N[(N[Sqrt[N[(N[(-16.0 * N[Power[A, 2.0], $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[((-F) / B$95$m), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 0.0071:\\
\;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\

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


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

    1. Initial program 18.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. Simplified20.9%

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

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

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

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

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

        \[\leadsto \frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{\color{blue}{\left(4 \cdot A\right) \cdot C}} \]
    9. Simplified8.6%

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

    if 0.0071000000000000004 < B

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{B}}} \cdot \sqrt{2} \]
    9. Step-by-step derivation
      1. associate-*r/40.9%

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

        \[\leadsto -\sqrt{\frac{\color{blue}{-F}}{B}} \cdot \sqrt{2} \]
    10. Simplified40.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq 0.0071:\\ \;\;\;\;\frac{\sqrt{\left(-16 \cdot {A}^{2}\right) \cdot \left(C \cdot F\right)}}{C \cdot \left(A \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{-F}{B}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 33.8% accurate, 2.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} \mathbf{if}\;F \leq -2.6 \cdot 10^{-68}:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{-F}{B\_m}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - B\_m\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 (<= F -2.6e-68)
   (* (sqrt 2.0) (- (sqrt (/ (- F) B_m))))
   (* (sqrt (* F (- A B_m))) (/ (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 (F <= -2.6e-68) {
		tmp = sqrt(2.0) * -sqrt((-F / B_m));
	} else {
		tmp = sqrt((F * (A - B_m))) * (sqrt(2.0) / -B_m);
	}
	return tmp;
}
B_m = abs(b)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    real(8) :: tmp
    if (f <= (-2.6d-68)) then
        tmp = sqrt(2.0d0) * -sqrt((-f / b_m))
    else
        tmp = sqrt((f * (a - b_m))) * (sqrt(2.0d0) / -b_m)
    end if
    code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	double tmp;
	if (F <= -2.6e-68) {
		tmp = Math.sqrt(2.0) * -Math.sqrt((-F / B_m));
	} else {
		tmp = Math.sqrt((F * (A - B_m))) * (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 F <= -2.6e-68:
		tmp = math.sqrt(2.0) * -math.sqrt((-F / B_m))
	else:
		tmp = math.sqrt((F * (A - B_m))) * (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 (F <= -2.6e-68)
		tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(Float64(-F) / B_m))));
	else
		tmp = Float64(sqrt(Float64(F * Float64(A - B_m))) * Float64(sqrt(2.0) / Float64(-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 (F <= -2.6e-68)
		tmp = sqrt(2.0) * -sqrt((-F / B_m));
	else
		tmp = sqrt((F * (A - B_m))) * (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[F, -2.6e-68], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[((-F) / B$95$m), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - B$95$m), $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}\;F \leq -2.6 \cdot 10^{-68}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{-F}{B\_m}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if F < -2.5999999999999998e-68

    1. Initial program 10.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. Simplified10.6%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{B}}} \cdot \sqrt{2} \]
    9. Step-by-step derivation
      1. associate-*r/17.0%

        \[\leadsto -\sqrt{\color{blue}{\frac{-1 \cdot F}{B}}} \cdot \sqrt{2} \]
      2. mul-1-neg17.0%

        \[\leadsto -\sqrt{\frac{\color{blue}{-F}}{B}} \cdot \sqrt{2} \]
    10. Simplified17.0%

      \[\leadsto -\sqrt{\color{blue}{\frac{-F}{B}}} \cdot \sqrt{2} \]

    if -2.5999999999999998e-68 < F

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 18.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. Simplified20.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.18e-4 < B

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{B}}} \cdot \sqrt{2} \]
    9. Step-by-step derivation
      1. associate-*r/40.9%

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

        \[\leadsto -\sqrt{\frac{\color{blue}{-F}}{B}} \cdot \sqrt{2} \]
    10. Simplified40.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \leq 0.000118:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{-0.25 \cdot \frac{F}{C}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{-F}{B}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 26.9% 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{2} \cdot \left(-\sqrt{\frac{-F}{B\_m}}\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) (- (sqrt (/ (- F) B_m)))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	return sqrt(2.0) * -sqrt((-F / B_m));
}
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) * -sqrt((-f / b_m))
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) * -Math.sqrt((-F / B_m));
}
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) * -math.sqrt((-F / B_m))
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(2.0) * Float64(-sqrt(Float64(Float64(-F) / B_m))))
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) * -sqrt((-F / B_m));
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[2.0], $MachinePrecision] * (-N[Sqrt[N[((-F) / B$95$m), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\sqrt{2} \cdot \left(-\sqrt{\frac{-F}{B\_m}}\right)
\end{array}
Derivation
  1. Initial program 18.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. Simplified18.9%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{B}}} \cdot \sqrt{2} \]
  9. Step-by-step derivation
    1. associate-*r/12.3%

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

      \[\leadsto -\sqrt{\frac{\color{blue}{-F}}{B}} \cdot \sqrt{2} \]
  10. Simplified12.3%

    \[\leadsto -\sqrt{\color{blue}{\frac{-F}{B}}} \cdot \sqrt{2} \]
  11. Final simplification12.3%

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

Alternative 12: 3.3% 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{\left|F \cdot \frac{2}{B\_m}\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 (fabs (* F (/ 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) {
	return sqrt(fabs((F * (2.0 / B_m))));
}
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(abs((f * (2.0d0 / b_m))))
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(Math.abs((F * (2.0 / B_m))));
}
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(math.fabs((F * (2.0 / B_m))))
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	return sqrt(abs(Float64(F * Float64(2.0 / B_m))))
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(abs((F * (2.0 / B_m))));
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := N[Sqrt[N[Abs[N[(F * N[(2.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\sqrt{\left|F \cdot \frac{2}{B\_m}\right|}
\end{array}
Derivation
  1. Initial program 18.2%

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

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

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

      \[\leadsto -\sqrt{\frac{F}{B}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{2}\right) \]
    3. rem-square-sqrt2.0%

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

    \[\leadsto \color{blue}{-\sqrt{\frac{F}{B}} \cdot \left(-1 \cdot \sqrt{2}\right)} \]
  6. Taylor expanded in F around 0 2.0%

    \[\leadsto \color{blue}{\sqrt{\frac{F}{B}} \cdot \sqrt{2}} \]
  7. Step-by-step derivation
    1. pow12.0%

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

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{F}{B} \cdot 2}\right)}}^{1} \]
  8. Applied egg-rr2.0%

    \[\leadsto \color{blue}{{\left(\sqrt{\frac{F}{B} \cdot 2}\right)}^{1}} \]
  9. Step-by-step derivation
    1. unpow12.0%

      \[\leadsto \color{blue}{\sqrt{\frac{F}{B} \cdot 2}} \]
    2. associate-*l/2.0%

      \[\leadsto \sqrt{\color{blue}{\frac{F \cdot 2}{B}}} \]
  10. Simplified2.0%

    \[\leadsto \color{blue}{\sqrt{\frac{F \cdot 2}{B}}} \]
  11. Step-by-step derivation
    1. associate-*l/2.0%

      \[\leadsto \sqrt{\color{blue}{\frac{F}{B} \cdot 2}} \]
    2. add-sqr-sqrt2.0%

      \[\leadsto \sqrt{\color{blue}{\sqrt{\frac{F}{B} \cdot 2} \cdot \sqrt{\frac{F}{B} \cdot 2}}} \]
    3. pow1/22.0%

      \[\leadsto \sqrt{\color{blue}{{\left(\frac{F}{B} \cdot 2\right)}^{0.5}} \cdot \sqrt{\frac{F}{B} \cdot 2}} \]
    4. pow1/22.2%

      \[\leadsto \sqrt{{\left(\frac{F}{B} \cdot 2\right)}^{0.5} \cdot \color{blue}{{\left(\frac{F}{B} \cdot 2\right)}^{0.5}}} \]
    5. pow-prod-down3.3%

      \[\leadsto \sqrt{\color{blue}{{\left(\left(\frac{F}{B} \cdot 2\right) \cdot \left(\frac{F}{B} \cdot 2\right)\right)}^{0.5}}} \]
    6. pow23.3%

      \[\leadsto \sqrt{{\color{blue}{\left({\left(\frac{F}{B} \cdot 2\right)}^{2}\right)}}^{0.5}} \]
    7. associate-*l/3.3%

      \[\leadsto \sqrt{{\left({\color{blue}{\left(\frac{F \cdot 2}{B}\right)}}^{2}\right)}^{0.5}} \]
    8. associate-/l*3.3%

      \[\leadsto \sqrt{{\left({\color{blue}{\left(F \cdot \frac{2}{B}\right)}}^{2}\right)}^{0.5}} \]
  12. Applied egg-rr3.3%

    \[\leadsto \sqrt{\color{blue}{{\left({\left(F \cdot \frac{2}{B}\right)}^{2}\right)}^{0.5}}} \]
  13. Step-by-step derivation
    1. unpow1/23.3%

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

      \[\leadsto \sqrt{\sqrt{\color{blue}{\left(F \cdot \frac{2}{B}\right) \cdot \left(F \cdot \frac{2}{B}\right)}}} \]
    3. rem-sqrt-square3.2%

      \[\leadsto \sqrt{\color{blue}{\left|F \cdot \frac{2}{B}\right|}} \]
  14. Simplified3.2%

    \[\leadsto \sqrt{\color{blue}{\left|F \cdot \frac{2}{B}\right|}} \]
  15. Add Preprocessing

Alternative 13: 1.7% accurate, 6.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ {\left(2 \cdot \frac{F}{B\_m}\right)}^{0.5} \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 (pow (* 2.0 (/ F B_m)) 0.5))
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 pow((2.0 * (F / B_m)), 0.5);
}
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 * (f / b_m)) ** 0.5d0
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.pow((2.0 * (F / B_m)), 0.5);
}
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.pow((2.0 * (F / B_m)), 0.5)
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(F / B_m)) ^ 0.5
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 * (F / B_m)) ^ 0.5;
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[Power[N[(2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
{\left(2 \cdot \frac{F}{B\_m}\right)}^{0.5}
\end{array}
Derivation
  1. Initial program 18.2%

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

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

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

      \[\leadsto -\sqrt{\frac{F}{B}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{2}\right) \]
    3. rem-square-sqrt2.0%

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

    \[\leadsto \color{blue}{-\sqrt{\frac{F}{B}} \cdot \left(-1 \cdot \sqrt{2}\right)} \]
  6. Taylor expanded in F around 0 2.0%

    \[\leadsto \color{blue}{\sqrt{\frac{F}{B}} \cdot \sqrt{2}} \]
  7. Step-by-step derivation
    1. sqrt-unprod2.0%

      \[\leadsto \color{blue}{\sqrt{\frac{F}{B} \cdot 2}} \]
    2. pow1/22.2%

      \[\leadsto \color{blue}{{\left(\frac{F}{B} \cdot 2\right)}^{0.5}} \]
  8. Applied egg-rr2.2%

    \[\leadsto \color{blue}{{\left(\frac{F}{B} \cdot 2\right)}^{0.5}} \]
  9. Final simplification2.2%

    \[\leadsto {\left(2 \cdot \frac{F}{B}\right)}^{0.5} \]
  10. Add Preprocessing

Alternative 14: 1.6% accurate, 6.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \sqrt{\frac{2 \cdot F}{B\_m}} \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 F) B_m)))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	return sqrt(((2.0 * F) / B_m));
}
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 * f) / b_m))
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 * F) / B_m));
}
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 * F) / B_m))
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	return sqrt(Float64(Float64(2.0 * F) / B_m))
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 * F) / B_m));
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := N[Sqrt[N[(N[(2.0 * F), $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])\\
\\
\sqrt{\frac{2 \cdot F}{B\_m}}
\end{array}
Derivation
  1. Initial program 18.2%

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

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

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

      \[\leadsto -\sqrt{\frac{F}{B}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{2}\right) \]
    3. rem-square-sqrt2.0%

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

    \[\leadsto \color{blue}{-\sqrt{\frac{F}{B}} \cdot \left(-1 \cdot \sqrt{2}\right)} \]
  6. Taylor expanded in F around 0 2.0%

    \[\leadsto \color{blue}{\sqrt{\frac{F}{B}} \cdot \sqrt{2}} \]
  7. Step-by-step derivation
    1. pow12.0%

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

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{F}{B} \cdot 2}\right)}}^{1} \]
  8. Applied egg-rr2.0%

    \[\leadsto \color{blue}{{\left(\sqrt{\frac{F}{B} \cdot 2}\right)}^{1}} \]
  9. Step-by-step derivation
    1. unpow12.0%

      \[\leadsto \color{blue}{\sqrt{\frac{F}{B} \cdot 2}} \]
    2. associate-*l/2.0%

      \[\leadsto \sqrt{\color{blue}{\frac{F \cdot 2}{B}}} \]
  10. Simplified2.0%

    \[\leadsto \color{blue}{\sqrt{\frac{F \cdot 2}{B}}} \]
  11. Final simplification2.0%

    \[\leadsto \sqrt{\frac{2 \cdot F}{B}} \]
  12. Add Preprocessing

Reproduce

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