ABCF->ab-angle b

Percentage Accurate: 18.0% → 45.8%
Time: 15.4s
Alternatives: 5
Speedup: 5.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 5 alternatives:

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

Initial Program: 18.0% accurate, 1.0× speedup?

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

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

Alternative 1: 45.8% accurate, 2.0× speedup?

\[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ \begin{array}{l} t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\ \mathbf{if}\;B \leq 7.5 \cdot 10^{+27}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\ \end{array} \end{array} \]
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
 :precision binary64
 (let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
   (if (<= B 7.5e+27)
     (/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)
     (* (sqrt (* F (- A (hypot A B)))) (/ (- (sqrt 2.0)) B)))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
	double t_0 = (B * B) - (4.0 * (A * C));
	double tmp;
	if (B <= 7.5e+27) {
		tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
	} else {
		tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
	}
	return tmp;
}
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
	double t_0 = (B * B) - (4.0 * (A * C));
	double tmp;
	if (B <= 7.5e+27) {
		tmp = -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
	} else {
		tmp = Math.sqrt((F * (A - Math.hypot(A, B)))) * (-Math.sqrt(2.0) / B);
	}
	return tmp;
}
B = abs(B)
[A, C] = sort([A, C])
def code(A, B, C, F):
	t_0 = (B * B) - (4.0 * (A * C))
	tmp = 0
	if B <= 7.5e+27:
		tmp = -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0
	else:
		tmp = math.sqrt((F * (A - math.hypot(A, B)))) * (-math.sqrt(2.0) / B)
	return tmp
B = abs(B)
A, C = sort([A, C])
function code(A, B, C, F)
	t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))
	tmp = 0.0
	if (B <= 7.5e+27)
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0);
	else
		tmp = Float64(sqrt(Float64(F * Float64(A - hypot(A, B)))) * Float64(Float64(-sqrt(2.0)) / B));
	end
	return tmp
end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp_2 = code(A, B, C, F)
	t_0 = (B * B) - (4.0 * (A * C));
	tmp = 0.0;
	if (B <= 7.5e+27)
		tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
	else
		tmp = sqrt((F * (A - hypot(A, B)))) * (-sqrt(2.0) / B);
	end
	tmp_2 = tmp;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 7.5e+27], N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
\mathbf{if}\;B \leq 7.5 \cdot 10^{+27}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}\\

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


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

    1. Initial program 17.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. Step-by-step derivation
      1. Simplified17.2%

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

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

      if 7.5000000000000002e27 < B

      1. Initial program 11.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. Step-by-step derivation
        1. Simplified11.6%

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

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

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

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

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

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

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

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

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

      Alternative 2: 35.2% accurate, 2.7× speedup?

      \[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ \begin{array}{l} t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\ t_1 := t_0 \cdot F\\ \mathbf{if}\;C \leq 3.8 \cdot 10^{+15}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}\right)\right)\right)}}{t_0}\\ \end{array} \end{array} \]
      NOTE: B should be positive before calling this function
      NOTE: A and C should be sorted in increasing order before calling this function.
      (FPCore (A B C F)
       :precision binary64
       (let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (* t_0 F)))
         (if (<= C 3.8e+15)
           (/ (- (sqrt (* 2.0 (* t_1 (- A (hypot A B)))))) t_0)
           (/
            (-
             (sqrt
              (*
               2.0
               (* t_1 (+ A (+ A (* -0.5 (/ (+ (* B B) (- (* A A) (* A A))) C))))))))
            t_0))))
      B = abs(B);
      assert(A < C);
      double code(double A, double B, double C, double F) {
      	double t_0 = (B * B) - (4.0 * (A * C));
      	double t_1 = t_0 * F;
      	double tmp;
      	if (C <= 3.8e+15) {
      		tmp = -sqrt((2.0 * (t_1 * (A - hypot(A, B))))) / t_0;
      	} else {
      		tmp = -sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_0;
      	}
      	return tmp;
      }
      
      B = Math.abs(B);
      assert A < C;
      public static double code(double A, double B, double C, double F) {
      	double t_0 = (B * B) - (4.0 * (A * C));
      	double t_1 = t_0 * F;
      	double tmp;
      	if (C <= 3.8e+15) {
      		tmp = -Math.sqrt((2.0 * (t_1 * (A - Math.hypot(A, B))))) / t_0;
      	} else {
      		tmp = -Math.sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_0;
      	}
      	return tmp;
      }
      
      B = abs(B)
      [A, C] = sort([A, C])
      def code(A, B, C, F):
      	t_0 = (B * B) - (4.0 * (A * C))
      	t_1 = t_0 * F
      	tmp = 0
      	if C <= 3.8e+15:
      		tmp = -math.sqrt((2.0 * (t_1 * (A - math.hypot(A, B))))) / t_0
      	else:
      		tmp = -math.sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_0
      	return tmp
      
      B = abs(B)
      A, C = sort([A, C])
      function code(A, B, C, F)
      	t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))
      	t_1 = Float64(t_0 * F)
      	tmp = 0.0
      	if (C <= 3.8e+15)
      		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A - hypot(A, B)))))) / t_0);
      	else
      		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C)))))))) / t_0);
      	end
      	return tmp
      end
      
      B = abs(B)
      A, C = num2cell(sort([A, C])){:}
      function tmp_2 = code(A, B, C, F)
      	t_0 = (B * B) - (4.0 * (A * C));
      	t_1 = t_0 * F;
      	tmp = 0.0;
      	if (C <= 3.8e+15)
      		tmp = -sqrt((2.0 * (t_1 * (A - hypot(A, B))))) / t_0;
      	else
      		tmp = -sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_0;
      	end
      	tmp_2 = tmp;
      end
      
      NOTE: B should be positive before calling this function
      NOTE: A and C should be sorted in increasing order before calling this function.
      code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[C, 3.8e+15], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A - N[Sqrt[A ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + N[(A + N[(-0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]
      
      \begin{array}{l}
      B = |B|\\
      [A, C] = \mathsf{sort}([A, C])\\
      \\
      \begin{array}{l}
      t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
      t_1 := t_0 \cdot F\\
      \mathbf{if}\;C \leq 3.8 \cdot 10^{+15}:\\
      \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A - \mathsf{hypot}\left(A, B\right)\right)\right)}}{t_0}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}\right)\right)\right)}}{t_0}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if C < 3.8e15

        1. Initial program 21.1%

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

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

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

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

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

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

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

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

          if 3.8e15 < C

          1. Initial program 0.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. Step-by-step derivation
            1. Simplified0.9%

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 3: 28.4% accurate, 4.3× speedup?

          \[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ \begin{array}{l} t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\ t_1 := t_0 \cdot F\\ \mathbf{if}\;C \leq -4.8 \cdot 10^{-294}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\ \mathbf{elif}\;C \leq 1.3 \cdot 10^{-15}:\\ \;\;\;\;-\frac{\sqrt{2 \cdot \left(t_1 \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}\right)\right)\right)}}{t_0}\\ \end{array} \end{array} \]
          NOTE: B should be positive before calling this function
          NOTE: A and C should be sorted in increasing order before calling this function.
          (FPCore (A B C F)
           :precision binary64
           (let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (* t_0 F)))
             (if (<= C -4.8e-294)
               (/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0)
               (if (<= C 1.3e-15)
                 (- (/ (sqrt (* 2.0 (* t_1 (- (+ A C) B)))) t_0))
                 (/
                  (-
                   (sqrt
                    (*
                     2.0
                     (*
                      t_1
                      (+ A (+ A (* -0.5 (/ (+ (* B B) (- (* A A) (* A A))) C))))))))
                  t_0)))))
          B = abs(B);
          assert(A < C);
          double code(double A, double B, double C, double F) {
          	double t_0 = (B * B) - (4.0 * (A * C));
          	double t_1 = t_0 * F;
          	double tmp;
          	if (C <= -4.8e-294) {
          		tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
          	} else if (C <= 1.3e-15) {
          		tmp = -(sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0);
          	} else {
          		tmp = -sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_0;
          	}
          	return tmp;
          }
          
          NOTE: B should be positive before calling this function
          NOTE: A and C should be sorted in increasing order before calling this function.
          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
              real(8) :: t_1
              real(8) :: tmp
              t_0 = (b * b) - (4.0d0 * (a * c))
              t_1 = t_0 * f
              if (c <= (-4.8d-294)) then
                  tmp = -sqrt((2.0d0 * (t_1 * (2.0d0 * a)))) / t_0
              else if (c <= 1.3d-15) then
                  tmp = -(sqrt((2.0d0 * (t_1 * ((a + c) - b)))) / t_0)
              else
                  tmp = -sqrt((2.0d0 * (t_1 * (a + (a + ((-0.5d0) * (((b * b) + ((a * a) - (a * a))) / c))))))) / t_0
              end if
              code = tmp
          end function
          
          B = Math.abs(B);
          assert A < C;
          public static double code(double A, double B, double C, double F) {
          	double t_0 = (B * B) - (4.0 * (A * C));
          	double t_1 = t_0 * F;
          	double tmp;
          	if (C <= -4.8e-294) {
          		tmp = -Math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
          	} else if (C <= 1.3e-15) {
          		tmp = -(Math.sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0);
          	} else {
          		tmp = -Math.sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_0;
          	}
          	return tmp;
          }
          
          B = abs(B)
          [A, C] = sort([A, C])
          def code(A, B, C, F):
          	t_0 = (B * B) - (4.0 * (A * C))
          	t_1 = t_0 * F
          	tmp = 0
          	if C <= -4.8e-294:
          		tmp = -math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0
          	elif C <= 1.3e-15:
          		tmp = -(math.sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0)
          	else:
          		tmp = -math.sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_0
          	return tmp
          
          B = abs(B)
          A, C = sort([A, C])
          function code(A, B, C, F)
          	t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))
          	t_1 = Float64(t_0 * F)
          	tmp = 0.0
          	if (C <= -4.8e-294)
          		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A))))) / t_0);
          	elseif (C <= 1.3e-15)
          		tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(t_1 * Float64(Float64(A + C) - B)))) / t_0));
          	else
          		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(A + Float64(A + Float64(-0.5 * Float64(Float64(Float64(B * B) + Float64(Float64(A * A) - Float64(A * A))) / C)))))))) / t_0);
          	end
          	return tmp
          end
          
          B = abs(B)
          A, C = num2cell(sort([A, C])){:}
          function tmp_2 = code(A, B, C, F)
          	t_0 = (B * B) - (4.0 * (A * C));
          	t_1 = t_0 * F;
          	tmp = 0.0;
          	if (C <= -4.8e-294)
          		tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
          	elseif (C <= 1.3e-15)
          		tmp = -(sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0);
          	else
          		tmp = -sqrt((2.0 * (t_1 * (A + (A + (-0.5 * (((B * B) + ((A * A) - (A * A))) / C))))))) / t_0;
          	end
          	tmp_2 = tmp;
          end
          
          NOTE: B should be positive before calling this function
          NOTE: A and C should be sorted in increasing order before calling this function.
          code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[C, -4.8e-294], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[C, 1.3e-15], (-N[(N[Sqrt[N[(2.0 * N[(t$95$1 * N[(N[(A + C), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(A + N[(A + N[(-0.5 * N[(N[(N[(B * B), $MachinePrecision] + N[(N[(A * A), $MachinePrecision] - N[(A * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]]
          
          \begin{array}{l}
          B = |B|\\
          [A, C] = \mathsf{sort}([A, C])\\
          \\
          \begin{array}{l}
          t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
          t_1 := t_0 \cdot F\\
          \mathbf{if}\;C \leq -4.8 \cdot 10^{-294}:\\
          \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
          
          \mathbf{elif}\;C \leq 1.3 \cdot 10^{-15}:\\
          \;\;\;\;-\frac{\sqrt{2 \cdot \left(t_1 \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}\right)\right)\right)}}{t_0}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if C < -4.79999999999999994e-294

            1. Initial program 20.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. Step-by-step derivation
              1. Simplified20.2%

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

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

              if -4.79999999999999994e-294 < C < 1.30000000000000002e-15

              1. Initial program 23.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. Step-by-step derivation
                1. Simplified23.4%

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

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

                if 1.30000000000000002e-15 < C

                1. Initial program 3.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. Step-by-step derivation
                  1. Simplified3.6%

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \begin{array}{l} \mathbf{if}\;C \leq -4.8 \cdot 10^{-294}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\ \mathbf{elif}\;C \leq 1.3 \cdot 10^{-15}:\\ \;\;\;\;-\frac{\sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \left(\left(A + C\right) - B\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \left(A + \left(A + -0.5 \cdot \frac{B \cdot B + \left(A \cdot A - A \cdot A\right)}{C}\right)\right)\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)}\\ \end{array} \]

                Alternative 4: 28.0% accurate, 4.8× speedup?

                \[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ \begin{array}{l} t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\ t_1 := t_0 \cdot F\\ \mathbf{if}\;B \leq 1.4 \cdot 10^{+28}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;-\frac{\sqrt{2 \cdot \left(t_1 \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\ \end{array} \end{array} \]
                NOTE: B should be positive before calling this function
                NOTE: A and C should be sorted in increasing order before calling this function.
                (FPCore (A B C F)
                 :precision binary64
                 (let* ((t_0 (- (* B B) (* 4.0 (* A C)))) (t_1 (* t_0 F)))
                   (if (<= B 1.4e+28)
                     (/ (- (sqrt (* 2.0 (* t_1 (* 2.0 A))))) t_0)
                     (- (/ (sqrt (* 2.0 (* t_1 (- (+ A C) B)))) t_0)))))
                B = abs(B);
                assert(A < C);
                double code(double A, double B, double C, double F) {
                	double t_0 = (B * B) - (4.0 * (A * C));
                	double t_1 = t_0 * F;
                	double tmp;
                	if (B <= 1.4e+28) {
                		tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
                	} else {
                		tmp = -(sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0);
                	}
                	return tmp;
                }
                
                NOTE: B should be positive before calling this function
                NOTE: A and C should be sorted in increasing order before calling this function.
                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
                    real(8) :: t_1
                    real(8) :: tmp
                    t_0 = (b * b) - (4.0d0 * (a * c))
                    t_1 = t_0 * f
                    if (b <= 1.4d+28) then
                        tmp = -sqrt((2.0d0 * (t_1 * (2.0d0 * a)))) / t_0
                    else
                        tmp = -(sqrt((2.0d0 * (t_1 * ((a + c) - b)))) / t_0)
                    end if
                    code = tmp
                end function
                
                B = Math.abs(B);
                assert A < C;
                public static double code(double A, double B, double C, double F) {
                	double t_0 = (B * B) - (4.0 * (A * C));
                	double t_1 = t_0 * F;
                	double tmp;
                	if (B <= 1.4e+28) {
                		tmp = -Math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
                	} else {
                		tmp = -(Math.sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0);
                	}
                	return tmp;
                }
                
                B = abs(B)
                [A, C] = sort([A, C])
                def code(A, B, C, F):
                	t_0 = (B * B) - (4.0 * (A * C))
                	t_1 = t_0 * F
                	tmp = 0
                	if B <= 1.4e+28:
                		tmp = -math.sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0
                	else:
                		tmp = -(math.sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0)
                	return tmp
                
                B = abs(B)
                A, C = sort([A, C])
                function code(A, B, C, F)
                	t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))
                	t_1 = Float64(t_0 * F)
                	tmp = 0.0
                	if (B <= 1.4e+28)
                		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(2.0 * A))))) / t_0);
                	else
                		tmp = Float64(-Float64(sqrt(Float64(2.0 * Float64(t_1 * Float64(Float64(A + C) - B)))) / t_0));
                	end
                	return tmp
                end
                
                B = abs(B)
                A, C = num2cell(sort([A, C])){:}
                function tmp_2 = code(A, B, C, F)
                	t_0 = (B * B) - (4.0 * (A * C));
                	t_1 = t_0 * F;
                	tmp = 0.0;
                	if (B <= 1.4e+28)
                		tmp = -sqrt((2.0 * (t_1 * (2.0 * A)))) / t_0;
                	else
                		tmp = -(sqrt((2.0 * (t_1 * ((A + C) - B)))) / t_0);
                	end
                	tmp_2 = tmp;
                end
                
                NOTE: B should be positive before calling this function
                NOTE: A and C should be sorted in increasing order before calling this function.
                code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * F), $MachinePrecision]}, If[LessEqual[B, 1.4e+28], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], (-N[(N[Sqrt[N[(2.0 * N[(t$95$1 * N[(N[(A + C), $MachinePrecision] - B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision])]]]
                
                \begin{array}{l}
                B = |B|\\
                [A, C] = \mathsf{sort}([A, C])\\
                \\
                \begin{array}{l}
                t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
                t_1 := t_0 \cdot F\\
                \mathbf{if}\;B \leq 1.4 \cdot 10^{+28}:\\
                \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(2 \cdot A\right)\right)}}{t_0}\\
                
                \mathbf{else}:\\
                \;\;\;\;-\frac{\sqrt{2 \cdot \left(t_1 \cdot \left(\left(A + C\right) - B\right)\right)}}{t_0}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if B < 1.4000000000000001e28

                  1. Initial program 17.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. Step-by-step derivation
                    1. Simplified17.2%

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

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

                    if 1.4000000000000001e28 < B

                    1. Initial program 11.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. Step-by-step derivation
                      1. Simplified11.6%

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

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

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

                    Alternative 5: 26.0% accurate, 5.0× speedup?

                    \[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ \begin{array}{l} t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\ \frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0} \end{array} \end{array} \]
                    NOTE: B should be positive before calling this function
                    NOTE: A and C should be sorted in increasing order before calling this function.
                    (FPCore (A B C F)
                     :precision binary64
                     (let* ((t_0 (- (* B B) (* 4.0 (* A C)))))
                       (/ (- (sqrt (* 2.0 (* (* t_0 F) (* 2.0 A))))) t_0)))
                    B = abs(B);
                    assert(A < C);
                    double code(double A, double B, double C, double F) {
                    	double t_0 = (B * B) - (4.0 * (A * C));
                    	return -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
                    }
                    
                    NOTE: B should be positive before calling this function
                    NOTE: A and C should be sorted in increasing order before calling this function.
                    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 * b) - (4.0d0 * (a * c))
                        code = -sqrt((2.0d0 * ((t_0 * f) * (2.0d0 * a)))) / t_0
                    end function
                    
                    B = Math.abs(B);
                    assert A < C;
                    public static double code(double A, double B, double C, double F) {
                    	double t_0 = (B * B) - (4.0 * (A * C));
                    	return -Math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
                    }
                    
                    B = abs(B)
                    [A, C] = sort([A, C])
                    def code(A, B, C, F):
                    	t_0 = (B * B) - (4.0 * (A * C))
                    	return -math.sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0
                    
                    B = abs(B)
                    A, C = sort([A, C])
                    function code(A, B, C, F)
                    	t_0 = Float64(Float64(B * B) - Float64(4.0 * Float64(A * C)))
                    	return Float64(Float64(-sqrt(Float64(2.0 * Float64(Float64(t_0 * F) * Float64(2.0 * A))))) / t_0)
                    end
                    
                    B = abs(B)
                    A, C = num2cell(sort([A, C])){:}
                    function tmp = code(A, B, C, F)
                    	t_0 = (B * B) - (4.0 * (A * C));
                    	tmp = -sqrt((2.0 * ((t_0 * F) * (2.0 * A)))) / t_0;
                    end
                    
                    NOTE: B should be positive before calling this function
                    NOTE: A and C should be sorted in increasing order before calling this function.
                    code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(2.0 * N[(N[(t$95$0 * F), $MachinePrecision] * N[(2.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
                    
                    \begin{array}{l}
                    B = |B|\\
                    [A, C] = \mathsf{sort}([A, C])\\
                    \\
                    \begin{array}{l}
                    t_0 := B \cdot B - 4 \cdot \left(A \cdot C\right)\\
                    \frac{-\sqrt{2 \cdot \left(\left(t_0 \cdot F\right) \cdot \left(2 \cdot A\right)\right)}}{t_0}
                    \end{array}
                    \end{array}
                    
                    Derivation
                    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. Step-by-step derivation
                      1. Simplified15.8%

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

                        \[\leadsto \frac{-\sqrt{2 \cdot \left(\left(\left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right) \cdot F\right) \cdot \color{blue}{\left(2 \cdot A\right)}\right)}}{B \cdot B - 4 \cdot \left(A \cdot C\right)} \]
                      3. Final simplification15.5%

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

                      Reproduce

                      ?
                      herbie shell --seed 2023238 
                      (FPCore (A B C F)
                        :name "ABCF->ab-angle b"
                        :precision binary64
                        (/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))