ABCF->ab-angle b

Percentage Accurate: 19.5% → 62.3%
Time: 27.0s
Alternatives: 14
Speedup: 6.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 62.3% accurate, 0.2× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\ t_1 := \mathsf{hypot}\left(B\_m, A - C\right)\\ t_2 := -t\_0\\ t_3 := \left(4 \cdot A\right) \cdot C\\ t_4 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_3\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B\_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_3 - {B\_m}^{2}}\\ t_5 := F \cdot t\_0\\ \mathbf{if}\;t\_4 \leq -\infty:\\ \;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - t\_1}{\mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)}\right)}\\ \mathbf{elif}\;t\_4 \leq -1 \cdot 10^{-189}:\\ \;\;\;\;\frac{\sqrt{t\_5 \cdot \left(2 \cdot \left(A + \left(C - t\_1\right)\right)\right)}}{t\_2}\\ \mathbf{elif}\;t\_4 \leq 5 \cdot 10^{+131}:\\ \;\;\;\;\frac{\sqrt{t\_5 \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B\_m}^{2}}{C}\right)\right)\right)}}{t\_2}\\ \mathbf{elif}\;t\_4 \leq \infty:\\ \;\;\;\;\frac{\sqrt{F}}{\sqrt{-C}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(\sqrt{-F} \cdot \left(-\sqrt{B\_m}\right)\right)\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (fma B_m B_m (* A (* C -4.0))))
        (t_1 (hypot B_m (- A C)))
        (t_2 (- t_0))
        (t_3 (* (* 4.0 A) C))
        (t_4
         (/
          (sqrt
           (*
            (* 2.0 (* (- (pow B_m 2.0) t_3) F))
            (- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0))))))
          (- t_3 (pow B_m 2.0))))
        (t_5 (* F t_0)))
   (if (<= t_4 (- INFINITY))
     (-
      (sqrt (* 2.0 (* F (/ (- (+ A C) t_1) (fma B_m B_m (* -4.0 (* A C))))))))
     (if (<= t_4 -1e-189)
       (/ (sqrt (* t_5 (* 2.0 (+ A (- C t_1))))) t_2)
       (if (<= t_4 5e+131)
         (/
          (sqrt (* t_5 (* 2.0 (+ A (+ A (* -0.5 (/ (pow B_m 2.0) C)))))))
          t_2)
         (if (<= t_4 INFINITY)
           (/ (sqrt F) (sqrt (- C)))
           (* (/ (sqrt 2.0) B_m) (* (sqrt (- F)) (- (sqrt 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 t_1 = hypot(B_m, (A - C));
	double t_2 = -t_0;
	double t_3 = (4.0 * A) * C;
	double t_4 = sqrt(((2.0 * ((pow(B_m, 2.0) - t_3) * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / (t_3 - pow(B_m, 2.0));
	double t_5 = F * t_0;
	double tmp;
	if (t_4 <= -((double) INFINITY)) {
		tmp = -sqrt((2.0 * (F * (((A + C) - t_1) / fma(B_m, B_m, (-4.0 * (A * C)))))));
	} else if (t_4 <= -1e-189) {
		tmp = sqrt((t_5 * (2.0 * (A + (C - t_1))))) / t_2;
	} else if (t_4 <= 5e+131) {
		tmp = sqrt((t_5 * (2.0 * (A + (A + (-0.5 * (pow(B_m, 2.0) / C))))))) / t_2;
	} else if (t_4 <= ((double) INFINITY)) {
		tmp = sqrt(F) / sqrt(-C);
	} else {
		tmp = (sqrt(2.0) / B_m) * (sqrt(-F) * -sqrt(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)))
	t_1 = hypot(B_m, Float64(A - C))
	t_2 = Float64(-t_0)
	t_3 = Float64(Float64(4.0 * A) * C)
	t_4 = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - t_3) * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0)))))) / Float64(t_3 - (B_m ^ 2.0)))
	t_5 = Float64(F * t_0)
	tmp = 0.0
	if (t_4 <= Float64(-Inf))
		tmp = Float64(-sqrt(Float64(2.0 * Float64(F * Float64(Float64(Float64(A + C) - t_1) / fma(B_m, B_m, Float64(-4.0 * Float64(A * C))))))));
	elseif (t_4 <= -1e-189)
		tmp = Float64(sqrt(Float64(t_5 * Float64(2.0 * Float64(A + Float64(C - t_1))))) / t_2);
	elseif (t_4 <= 5e+131)
		tmp = Float64(sqrt(Float64(t_5 * Float64(2.0 * Float64(A + Float64(A + Float64(-0.5 * Float64((B_m ^ 2.0) / C))))))) / t_2);
	elseif (t_4 <= Inf)
		tmp = Float64(sqrt(F) / sqrt(Float64(-C)));
	else
		tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(sqrt(Float64(-F)) * Float64(-sqrt(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]}, Block[{t$95$1 = N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$2 = (-t$95$0)}, Block[{t$95$3 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$3), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$3 - N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(F * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], (-N[Sqrt[N[(2.0 * N[(F * N[(N[(N[(A + C), $MachinePrecision] - t$95$1), $MachinePrecision] / N[(B$95$m * B$95$m + N[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), If[LessEqual[t$95$4, -1e-189], N[(N[Sqrt[N[(t$95$5 * N[(2.0 * N[(A + N[(C - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[t$95$4, 5e+131], N[(N[Sqrt[N[(t$95$5 * N[(2.0 * N[(A + N[(A + N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(N[Sqrt[F], $MachinePrecision] / N[Sqrt[(-C)], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * N[(N[Sqrt[(-F)], $MachinePrecision] * (-N[Sqrt[B$95$m], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := \mathsf{hypot}\left(B\_m, A - C\right)\\
t_2 := -t\_0\\
t_3 := \left(4 \cdot A\right) \cdot C\\
t_4 := \frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - t\_3\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B\_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t\_3 - {B\_m}^{2}}\\
t_5 := F \cdot t\_0\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;-\sqrt{2 \cdot \left(F \cdot \frac{\left(A + C\right) - t\_1}{\mathsf{fma}\left(B\_m, B\_m, -4 \cdot \left(A \cdot C\right)\right)}\right)}\\

\mathbf{elif}\;t\_4 \leq -1 \cdot 10^{-189}:\\
\;\;\;\;\frac{\sqrt{t\_5 \cdot \left(2 \cdot \left(A + \left(C - t\_1\right)\right)\right)}}{t\_2}\\

\mathbf{elif}\;t\_4 \leq 5 \cdot 10^{+131}:\\
\;\;\;\;\frac{\sqrt{t\_5 \cdot \left(2 \cdot \left(A + \left(A + -0.5 \cdot \frac{{B\_m}^{2}}{C}\right)\right)\right)}}{t\_2}\\

\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\frac{\sqrt{F}}{\sqrt{-C}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -inf.0

    1. Initial program 3.3%

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

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

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

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

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

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

    if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -1.00000000000000007e-189

    1. Initial program 98.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. Simplified98.1%

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

    if -1.00000000000000007e-189 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < 4.99999999999999995e131

    1. Initial program 22.3%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified24.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 35.4%

      \[\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-neg35.4%

        \[\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. Simplified35.4%

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

    if 4.99999999999999995e131 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < +inf.0

    1. Initial program 29.2%

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

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

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

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

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

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

      \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{C}}} \]
    9. Step-by-step derivation
      1. mul-1-neg1.6%

        \[\leadsto -\sqrt{\color{blue}{-\frac{F}{C}}} \]
    10. Simplified1.6%

      \[\leadsto -\sqrt{\color{blue}{-\frac{F}{C}}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt0.9%

        \[\leadsto \color{blue}{\sqrt{-\sqrt{-\frac{F}{C}}} \cdot \sqrt{-\sqrt{-\frac{F}{C}}}} \]
      2. sqrt-unprod30.0%

        \[\leadsto \color{blue}{\sqrt{\left(-\sqrt{-\frac{F}{C}}\right) \cdot \left(-\sqrt{-\frac{F}{C}}\right)}} \]
      3. sqr-neg30.0%

        \[\leadsto \sqrt{\color{blue}{\sqrt{-\frac{F}{C}} \cdot \sqrt{-\frac{F}{C}}}} \]
      4. add-sqr-sqrt30.0%

        \[\leadsto \sqrt{\color{blue}{-\frac{F}{C}}} \]
      5. distribute-neg-frac230.0%

        \[\leadsto \sqrt{\color{blue}{\frac{F}{-C}}} \]
      6. sqrt-div61.6%

        \[\leadsto \color{blue}{\frac{\sqrt{F}}{\sqrt{-C}}} \]
    12. Applied egg-rr61.6%

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

    if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)))

    1. Initial program 0.0%

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

      \[\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-neg1.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 55.6% accurate, 1.2× speedup?

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

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

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


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

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

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

      \[\leadsto \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)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    5. Taylor expanded in C around inf 21.9%

      \[\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)}}}{4 \cdot \left(A \cdot C\right)} \]
    6. Step-by-step derivation
      1. associate-*r*21.8%

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

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

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

    if 4.9999999999999999e-86 < (pow.f64 B #s(literal 2 binary64)) < 5.00000000000000026e300

    1. Initial program 40.2%

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

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

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

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

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

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

    if 5.00000000000000026e300 < (pow.f64 B #s(literal 2 binary64))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 53.5% accurate, 1.2× speedup?

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

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

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


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

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

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

      \[\leadsto \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)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    5. Taylor expanded in C around inf 21.9%

      \[\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)}}}{4 \cdot \left(A \cdot C\right)} \]
    6. Step-by-step derivation
      1. associate-*r*21.8%

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

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

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

    if 4.9999999999999999e-86 < (pow.f64 B #s(literal 2 binary64)) < 5.00000000000000026e300

    1. Initial program 40.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000026e300 < (pow.f64 B #s(literal 2 binary64))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 52.4% 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 1.8 \cdot 10^{-42}:\\ \;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{4 \cdot \left(A \cdot C\right)}\\ \mathbf{elif}\;B\_m \leq 6.5 \cdot 10^{+174}:\\ \;\;\;\;\frac{-1}{\frac{B\_m}{\sqrt{\left(A - \mathsf{hypot}\left(B\_m, A\right)\right) \cdot \left(2 \cdot F\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(\sqrt{-F} \cdot \left(-\sqrt{B\_m}\right)\right)\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (if (<= B_m 1.8e-42)
   (/ (sqrt (* -8.0 (* (* A C) (* F (+ A A))))) (* 4.0 (* A C)))
   (if (<= B_m 6.5e+174)
     (/ -1.0 (/ B_m (sqrt (* (- A (hypot B_m A)) (* 2.0 F)))))
     (* (/ (sqrt 2.0) B_m) (* (sqrt (- F)) (- (sqrt B_m)))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 1.8e-42) {
		tmp = sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C));
	} else if (B_m <= 6.5e+174) {
		tmp = -1.0 / (B_m / sqrt(((A - hypot(B_m, A)) * (2.0 * F))));
	} else {
		tmp = (sqrt(2.0) / B_m) * (sqrt(-F) * -sqrt(B_m));
	}
	return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 1.8e-42) {
		tmp = Math.sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C));
	} else if (B_m <= 6.5e+174) {
		tmp = -1.0 / (B_m / Math.sqrt(((A - Math.hypot(B_m, A)) * (2.0 * F))));
	} else {
		tmp = (Math.sqrt(2.0) / B_m) * (Math.sqrt(-F) * -Math.sqrt(B_m));
	}
	return tmp;
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	tmp = 0
	if B_m <= 1.8e-42:
		tmp = math.sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C))
	elif B_m <= 6.5e+174:
		tmp = -1.0 / (B_m / math.sqrt(((A - math.hypot(B_m, A)) * (2.0 * F))))
	else:
		tmp = (math.sqrt(2.0) / B_m) * (math.sqrt(-F) * -math.sqrt(B_m))
	return tmp
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if (B_m <= 1.8e-42)
		tmp = Float64(sqrt(Float64(-8.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))) / Float64(4.0 * Float64(A * C)));
	elseif (B_m <= 6.5e+174)
		tmp = Float64(-1.0 / Float64(B_m / sqrt(Float64(Float64(A - hypot(B_m, A)) * Float64(2.0 * F)))));
	else
		tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(sqrt(Float64(-F)) * Float64(-sqrt(B_m))));
	end
	return tmp
end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
	tmp = 0.0;
	if (B_m <= 1.8e-42)
		tmp = sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C));
	elseif (B_m <= 6.5e+174)
		tmp = -1.0 / (B_m / sqrt(((A - hypot(B_m, A)) * (2.0 * F))));
	else
		tmp = (sqrt(2.0) / B_m) * (sqrt(-F) * -sqrt(B_m));
	end
	tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 1.8e-42], N[(N[Sqrt[N[(-8.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 6.5e+174], N[(-1.0 / N[(B$95$m / N[Sqrt[N[(N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * N[(N[Sqrt[(-F)], $MachinePrecision] * (-N[Sqrt[B$95$m], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 1.8 \cdot 10^{-42}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{4 \cdot \left(A \cdot C\right)}\\

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

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


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

    1. Initial program 21.1%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified20.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 C around inf 14.5%

      \[\leadsto \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)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    5. Taylor expanded in C around inf 14.9%

      \[\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)}}}{4 \cdot \left(A \cdot C\right)} \]
    6. Step-by-step derivation
      1. associate-*r*14.8%

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

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

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

    if 1.8000000000000001e-42 < B < 6.5000000000000001e174

    1. Initial program 34.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}} \]
    6. Step-by-step derivation
      1. add-exp-log36.8%

        \[\leadsto -\color{blue}{e^{\log \left(\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)}} \]
      2. associate-*l/36.8%

        \[\leadsto -e^{\log \color{blue}{\left(\frac{\sqrt{2} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}{B}\right)}} \]
      3. pow1/236.8%

        \[\leadsto -e^{\log \left(\frac{\color{blue}{{2}^{0.5}} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}{B}\right)} \]
      4. pow1/236.8%

        \[\leadsto -e^{\log \left(\frac{{2}^{0.5} \cdot \color{blue}{{\left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}^{0.5}}}{B}\right)} \]
      5. pow-prod-down36.8%

        \[\leadsto -e^{\log \left(\frac{\color{blue}{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}}{B}\right)} \]
    7. Applied egg-rr36.8%

      \[\leadsto -\color{blue}{e^{\log \left(\frac{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}{B}\right)}} \]
    8. Step-by-step derivation
      1. rem-exp-log39.7%

        \[\leadsto -\color{blue}{\frac{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}{B}} \]
      2. clear-num39.7%

        \[\leadsto -\color{blue}{\frac{1}{\frac{B}{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}}} \]
      3. unpow1/239.7%

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

        \[\leadsto -\frac{1}{\frac{B}{\sqrt{\color{blue}{\left(2 \cdot F\right) \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}}} \]
    9. Applied egg-rr39.7%

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

    if 6.5000000000000001e174 < B

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\sqrt{2}}{B} \cdot \sqrt{\color{blue}{-B \cdot F}} \]
    8. Simplified42.8%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 46.2% accurate, 2.8× speedup?

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

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

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


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

    1. Initial program 21.1%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified20.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 C around inf 14.5%

      \[\leadsto \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)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    5. Taylor expanded in C around inf 14.9%

      \[\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)}}}{4 \cdot \left(A \cdot C\right)} \]
    6. Step-by-step derivation
      1. associate-*r*14.8%

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

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

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

    if 1.05000000000000003e-42 < B < 5.50000000000000013e188

    1. Initial program 33.5%

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

      \[\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-neg33.8%

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

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

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

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

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

      \[\leadsto \color{blue}{-\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}} \]
    6. Step-by-step derivation
      1. add-exp-log35.7%

        \[\leadsto -\color{blue}{e^{\log \left(\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)}} \]
      2. associate-*l/35.7%

        \[\leadsto -e^{\log \color{blue}{\left(\frac{\sqrt{2} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}{B}\right)}} \]
      3. pow1/235.7%

        \[\leadsto -e^{\log \left(\frac{\color{blue}{{2}^{0.5}} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}{B}\right)} \]
      4. pow1/235.7%

        \[\leadsto -e^{\log \left(\frac{{2}^{0.5} \cdot \color{blue}{{\left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}^{0.5}}}{B}\right)} \]
      5. pow-prod-down35.7%

        \[\leadsto -e^{\log \left(\frac{\color{blue}{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}}{B}\right)} \]
    7. Applied egg-rr35.7%

      \[\leadsto -\color{blue}{e^{\log \left(\frac{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}{B}\right)}} \]
    8. Step-by-step derivation
      1. rem-exp-log38.5%

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

        \[\leadsto -\color{blue}{\frac{1}{\frac{B}{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}}} \]
      3. unpow1/238.4%

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

        \[\leadsto -\frac{1}{\frac{B}{\sqrt{\color{blue}{\left(2 \cdot F\right) \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}}} \]
    9. Applied egg-rr38.4%

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

    if 5.50000000000000013e188 < B

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 46.1% 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 2.1 \cdot 10^{-42}:\\ \;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{4 \cdot \left(A \cdot C\right)}\\ \mathbf{elif}\;B\_m \leq 2.6 \cdot 10^{+174}:\\ \;\;\;\;\frac{-1}{\frac{B\_m}{\sqrt{\left(A - \mathsf{hypot}\left(B\_m, A\right)\right) \cdot \left(2 \cdot F\right)}}}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (if (<= B_m 2.1e-42)
   (/ (sqrt (* -8.0 (* (* A C) (* F (+ A A))))) (* 4.0 (* A C)))
   (if (<= B_m 2.6e+174)
     (/ -1.0 (/ B_m (sqrt (* (- A (hypot B_m A)) (* 2.0 F)))))
     (- (sqrt (* -2.0 (/ F B_m)))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 2.1e-42) {
		tmp = sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C));
	} else if (B_m <= 2.6e+174) {
		tmp = -1.0 / (B_m / sqrt(((A - hypot(B_m, A)) * (2.0 * F))));
	} else {
		tmp = -sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 2.1e-42) {
		tmp = Math.sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C));
	} else if (B_m <= 2.6e+174) {
		tmp = -1.0 / (B_m / Math.sqrt(((A - Math.hypot(B_m, A)) * (2.0 * F))));
	} else {
		tmp = -Math.sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	tmp = 0
	if B_m <= 2.1e-42:
		tmp = math.sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C))
	elif B_m <= 2.6e+174:
		tmp = -1.0 / (B_m / math.sqrt(((A - math.hypot(B_m, A)) * (2.0 * F))))
	else:
		tmp = -math.sqrt((-2.0 * (F / B_m)))
	return tmp
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if (B_m <= 2.1e-42)
		tmp = Float64(sqrt(Float64(-8.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))) / Float64(4.0 * Float64(A * C)));
	elseif (B_m <= 2.6e+174)
		tmp = Float64(-1.0 / Float64(B_m / sqrt(Float64(Float64(A - hypot(B_m, A)) * Float64(2.0 * F)))));
	else
		tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / B_m))));
	end
	return tmp
end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
	tmp = 0.0;
	if (B_m <= 2.1e-42)
		tmp = sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C));
	elseif (B_m <= 2.6e+174)
		tmp = -1.0 / (B_m / sqrt(((A - hypot(B_m, A)) * (2.0 * F))));
	else
		tmp = -sqrt((-2.0 * (F / B_m)));
	end
	tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 2.1e-42], N[(N[Sqrt[N[(-8.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 2.6e+174], N[(-1.0 / N[(B$95$m / N[Sqrt[N[(N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 2.1 \cdot 10^{-42}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{4 \cdot \left(A \cdot C\right)}\\

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

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


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

    1. Initial program 21.1%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified20.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 C around inf 14.5%

      \[\leadsto \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)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    5. Taylor expanded in C around inf 14.9%

      \[\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)}}}{4 \cdot \left(A \cdot C\right)} \]
    6. Step-by-step derivation
      1. associate-*r*14.8%

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

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

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

    if 2.10000000000000006e-42 < B < 2.5999999999999999e174

    1. Initial program 34.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}} \]
    6. Step-by-step derivation
      1. add-exp-log36.8%

        \[\leadsto -\color{blue}{e^{\log \left(\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)}} \]
      2. associate-*l/36.8%

        \[\leadsto -e^{\log \color{blue}{\left(\frac{\sqrt{2} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}{B}\right)}} \]
      3. pow1/236.8%

        \[\leadsto -e^{\log \left(\frac{\color{blue}{{2}^{0.5}} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}{B}\right)} \]
      4. pow1/236.8%

        \[\leadsto -e^{\log \left(\frac{{2}^{0.5} \cdot \color{blue}{{\left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}^{0.5}}}{B}\right)} \]
      5. pow-prod-down36.8%

        \[\leadsto -e^{\log \left(\frac{\color{blue}{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}}{B}\right)} \]
    7. Applied egg-rr36.8%

      \[\leadsto -\color{blue}{e^{\log \left(\frac{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}{B}\right)}} \]
    8. Step-by-step derivation
      1. rem-exp-log39.7%

        \[\leadsto -\color{blue}{\frac{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}{B}} \]
      2. clear-num39.7%

        \[\leadsto -\color{blue}{\frac{1}{\frac{B}{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}}} \]
      3. unpow1/239.7%

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

        \[\leadsto -\frac{1}{\frac{B}{\sqrt{\color{blue}{\left(2 \cdot F\right) \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}}} \]
    9. Applied egg-rr39.7%

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

    if 2.5999999999999999e174 < B

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

Alternative 7: 46.1% 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 2.6 \cdot 10^{-41}:\\ \;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{4 \cdot \left(A \cdot C\right)}\\ \mathbf{elif}\;B\_m \leq 3.9 \cdot 10^{+176}:\\ \;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)\right)}}{-B\_m}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{-2 \cdot \frac{F}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (if (<= B_m 2.6e-41)
   (/ (sqrt (* -8.0 (* (* A C) (* F (+ A A))))) (* 4.0 (* A C)))
   (if (<= B_m 3.9e+176)
     (/ (sqrt (* 2.0 (* F (- A (hypot B_m A))))) (- B_m))
     (- (sqrt (* -2.0 (/ F B_m)))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 2.6e-41) {
		tmp = sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C));
	} else if (B_m <= 3.9e+176) {
		tmp = sqrt((2.0 * (F * (A - hypot(B_m, A))))) / -B_m;
	} else {
		tmp = -sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 2.6e-41) {
		tmp = Math.sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C));
	} else if (B_m <= 3.9e+176) {
		tmp = Math.sqrt((2.0 * (F * (A - Math.hypot(B_m, A))))) / -B_m;
	} else {
		tmp = -Math.sqrt((-2.0 * (F / B_m)));
	}
	return tmp;
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	tmp = 0
	if B_m <= 2.6e-41:
		tmp = math.sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C))
	elif B_m <= 3.9e+176:
		tmp = math.sqrt((2.0 * (F * (A - math.hypot(B_m, A))))) / -B_m
	else:
		tmp = -math.sqrt((-2.0 * (F / B_m)))
	return tmp
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if (B_m <= 2.6e-41)
		tmp = Float64(sqrt(Float64(-8.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))) / Float64(4.0 * Float64(A * C)));
	elseif (B_m <= 3.9e+176)
		tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(A - hypot(B_m, A))))) / Float64(-B_m));
	else
		tmp = Float64(-sqrt(Float64(-2.0 * Float64(F / B_m))));
	end
	return tmp
end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
	tmp = 0.0;
	if (B_m <= 2.6e-41)
		tmp = sqrt((-8.0 * ((A * C) * (F * (A + A))))) / (4.0 * (A * C));
	elseif (B_m <= 3.9e+176)
		tmp = sqrt((2.0 * (F * (A - hypot(B_m, A))))) / -B_m;
	else
		tmp = -sqrt((-2.0 * (F / B_m)));
	end
	tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 2.6e-41], N[(N[Sqrt[N[(-8.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 3.9e+176], N[(N[Sqrt[N[(2.0 * N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision], (-N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 2.6 \cdot 10^{-41}:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{4 \cdot \left(A \cdot C\right)}\\

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

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


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

    1. Initial program 21.1%

      \[\frac{-\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    2. Simplified20.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 C around inf 14.5%

      \[\leadsto \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)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    5. Taylor expanded in C around inf 14.9%

      \[\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)}}}{4 \cdot \left(A \cdot C\right)} \]
    6. Step-by-step derivation
      1. associate-*r*14.8%

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

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

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

    if 2.5999999999999999e-41 < B < 3.9000000000000001e176

    1. Initial program 34.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \frac{\color{blue}{{2}^{0.5}} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}}{B} \]
      4. pow1/239.6%

        \[\leadsto 0 - \frac{{2}^{0.5} \cdot \color{blue}{{\left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)}^{0.5}}}{B} \]
      5. pow-prod-down39.7%

        \[\leadsto 0 - \frac{\color{blue}{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}}{B} \]
    7. Applied egg-rr39.7%

      \[\leadsto \color{blue}{0 - \frac{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}{B}} \]
    8. Step-by-step derivation
      1. neg-sub039.7%

        \[\leadsto \color{blue}{-\frac{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}{B}} \]
      2. distribute-neg-frac239.7%

        \[\leadsto \color{blue}{\frac{{\left(2 \cdot \left(F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)\right)\right)}^{0.5}}{-B}} \]
      3. unpow1/239.7%

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

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

    if 3.9000000000000001e176 < B

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;B\_m \leq 7.4 \cdot 10^{+173}:\\
\;\;\;\;\left(\sqrt{2} \cdot \sqrt{B\_m \cdot \left(-F\right)}\right) \cdot \frac{-1}{B\_m}\\

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


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

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

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

      \[\leadsto \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)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    5. Taylor expanded in C around inf 15.7%

      \[\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)}}}{4 \cdot \left(A \cdot C\right)} \]
    6. Step-by-step derivation
      1. associate-*r*15.6%

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

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

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

    if 1.2500000000000001e-23 < B < 7.39999999999999972e173

    1. Initial program 38.5%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -\color{blue}{\frac{1}{\frac{B}{\sqrt{2}}}} \cdot \sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \]
    10. Step-by-step derivation
      1. distribute-rgt-neg-in43.5%

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{B} \cdot \sqrt{2}\right) \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right)} \]
    12. Step-by-step derivation
      1. associate-*l*43.6%

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

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

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

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

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

    if 7.39999999999999972e173 < B

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;B\_m \leq 6 \cdot 10^{+174}:\\
\;\;\;\;\sqrt{B\_m \cdot \left(-F\right)} \cdot \frac{\sqrt{2}}{-B\_m}\\

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


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

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

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

      \[\leadsto \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)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    5. Taylor expanded in C around inf 15.7%

      \[\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)}}}{4 \cdot \left(A \cdot C\right)} \]
    6. Step-by-step derivation
      1. associate-*r*15.6%

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

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

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

    if 4.4999999999999997e-24 < B < 6e174

    1. Initial program 38.5%

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

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

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

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

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

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

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

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

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

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

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

    if 6e174 < B

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

Alternative 10: 43.0% accurate, 5.2× speedup?

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

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


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

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

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

      \[\leadsto \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)}}{\color{blue}{4 \cdot \left(A \cdot C\right)}} \]
    5. Taylor expanded in C around inf 15.7%

      \[\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)}}}{4 \cdot \left(A \cdot C\right)} \]
    6. Step-by-step derivation
      1. associate-*r*15.6%

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

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

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

    if 4.6000000000000002e-23 < B

    1. Initial program 21.2%

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

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

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

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

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

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

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

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

Alternative 11: 40.6% accurate, 5.7× speedup?

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

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


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

    1. Initial program 21.3%

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

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

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

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

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

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

      \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{C}}} \]
    9. Step-by-step derivation
      1. mul-1-neg15.6%

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

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

    if 1.4000000000000001e-7 < B

    1. Initial program 19.6%

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

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

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

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

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

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

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

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

Alternative 12: 27.5% accurate, 6.0× speedup?

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

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

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

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

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

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

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

    \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{C}}} \]
  9. Step-by-step derivation
    1. mul-1-neg13.0%

      \[\leadsto -\sqrt{\color{blue}{-\frac{F}{C}}} \]
  10. Simplified13.0%

    \[\leadsto -\sqrt{\color{blue}{-\frac{F}{C}}} \]
  11. Final simplification13.0%

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

Alternative 13: 1.3% accurate, 6.1× speedup?

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

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

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

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

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

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

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

    \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{C}}} \]
  9. Step-by-step derivation
    1. mul-1-neg13.0%

      \[\leadsto -\sqrt{\color{blue}{-\frac{F}{C}}} \]
  10. Simplified13.0%

    \[\leadsto -\sqrt{\color{blue}{-\frac{F}{C}}} \]
  11. Step-by-step derivation
    1. neg-sub013.0%

      \[\leadsto \color{blue}{0 - \sqrt{-\frac{F}{C}}} \]
    2. add-sqr-sqrt13.0%

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

      \[\leadsto 0 - \sqrt{\color{blue}{\sqrt{\left(-\frac{F}{C}\right) \cdot \left(-\frac{F}{C}\right)}}} \]
    4. sqr-neg9.9%

      \[\leadsto 0 - \sqrt{\sqrt{\color{blue}{\frac{F}{C} \cdot \frac{F}{C}}}} \]
    5. sqrt-unprod2.9%

      \[\leadsto 0 - \sqrt{\color{blue}{\sqrt{\frac{F}{C}} \cdot \sqrt{\frac{F}{C}}}} \]
    6. add-sqr-sqrt2.9%

      \[\leadsto 0 - \sqrt{\color{blue}{\frac{F}{C}}} \]
  12. Applied egg-rr2.9%

    \[\leadsto \color{blue}{0 - \sqrt{\frac{F}{C}}} \]
  13. Step-by-step derivation
    1. neg-sub02.9%

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

    \[\leadsto \color{blue}{-\sqrt{\frac{F}{C}}} \]
  15. Add Preprocessing

Alternative 14: 0.9% accurate, 6.2× speedup?

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

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

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

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

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

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

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

    \[\leadsto -\sqrt{\color{blue}{-1 \cdot \frac{F}{C}}} \]
  9. Step-by-step derivation
    1. mul-1-neg13.0%

      \[\leadsto -\sqrt{\color{blue}{-\frac{F}{C}}} \]
  10. Simplified13.0%

    \[\leadsto -\sqrt{\color{blue}{-\frac{F}{C}}} \]
  11. Step-by-step derivation
    1. *-un-lft-identity13.0%

      \[\leadsto \color{blue}{1 \cdot \left(-\sqrt{-\frac{F}{C}}\right)} \]
    2. add-sqr-sqrt0.7%

      \[\leadsto 1 \cdot \color{blue}{\left(\sqrt{-\sqrt{-\frac{F}{C}}} \cdot \sqrt{-\sqrt{-\frac{F}{C}}}\right)} \]
    3. sqrt-unprod9.0%

      \[\leadsto 1 \cdot \color{blue}{\sqrt{\left(-\sqrt{-\frac{F}{C}}\right) \cdot \left(-\sqrt{-\frac{F}{C}}\right)}} \]
    4. sqr-neg9.0%

      \[\leadsto 1 \cdot \sqrt{\color{blue}{\sqrt{-\frac{F}{C}} \cdot \sqrt{-\frac{F}{C}}}} \]
    5. sqrt-unprod6.9%

      \[\leadsto 1 \cdot \sqrt{\color{blue}{\sqrt{\left(-\frac{F}{C}\right) \cdot \left(-\frac{F}{C}\right)}}} \]
    6. sqr-neg6.9%

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

      \[\leadsto 1 \cdot \sqrt{\color{blue}{\sqrt{\frac{F}{C}} \cdot \sqrt{\frac{F}{C}}}} \]
    8. add-sqr-sqrt1.2%

      \[\leadsto 1 \cdot \sqrt{\color{blue}{\frac{F}{C}}} \]
  12. Applied egg-rr1.2%

    \[\leadsto \color{blue}{1 \cdot \sqrt{\frac{F}{C}}} \]
  13. Step-by-step derivation
    1. *-lft-identity1.2%

      \[\leadsto \color{blue}{\sqrt{\frac{F}{C}}} \]
  14. Simplified1.2%

    \[\leadsto \color{blue}{\sqrt{\frac{F}{C}}} \]
  15. Add Preprocessing

Reproduce

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