ABCF->ab-angle a

Percentage Accurate: 19.6% → 52.0%
Time: 22.3s
Alternatives: 14
Speedup: 6.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 19.6% 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: 52.0% accurate, 1.2× speedup?

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

\mathbf{elif}\;B\_m \leq 1.95 \cdot 10^{-140}:\\
\;\;\;\;\frac{\sqrt{\left(F \cdot t\_0\right) \cdot \left(C \cdot 4\right)}}{-t\_0}\\

\mathbf{elif}\;B\_m \leq 9.2 \cdot 10^{+127}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if B < 1.89999999999999985e-250 or 1.9500000000000001e-140 < B < 9.2000000000000007e127

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

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

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

    if 1.89999999999999985e-250 < B < 1.9500000000000001e-140

    1. Initial program 25.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. Simplified40.0%

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

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

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

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

    if 9.2000000000000007e127 < 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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-115}:\\
\;\;\;\;t\_1 \cdot \left(-\sqrt{F \cdot t\_0}\right)\\

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

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

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


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

    1. Initial program 20.0%

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

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

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

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

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

    if 1.00000000000000005e-286 < (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000003e-115

    1. Initial program 16.7%

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000003e-115 < (pow.f64 B #s(literal 2 binary64)) < 9.99999999999999983e76

    1. Initial program 35.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. Simplified54.3%

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

    if 9.99999999999999983e76 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e152

    1. Initial program 7.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 12.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-neg12.0%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 10.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{-127}:\\
\;\;\;\;t\_1 \cdot \left(-\sqrt{F \cdot t\_0}\right)\\

\mathbf{elif}\;{B\_m}^{2} \leq 10^{+77}:\\
\;\;\;\;t\_3\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000005e-286 or 4.9999999999999997e-127 < (pow.f64 B #s(literal 2 binary64)) < 9.99999999999999983e76

    1. Initial program 24.7%

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

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

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

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

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

    if 1.00000000000000005e-286 < (pow.f64 B #s(literal 2 binary64)) < 4.9999999999999997e-127

    1. Initial program 17.0%

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999983e76 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e152

    1. Initial program 7.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 12.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-neg12.0%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 10.1%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 45.7% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 20.0%

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

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

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

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

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

    if 1.00000000000000005e-286 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e161

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 10.2%

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

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

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

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

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

        \[\leadsto -\sqrt{2} \cdot \color{blue}{{\left(\frac{F}{B}\right)}^{0.5}} \]
      2. div-inv24.2%

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

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

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

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

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

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

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

Alternative 5: 48.8% accurate, 1.4× speedup?

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

\mathbf{elif}\;B\_m \leq 3 \cdot 10^{-56}:\\
\;\;\;\;t\_5 \cdot \left(-\sqrt{F \cdot t\_1}\right)\\

\mathbf{elif}\;B\_m \leq 3.1 \cdot 10^{+38}:\\
\;\;\;\;\frac{\sqrt{t\_4 \cdot \left(2 \cdot \left(A + \left(C + \mathsf{hypot}\left(B\_m, A - C\right)\right)\right)\right)}}{t\_3}\\

\mathbf{elif}\;B\_m \leq 1.02 \cdot 10^{+77}:\\
\;\;\;\;t\_5 \cdot \left(\sqrt{F} \cdot \left(-\sqrt{t\_1}\right)\right)\\

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


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

    1. Initial program 17.4%

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

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

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

    if 3.89999999999999966e-127 < B < 2.99999999999999989e-56

    1. Initial program 1.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 C around 0 2.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-neg2.7%

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

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

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

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

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

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

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

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

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

    if 2.99999999999999989e-56 < B < 3.10000000000000018e38

    1. Initial program 38.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. Simplified64.3%

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

    if 3.10000000000000018e38 < B < 1.02e77

    1. Initial program 9.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.02e77 < B

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 46.0% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 16.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. Simplified22.9%

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

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

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

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

    if 1.25e-141 < B < 4.55000000000000007e80

    1. Initial program 19.7%

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

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

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

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

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

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

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

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

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

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

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

    if 4.55000000000000007e80 < B

    1. Initial program 13.1%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 47.2% accurate, 1.9× speedup?

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

\mathbf{elif}\;F \leq 6.3 \cdot 10^{-304}:\\
\;\;\;\;\sqrt{\left|\frac{F}{A}\right|}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if F < -1.36000000000000002e89

    1. Initial program 46.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 C around 0 6.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-neg6.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.36000000000000002e89 < F < 6.29999999999999984e-304

    1. Initial program 27.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. Simplified56.9%

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

        \[\leadsto \color{blue}{\sqrt{\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)}} \cdot \sqrt{\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)}}} \]
      2. sqrt-unprod52.7%

        \[\leadsto \color{blue}{\sqrt{\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)} \cdot \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. frac-times40.5%

        \[\leadsto \sqrt{\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)} \cdot \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)}}{\left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right) \cdot \left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)}}} \]
    5. Applied egg-rr43.9%

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

      \[\leadsto \sqrt{\color{blue}{-1 \cdot \frac{F}{A}}} \]
    7. Step-by-step derivation
      1. mul-1-neg41.7%

        \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    8. Simplified41.7%

      \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt41.7%

        \[\leadsto \sqrt{\color{blue}{\sqrt{-\frac{F}{A}} \cdot \sqrt{-\frac{F}{A}}}} \]
      2. pow1/241.7%

        \[\leadsto \sqrt{\color{blue}{{\left(-\frac{F}{A}\right)}^{0.5}} \cdot \sqrt{-\frac{F}{A}}} \]
      3. pow1/241.7%

        \[\leadsto \sqrt{{\left(-\frac{F}{A}\right)}^{0.5} \cdot \color{blue}{{\left(-\frac{F}{A}\right)}^{0.5}}} \]
      4. pow-prod-down36.6%

        \[\leadsto \sqrt{\color{blue}{{\left(\left(-\frac{F}{A}\right) \cdot \left(-\frac{F}{A}\right)\right)}^{0.5}}} \]
      5. pow236.6%

        \[\leadsto \sqrt{{\color{blue}{\left({\left(-\frac{F}{A}\right)}^{2}\right)}}^{0.5}} \]
      6. distribute-neg-frac236.6%

        \[\leadsto \sqrt{{\left({\color{blue}{\left(\frac{F}{-A}\right)}}^{2}\right)}^{0.5}} \]
    10. Applied egg-rr36.6%

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

        \[\leadsto \sqrt{\color{blue}{\sqrt{{\left(\frac{F}{-A}\right)}^{2}}}} \]
      2. unpow236.6%

        \[\leadsto \sqrt{\sqrt{\color{blue}{\frac{F}{-A} \cdot \frac{F}{-A}}}} \]
      3. rem-sqrt-square42.0%

        \[\leadsto \sqrt{\color{blue}{\left|\frac{F}{-A}\right|}} \]
      4. distribute-frac-neg242.0%

        \[\leadsto \sqrt{\left|\color{blue}{-\frac{F}{A}}\right|} \]
    12. Simplified42.0%

      \[\leadsto \sqrt{\color{blue}{\left|-\frac{F}{A}\right|}} \]

    if 6.29999999999999984e-304 < F < 2.8999999999999998e-26

    1. Initial program 13.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 A around 0 6.9%

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

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

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

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

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

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

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

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

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

    if 2.8999999999999998e-26 < F

    1. Initial program 12.2%

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

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

        \[\leadsto \color{blue}{-\sqrt{\frac{F}{B}} \cdot \sqrt{2}} \]
      2. *-commutative22.1%

        \[\leadsto -\color{blue}{\sqrt{2} \cdot \sqrt{\frac{F}{B}}} \]
    5. Simplified22.1%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -1.36 \cdot 10^{+89}:\\ \;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(A + \mathsf{hypot}\left(B, A\right)\right)\right)}}{-B}\\ \mathbf{elif}\;F \leq 6.3 \cdot 10^{-304}:\\ \;\;\;\;\sqrt{\left|\frac{F}{A}\right|}\\ \mathbf{elif}\;F \leq 2.9 \cdot 10^{-26}:\\ \;\;\;\;\sqrt{F \cdot \left(C + \mathsf{hypot}\left(C, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \left(\sqrt{F} \cdot \left(-\sqrt{\frac{1}{B}}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

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

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

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


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

    1. Initial program 16.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. Simplified22.9%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(-4 \cdot \left(A \cdot \left(C \cdot F\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)} \]
    5. Step-by-step derivation
      1. associate-*r*18.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(-4 \cdot A\right) \cdot \left(C \cdot F\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)} \]
    6. Simplified18.5%

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

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

    if 8.59999999999999912e-143 < B < 4.50000000000000007e80

    1. Initial program 19.7%

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

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

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

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

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

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

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

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

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

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

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

    if 4.50000000000000007e80 < B

    1. Initial program 13.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 44.1% accurate, 2.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;B\_m \leq 3.3 \cdot 10^{-140}:\\ \;\;\;\;\frac{\sqrt{\left(\left(A \cdot -4\right) \cdot \left(F \cdot C\right)\right) \cdot \left(2 \cdot \left(2 \cdot C\right)\right)}}{-\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{elif}\;B\_m \leq 8.2 \cdot 10^{-99}:\\ \;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(A + \mathsf{hypot}\left(B\_m, A\right)\right)\right)}}{-B\_m}\\ \mathbf{elif}\;B\_m \leq 7.5 \cdot 10^{-30}:\\ \;\;\;\;\sqrt{\left|\frac{F}{A}\right|}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot \frac{\sqrt{F}}{-\sqrt{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 3.3e-140)
   (/
    (sqrt (* (* (* A -4.0) (* F C)) (* 2.0 (* 2.0 C))))
    (- (fma B_m B_m (* A (* C -4.0)))))
   (if (<= B_m 8.2e-99)
     (/ (sqrt (* 2.0 (* F (+ A (hypot B_m A))))) (- B_m))
     (if (<= B_m 7.5e-30)
       (sqrt (fabs (/ F A)))
       (* (sqrt 2.0) (/ (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 <= 3.3e-140) {
		tmp = sqrt((((A * -4.0) * (F * C)) * (2.0 * (2.0 * C)))) / -fma(B_m, B_m, (A * (C * -4.0)));
	} else if (B_m <= 8.2e-99) {
		tmp = sqrt((2.0 * (F * (A + hypot(B_m, A))))) / -B_m;
	} else if (B_m <= 7.5e-30) {
		tmp = sqrt(fabs((F / A)));
	} else {
		tmp = sqrt(2.0) * (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 <= 3.3e-140)
		tmp = Float64(sqrt(Float64(Float64(Float64(A * -4.0) * Float64(F * C)) * Float64(2.0 * Float64(2.0 * C)))) / Float64(-fma(B_m, B_m, Float64(A * Float64(C * -4.0)))));
	elseif (B_m <= 8.2e-99)
		tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(A + hypot(B_m, A))))) / Float64(-B_m));
	elseif (B_m <= 7.5e-30)
		tmp = sqrt(abs(Float64(F / A)));
	else
		tmp = Float64(sqrt(2.0) * Float64(sqrt(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[B$95$m, 3.3e-140], N[(N[Sqrt[N[(N[(N[(A * -4.0), $MachinePrecision] * N[(F * C), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 8.2e-99], 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], If[LessEqual[B$95$m, 7.5e-30], N[Sqrt[N[Abs[N[(F / A), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[2.0], $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 3.3 \cdot 10^{-140}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A \cdot -4\right) \cdot \left(F \cdot C\right)\right) \cdot \left(2 \cdot \left(2 \cdot C\right)\right)}}{-\mathsf{fma}\left(B\_m, B\_m, A \cdot \left(C \cdot -4\right)\right)}\\

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

\mathbf{elif}\;B\_m \leq 7.5 \cdot 10^{-30}:\\
\;\;\;\;\sqrt{\left|\frac{F}{A}\right|}\\

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


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

    1. Initial program 16.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. Simplified22.9%

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(-4 \cdot \left(A \cdot \left(C \cdot F\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)} \]
    5. Step-by-step derivation
      1. associate-*r*18.5%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(\left(-4 \cdot A\right) \cdot \left(C \cdot F\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)} \]
    6. Simplified18.5%

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

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

    if 3.29999999999999987e-140 < B < 8.20000000000000057e-99

    1. Initial program 23.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 C around 0 2.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.20000000000000057e-99 < B < 7.5000000000000006e-30

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

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

        \[\leadsto \color{blue}{\sqrt{\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)}} \cdot \sqrt{\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)}}} \]
      2. sqrt-unprod13.0%

        \[\leadsto \color{blue}{\sqrt{\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)} \cdot \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. frac-times9.9%

        \[\leadsto \sqrt{\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)} \cdot \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)}}{\left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right) \cdot \left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)}}} \]
    5. Applied egg-rr9.9%

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

      \[\leadsto \sqrt{\color{blue}{-1 \cdot \frac{F}{A}}} \]
    7. Step-by-step derivation
      1. mul-1-neg26.8%

        \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    8. Simplified26.8%

      \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt26.8%

        \[\leadsto \sqrt{\color{blue}{\sqrt{-\frac{F}{A}} \cdot \sqrt{-\frac{F}{A}}}} \]
      2. pow1/226.8%

        \[\leadsto \sqrt{\color{blue}{{\left(-\frac{F}{A}\right)}^{0.5}} \cdot \sqrt{-\frac{F}{A}}} \]
      3. pow1/226.8%

        \[\leadsto \sqrt{{\left(-\frac{F}{A}\right)}^{0.5} \cdot \color{blue}{{\left(-\frac{F}{A}\right)}^{0.5}}} \]
      4. pow-prod-down19.6%

        \[\leadsto \sqrt{\color{blue}{{\left(\left(-\frac{F}{A}\right) \cdot \left(-\frac{F}{A}\right)\right)}^{0.5}}} \]
      5. pow219.6%

        \[\leadsto \sqrt{{\color{blue}{\left({\left(-\frac{F}{A}\right)}^{2}\right)}}^{0.5}} \]
      6. distribute-neg-frac219.6%

        \[\leadsto \sqrt{{\left({\color{blue}{\left(\frac{F}{-A}\right)}}^{2}\right)}^{0.5}} \]
    10. Applied egg-rr19.6%

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

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

        \[\leadsto \sqrt{\sqrt{\color{blue}{\frac{F}{-A} \cdot \frac{F}{-A}}}} \]
      3. rem-sqrt-square27.1%

        \[\leadsto \sqrt{\color{blue}{\left|\frac{F}{-A}\right|}} \]
      4. distribute-frac-neg227.1%

        \[\leadsto \sqrt{\left|\color{blue}{-\frac{F}{A}}\right|} \]
    12. Simplified27.1%

      \[\leadsto \sqrt{\color{blue}{\left|-\frac{F}{A}\right|}} \]

    if 7.5000000000000006e-30 < B

    1. Initial program 18.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 B around inf 39.5%

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

        \[\leadsto \color{blue}{-\sqrt{\frac{F}{B}} \cdot \sqrt{2}} \]
      2. *-commutative39.5%

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

      \[\leadsto \color{blue}{-\sqrt{2} \cdot \sqrt{\frac{F}{B}}} \]
    6. Step-by-step derivation
      1. sqrt-div53.4%

        \[\leadsto -\sqrt{2} \cdot \color{blue}{\frac{\sqrt{F}}{\sqrt{B}}} \]
    7. Applied egg-rr53.4%

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

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

Alternative 10: 44.3% 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} t_0 := \frac{\sqrt{2 \cdot \left(F \cdot \left(A + \mathsf{hypot}\left(B\_m, A\right)\right)\right)}}{-B\_m}\\ \mathbf{if}\;F \leq -8.8 \cdot 10^{+93}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;F \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\sqrt{\left|\frac{F}{A}\right|}\\ \mathbf{elif}\;F \leq 7.5 \cdot 10^{-21}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{2 \cdot \frac{F}{B\_m}}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (/ (sqrt (* 2.0 (* F (+ A (hypot B_m A))))) (- B_m))))
   (if (<= F -8.8e+93)
     t_0
     (if (<= F -4e-310)
       (sqrt (fabs (/ F A)))
       (if (<= F 7.5e-21) t_0 (- (sqrt (* 2.0 (/ F B_m)))))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double t_0 = sqrt((2.0 * (F * (A + hypot(B_m, A))))) / -B_m;
	double tmp;
	if (F <= -8.8e+93) {
		tmp = t_0;
	} else if (F <= -4e-310) {
		tmp = sqrt(fabs((F / A)));
	} else if (F <= 7.5e-21) {
		tmp = t_0;
	} 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 t_0 = Math.sqrt((2.0 * (F * (A + Math.hypot(B_m, A))))) / -B_m;
	double tmp;
	if (F <= -8.8e+93) {
		tmp = t_0;
	} else if (F <= -4e-310) {
		tmp = Math.sqrt(Math.abs((F / A)));
	} else if (F <= 7.5e-21) {
		tmp = t_0;
	} 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):
	t_0 = math.sqrt((2.0 * (F * (A + math.hypot(B_m, A))))) / -B_m
	tmp = 0
	if F <= -8.8e+93:
		tmp = t_0
	elif F <= -4e-310:
		tmp = math.sqrt(math.fabs((F / A)))
	elif F <= 7.5e-21:
		tmp = t_0
	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)
	t_0 = Float64(sqrt(Float64(2.0 * Float64(F * Float64(A + hypot(B_m, A))))) / Float64(-B_m))
	tmp = 0.0
	if (F <= -8.8e+93)
		tmp = t_0;
	elseif (F <= -4e-310)
		tmp = sqrt(abs(Float64(F / A)));
	elseif (F <= 7.5e-21)
		tmp = t_0;
	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)
	t_0 = sqrt((2.0 * (F * (A + hypot(B_m, A))))) / -B_m;
	tmp = 0.0;
	if (F <= -8.8e+93)
		tmp = t_0;
	elseif (F <= -4e-310)
		tmp = sqrt(abs((F / A)));
	elseif (F <= 7.5e-21)
		tmp = t_0;
	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_] := Block[{t$95$0 = 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]}, If[LessEqual[F, -8.8e+93], t$95$0, If[LessEqual[F, -4e-310], N[Sqrt[N[Abs[N[(F / A), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[F, 7.5e-21], t$95$0, (-N[Sqrt[N[(2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \frac{\sqrt{2 \cdot \left(F \cdot \left(A + \mathsf{hypot}\left(B\_m, A\right)\right)\right)}}{-B\_m}\\
\mathbf{if}\;F \leq -8.8 \cdot 10^{+93}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;F \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\left|\frac{F}{A}\right|}\\

\mathbf{elif}\;F \leq 7.5 \cdot 10^{-21}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if F < -8.80000000000000084e93 or -3.999999999999988e-310 < F < 7.50000000000000072e-21

    1. Initial program 17.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.80000000000000084e93 < F < -3.999999999999988e-310

    1. Initial program 29.3%

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

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

        \[\leadsto \color{blue}{\sqrt{\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)}} \cdot \sqrt{\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)}}} \]
      2. sqrt-unprod56.4%

        \[\leadsto \color{blue}{\sqrt{\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)} \cdot \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. frac-times43.4%

        \[\leadsto \sqrt{\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)} \cdot \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)}}{\left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right) \cdot \left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)}}} \]
    5. Applied egg-rr47.0%

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

      \[\leadsto \sqrt{\color{blue}{-1 \cdot \frac{F}{A}}} \]
    7. Step-by-step derivation
      1. mul-1-neg44.2%

        \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    8. Simplified44.2%

      \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt44.2%

        \[\leadsto \sqrt{\color{blue}{\sqrt{-\frac{F}{A}} \cdot \sqrt{-\frac{F}{A}}}} \]
      2. pow1/244.2%

        \[\leadsto \sqrt{\color{blue}{{\left(-\frac{F}{A}\right)}^{0.5}} \cdot \sqrt{-\frac{F}{A}}} \]
      3. pow1/244.2%

        \[\leadsto \sqrt{{\left(-\frac{F}{A}\right)}^{0.5} \cdot \color{blue}{{\left(-\frac{F}{A}\right)}^{0.5}}} \]
      4. pow-prod-down38.7%

        \[\leadsto \sqrt{\color{blue}{{\left(\left(-\frac{F}{A}\right) \cdot \left(-\frac{F}{A}\right)\right)}^{0.5}}} \]
      5. pow238.7%

        \[\leadsto \sqrt{{\color{blue}{\left({\left(-\frac{F}{A}\right)}^{2}\right)}}^{0.5}} \]
      6. distribute-neg-frac238.7%

        \[\leadsto \sqrt{{\left({\color{blue}{\left(\frac{F}{-A}\right)}}^{2}\right)}^{0.5}} \]
    10. Applied egg-rr38.7%

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

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

        \[\leadsto \sqrt{\sqrt{\color{blue}{\frac{F}{-A} \cdot \frac{F}{-A}}}} \]
      3. rem-sqrt-square44.5%

        \[\leadsto \sqrt{\color{blue}{\left|\frac{F}{-A}\right|}} \]
      4. distribute-frac-neg244.5%

        \[\leadsto \sqrt{\left|\color{blue}{-\frac{F}{A}}\right|} \]
    12. Simplified44.5%

      \[\leadsto \sqrt{\color{blue}{\left|-\frac{F}{A}\right|}} \]

    if 7.50000000000000072e-21 < F

    1. Initial program 12.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 B around inf 21.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq -8.8 \cdot 10^{+93}:\\ \;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(A + \mathsf{hypot}\left(B, A\right)\right)\right)}}{-B}\\ \mathbf{elif}\;F \leq -4 \cdot 10^{-310}:\\ \;\;\;\;\sqrt{\left|\frac{F}{A}\right|}\\ \mathbf{elif}\;F \leq 7.5 \cdot 10^{-21}:\\ \;\;\;\;\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 11: 43.3% accurate, 2.9× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;F \leq 6.3 \cdot 10^{-304}:\\ \;\;\;\;\sqrt{-1 + \left(1 - \frac{F}{A}\right)}\\ \mathbf{elif}\;F \leq 3.9 \cdot 10^{-19}:\\ \;\;\;\;\sqrt{B\_m \cdot F} \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 (<= F 6.3e-304)
   (sqrt (+ -1.0 (- 1.0 (/ F A))))
   (if (<= F 3.9e-19)
     (* (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 (F <= 6.3e-304) {
		tmp = sqrt((-1.0 + (1.0 - (F / A))));
	} else if (F <= 3.9e-19) {
		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 (f <= 6.3d-304) then
        tmp = sqrt(((-1.0d0) + (1.0d0 - (f / a))))
    else if (f <= 3.9d-19) 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 (F <= 6.3e-304) {
		tmp = Math.sqrt((-1.0 + (1.0 - (F / A))));
	} else if (F <= 3.9e-19) {
		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 F <= 6.3e-304:
		tmp = math.sqrt((-1.0 + (1.0 - (F / A))))
	elif F <= 3.9e-19:
		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 (F <= 6.3e-304)
		tmp = sqrt(Float64(-1.0 + Float64(1.0 - Float64(F / A))));
	elseif (F <= 3.9e-19)
		tmp = Float64(sqrt(Float64(B_m * F)) * Float64(Float64(-sqrt(2.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 (F <= 6.3e-304)
		tmp = sqrt((-1.0 + (1.0 - (F / A))));
	elseif (F <= 3.9e-19)
		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[F, 6.3e-304], N[Sqrt[N[(-1.0 + N[(1.0 - N[(F / A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[F, 3.9e-19], 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}\;F \leq 6.3 \cdot 10^{-304}:\\
\;\;\;\;\sqrt{-1 + \left(1 - \frac{F}{A}\right)}\\

\mathbf{elif}\;F \leq 3.9 \cdot 10^{-19}:\\
\;\;\;\;\sqrt{B\_m \cdot F} \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 F < 6.29999999999999984e-304

    1. Initial program 33.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. Simplified51.2%

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

        \[\leadsto \color{blue}{\sqrt{\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)}} \cdot \sqrt{\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)}}} \]
      2. sqrt-unprod42.1%

        \[\leadsto \color{blue}{\sqrt{\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)} \cdot \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. frac-times34.0%

        \[\leadsto \sqrt{\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)} \cdot \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)}}{\left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right) \cdot \left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)}}} \]
    5. Applied egg-rr36.3%

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

      \[\leadsto \sqrt{\color{blue}{-1 \cdot \frac{F}{A}}} \]
    7. Step-by-step derivation
      1. mul-1-neg30.6%

        \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    8. Simplified30.6%

      \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u30.1%

        \[\leadsto \sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-\frac{F}{A}\right)\right)}} \]
      2. expm1-undefine31.0%

        \[\leadsto \sqrt{\color{blue}{e^{\mathsf{log1p}\left(-\frac{F}{A}\right)} - 1}} \]
      3. distribute-neg-frac231.0%

        \[\leadsto \sqrt{e^{\mathsf{log1p}\left(\color{blue}{\frac{F}{-A}}\right)} - 1} \]
    10. Applied egg-rr31.0%

      \[\leadsto \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{F}{-A}\right)} - 1}} \]
    11. Step-by-step derivation
      1. sub-neg31.0%

        \[\leadsto \sqrt{\color{blue}{e^{\mathsf{log1p}\left(\frac{F}{-A}\right)} + \left(-1\right)}} \]
      2. log1p-undefine31.0%

        \[\leadsto \sqrt{e^{\color{blue}{\log \left(1 + \frac{F}{-A}\right)}} + \left(-1\right)} \]
      3. rem-exp-log31.5%

        \[\leadsto \sqrt{\color{blue}{\left(1 + \frac{F}{-A}\right)} + \left(-1\right)} \]
      4. distribute-frac-neg231.5%

        \[\leadsto \sqrt{\left(1 + \color{blue}{\left(-\frac{F}{A}\right)}\right) + \left(-1\right)} \]
      5. unsub-neg31.5%

        \[\leadsto \sqrt{\color{blue}{\left(1 - \frac{F}{A}\right)} + \left(-1\right)} \]
      6. metadata-eval31.5%

        \[\leadsto \sqrt{\left(1 - \frac{F}{A}\right) + \color{blue}{-1}} \]
    12. Simplified31.5%

      \[\leadsto \sqrt{\color{blue}{\left(1 - \frac{F}{A}\right) + -1}} \]

    if 6.29999999999999984e-304 < F < 3.89999999999999995e-19

    1. Initial program 13.1%

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

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

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

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

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

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

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

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

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

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

    if 3.89999999999999995e-19 < F

    1. Initial program 12.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 B around inf 21.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;F \leq 6.3 \cdot 10^{-304}:\\ \;\;\;\;\sqrt{-1 + \left(1 - \frac{F}{A}\right)}\\ \mathbf{elif}\;F \leq 3.9 \cdot 10^{-19}:\\ \;\;\;\;\sqrt{B \cdot F} \cdot \frac{-\sqrt{2}}{B}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{2 \cdot \frac{F}{B}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 36.8% accurate, 3.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;B\_m \leq 2.3 \cdot 10^{-30}:\\ \;\;\;\;\sqrt{\left|\frac{F}{A}\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.3e-30) (sqrt (fabs (/ F A))) (- (sqrt (* 2.0 (/ F B_m))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 2.3e-30) {
		tmp = sqrt(fabs((F / A)));
	} 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 <= 2.3d-30) then
        tmp = sqrt(abs((f / a)))
    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 <= 2.3e-30) {
		tmp = Math.sqrt(Math.abs((F / A)));
	} 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.3e-30:
		tmp = math.sqrt(math.fabs((F / A)))
	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.3e-30)
		tmp = sqrt(abs(Float64(F / A)));
	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.3e-30)
		tmp = sqrt(abs((F / A)));
	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.3e-30], N[Sqrt[N[Abs[N[(F / A), $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.3 \cdot 10^{-30}:\\
\;\;\;\;\sqrt{\left|\frac{F}{A}\right|}\\

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


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

    1. Initial program 15.8%

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

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

        \[\leadsto \color{blue}{\sqrt{\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)}} \cdot \sqrt{\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)}}} \]
      2. sqrt-unprod11.2%

        \[\leadsto \color{blue}{\sqrt{\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)} \cdot \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. frac-times9.1%

        \[\leadsto \sqrt{\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)} \cdot \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)}}{\left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right) \cdot \left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)}}} \]
    5. Applied egg-rr9.6%

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

      \[\leadsto \sqrt{\color{blue}{-1 \cdot \frac{F}{A}}} \]
    7. Step-by-step derivation
      1. mul-1-neg14.4%

        \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    8. Simplified14.4%

      \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt14.4%

        \[\leadsto \sqrt{\color{blue}{\sqrt{-\frac{F}{A}} \cdot \sqrt{-\frac{F}{A}}}} \]
      2. pow1/214.4%

        \[\leadsto \sqrt{\color{blue}{{\left(-\frac{F}{A}\right)}^{0.5}} \cdot \sqrt{-\frac{F}{A}}} \]
      3. pow1/214.4%

        \[\leadsto \sqrt{{\left(-\frac{F}{A}\right)}^{0.5} \cdot \color{blue}{{\left(-\frac{F}{A}\right)}^{0.5}}} \]
      4. pow-prod-down13.3%

        \[\leadsto \sqrt{\color{blue}{{\left(\left(-\frac{F}{A}\right) \cdot \left(-\frac{F}{A}\right)\right)}^{0.5}}} \]
      5. pow213.3%

        \[\leadsto \sqrt{{\color{blue}{\left({\left(-\frac{F}{A}\right)}^{2}\right)}}^{0.5}} \]
      6. distribute-neg-frac213.3%

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

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

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

        \[\leadsto \sqrt{\sqrt{\color{blue}{\frac{F}{-A} \cdot \frac{F}{-A}}}} \]
      3. rem-sqrt-square14.9%

        \[\leadsto \sqrt{\color{blue}{\left|\frac{F}{-A}\right|}} \]
      4. distribute-frac-neg214.9%

        \[\leadsto \sqrt{\left|\color{blue}{-\frac{F}{A}}\right|} \]
    12. Simplified14.9%

      \[\leadsto \sqrt{\color{blue}{\left|-\frac{F}{A}\right|}} \]

    if 2.29999999999999984e-30 < B

    1. Initial program 18.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 B around inf 39.5%

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

        \[\leadsto \color{blue}{-\sqrt{\frac{F}{B}} \cdot \sqrt{2}} \]
      2. *-commutative39.5%

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

      \[\leadsto \color{blue}{-\sqrt{2} \cdot \sqrt{\frac{F}{B}}} \]
    6. Step-by-step derivation
      1. *-commutative39.5%

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

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

        \[\leadsto -{\left(\frac{F}{B}\right)}^{0.5} \cdot \color{blue}{{2}^{0.5}} \]
      4. pow-prod-down39.6%

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

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

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

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

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

Alternative 13: 36.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.9 \cdot 10^{-30}:\\ \;\;\;\;\sqrt{\frac{F}{-A}}\\ \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.9e-30) (sqrt (/ F (- A))) (- (sqrt (* 2.0 (/ F B_m))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 1.9e-30) {
		tmp = sqrt((F / -A));
	} 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.9d-30) then
        tmp = sqrt((f / -a))
    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.9e-30) {
		tmp = Math.sqrt((F / -A));
	} 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.9e-30:
		tmp = math.sqrt((F / -A))
	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.9e-30)
		tmp = sqrt(Float64(F / Float64(-A)));
	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.9e-30)
		tmp = sqrt((F / -A));
	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.9e-30], N[Sqrt[N[(F / (-A)), $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.9 \cdot 10^{-30}:\\
\;\;\;\;\sqrt{\frac{F}{-A}}\\

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


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

    1. Initial program 15.8%

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

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

        \[\leadsto \color{blue}{\sqrt{\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)}} \cdot \sqrt{\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)}}} \]
      2. sqrt-unprod11.2%

        \[\leadsto \color{blue}{\sqrt{\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)} \cdot \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. frac-times9.1%

        \[\leadsto \sqrt{\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)} \cdot \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)}}{\left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right) \cdot \left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)}}} \]
    5. Applied egg-rr9.6%

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

      \[\leadsto \sqrt{\color{blue}{-1 \cdot \frac{F}{A}}} \]
    7. Step-by-step derivation
      1. mul-1-neg14.4%

        \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
    8. Simplified14.4%

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

    if 1.9000000000000002e-30 < B

    1. Initial program 18.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 B around inf 39.5%

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

        \[\leadsto \color{blue}{-\sqrt{\frac{F}{B}} \cdot \sqrt{2}} \]
      2. *-commutative39.5%

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

      \[\leadsto \color{blue}{-\sqrt{2} \cdot \sqrt{\frac{F}{B}}} \]
    6. Step-by-step derivation
      1. *-commutative39.5%

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

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

        \[\leadsto -{\left(\frac{F}{B}\right)}^{0.5} \cdot \color{blue}{{2}^{0.5}} \]
      4. pow-prod-down39.6%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\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)}} \cdot \sqrt{\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)}}} \]
    2. sqrt-unprod8.9%

      \[\leadsto \color{blue}{\sqrt{\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)} \cdot \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. frac-times7.2%

      \[\leadsto \sqrt{\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)} \cdot \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)}}{\left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right) \cdot \left(-\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\right)}}} \]
  5. Applied egg-rr7.6%

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

    \[\leadsto \sqrt{\color{blue}{-1 \cdot \frac{F}{A}}} \]
  7. Step-by-step derivation
    1. mul-1-neg11.6%

      \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
  8. Simplified11.6%

    \[\leadsto \sqrt{\color{blue}{-\frac{F}{A}}} \]
  9. Final simplification11.6%

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

Reproduce

?
herbie shell --seed 2024177 
(FPCore (A B C F)
  :name "ABCF->ab-angle a"
  :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))))