ABCF->ab-angle b

Percentage Accurate: 19.8% → 44.4%
Time: 20.6s
Alternatives: 9
Speedup: 12.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 9 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.8% 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: 44.4% accurate, 5.9× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} t_0 := \mathsf{fma}\left(B\_m, B\_m, C \cdot \left(A \cdot -4\right)\right)\\ \mathbf{if}\;B\_m \leq 1.75 \cdot 10^{+26}:\\ \;\;\;\;\frac{-1}{t\_0} \cdot \sqrt{t\_0 \cdot \left(\left(A + A\right) \cdot \left(2 \cdot F\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{-\frac{F}{B\_m}} \cdot \left(-\sqrt{2}\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 (* C (* A -4.0)))))
   (if (<= B_m 1.75e+26)
     (* (/ -1.0 t_0) (sqrt (* t_0 (* (+ A A) (* 2.0 F)))))
     (* (sqrt (- (/ F B_m))) (- (sqrt 2.0))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double t_0 = fma(B_m, B_m, (C * (A * -4.0)));
	double tmp;
	if (B_m <= 1.75e+26) {
		tmp = (-1.0 / t_0) * sqrt((t_0 * ((A + A) * (2.0 * F))));
	} else {
		tmp = sqrt(-(F / B_m)) * -sqrt(2.0);
	}
	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(C * Float64(A * -4.0)))
	tmp = 0.0
	if (B_m <= 1.75e+26)
		tmp = Float64(Float64(-1.0 / t_0) * sqrt(Float64(t_0 * Float64(Float64(A + A) * Float64(2.0 * F)))));
	else
		tmp = Float64(sqrt(Float64(-Float64(F / B_m))) * Float64(-sqrt(2.0)));
	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[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 1.75e+26], N[(N[(-1.0 / t$95$0), $MachinePrecision] * N[Sqrt[N[(t$95$0 * N[(N[(A + A), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[(-N[(F / B$95$m), $MachinePrecision])], $MachinePrecision] * (-N[Sqrt[2.0], $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, C \cdot \left(A \cdot -4\right)\right)\\
\mathbf{if}\;B\_m \leq 1.75 \cdot 10^{+26}:\\
\;\;\;\;\frac{-1}{t\_0} \cdot \sqrt{t\_0 \cdot \left(\left(A + A\right) \cdot \left(2 \cdot F\right)\right)}\\

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


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

    1. Initial program 23.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 inf

      \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \color{blue}{\left(A - -1 \cdot A\right)}}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \color{blue}{\left(A + \left(\mathsf{neg}\left(-1\right)\right) \cdot A\right)}}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
      2. metadata-evalN/A

        \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + \color{blue}{1} \cdot A\right)}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
      3. *-lft-identityN/A

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

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

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}\right)\right)\right)}{\mathsf{neg}\left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right)\right)}} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}\right)\right)}\right)}{\mathsf{neg}\left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right)\right)} \]
      4. remove-double-negN/A

        \[\leadsto \frac{\color{blue}{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}}{\mathsf{neg}\left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right)\right)} \]
      5. lift--.f64N/A

        \[\leadsto \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{\mathsf{neg}\left(\color{blue}{\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right)}\right)} \]
      6. sub-negN/A

        \[\leadsto \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{\mathsf{neg}\left(\color{blue}{\left({B}^{2} + \left(\mathsf{neg}\left(\left(4 \cdot A\right) \cdot C\right)\right)\right)}\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{\mathsf{neg}\left(\left({B}^{2} + \left(\mathsf{neg}\left(\color{blue}{\left(4 \cdot A\right) \cdot C}\right)\right)\right)\right)} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{\mathsf{neg}\left(\left({B}^{2} + \left(\mathsf{neg}\left(\color{blue}{C \cdot \left(4 \cdot A\right)}\right)\right)\right)\right)} \]
      9. distribute-rgt-neg-inN/A

        \[\leadsto \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{\mathsf{neg}\left(\left({B}^{2} + \color{blue}{C \cdot \left(\mathsf{neg}\left(4 \cdot A\right)\right)}\right)\right)} \]
      10. lift-*.f64N/A

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{neg}\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\right)}{\sqrt{2 \cdot \left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \cdot \left(A + A\right)\right)}}}} \]
      3. associate-/r/N/A

        \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\right)} \cdot \sqrt{2 \cdot \left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \cdot \left(A + A\right)\right)}} \]
      4. lower-*.f64N/A

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

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\right)\right)\right)}} \cdot \sqrt{2 \cdot \left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \cdot \left(A + A\right)\right)} \]
      6. metadata-evalN/A

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

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\right)\right)}\right)} \cdot \sqrt{2 \cdot \left(\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right) \cdot \left(A + A\right)\right)} \]
      8. remove-double-negN/A

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

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

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

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

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

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

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

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

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

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

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

    if 1.75e26 < B

    1. Initial program 8.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 F around 0

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

        \[\leadsto \color{blue}{\mathsf{neg}\left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
      2. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \left(\mathsf{neg}\left(\sqrt{2}\right)\right)} \]
      3. lower-*.f64N/A

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

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

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

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

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

    Alternative 2: 43.7% accurate, 1.7× speedup?

    \[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} t_0 := \mathsf{fma}\left(B\_m, B\_m, C \cdot \left(A \cdot -4\right)\right)\\ \mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-210}:\\ \;\;\;\;\frac{\sqrt{\left(A + A\right) \cdot \left(\left(C \cdot A\right) \cdot \left(F \cdot -8\right)\right)}}{\mathsf{fma}\left(B\_m, -B\_m, C \cdot \left(A \cdot 4\right)\right)}\\ \mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+50}:\\ \;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(t\_0 \cdot \left(A + A\right)\right)\right)}}{-t\_0}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{-\frac{F}{B\_m}} \cdot \left(-\sqrt{2}\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 (* C (* A -4.0)))))
       (if (<= (pow B_m 2.0) 5e-210)
         (/
          (sqrt (* (+ A A) (* (* C A) (* F -8.0))))
          (fma B_m (- B_m) (* C (* A 4.0))))
         (if (<= (pow B_m 2.0) 5e+50)
           (/ (sqrt (* 2.0 (* F (* t_0 (+ A A))))) (- t_0))
           (* (sqrt (- (/ F B_m))) (- (sqrt 2.0)))))))
    B_m = fabs(B);
    assert(A < B_m && B_m < C && C < F);
    double code(double A, double B_m, double C, double F) {
    	double t_0 = fma(B_m, B_m, (C * (A * -4.0)));
    	double tmp;
    	if (pow(B_m, 2.0) <= 5e-210) {
    		tmp = sqrt(((A + A) * ((C * A) * (F * -8.0)))) / fma(B_m, -B_m, (C * (A * 4.0)));
    	} else if (pow(B_m, 2.0) <= 5e+50) {
    		tmp = sqrt((2.0 * (F * (t_0 * (A + A))))) / -t_0;
    	} else {
    		tmp = sqrt(-(F / B_m)) * -sqrt(2.0);
    	}
    	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(C * Float64(A * -4.0)))
    	tmp = 0.0
    	if ((B_m ^ 2.0) <= 5e-210)
    		tmp = Float64(sqrt(Float64(Float64(A + A) * Float64(Float64(C * A) * Float64(F * -8.0)))) / fma(B_m, Float64(-B_m), Float64(C * Float64(A * 4.0))));
    	elseif ((B_m ^ 2.0) <= 5e+50)
    		tmp = Float64(sqrt(Float64(2.0 * Float64(F * Float64(t_0 * Float64(A + A))))) / Float64(-t_0));
    	else
    		tmp = Float64(sqrt(Float64(-Float64(F / B_m))) * Float64(-sqrt(2.0)));
    	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[(C * N[(A * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e-210], N[(N[Sqrt[N[(N[(A + A), $MachinePrecision] * N[(N[(C * A), $MachinePrecision] * N[(F * -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(B$95$m * (-B$95$m) + N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+50], N[(N[Sqrt[N[(2.0 * N[(F * N[(t$95$0 * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], N[(N[Sqrt[(-N[(F / B$95$m), $MachinePrecision])], $MachinePrecision] * (-N[Sqrt[2.0], $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, C \cdot \left(A \cdot -4\right)\right)\\
    \mathbf{if}\;{B\_m}^{2} \leq 5 \cdot 10^{-210}:\\
    \;\;\;\;\frac{\sqrt{\left(A + A\right) \cdot \left(\left(C \cdot A\right) \cdot \left(F \cdot -8\right)\right)}}{\mathsf{fma}\left(B\_m, -B\_m, C \cdot \left(A \cdot 4\right)\right)}\\
    
    \mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+50}:\\
    \;\;\;\;\frac{\sqrt{2 \cdot \left(F \cdot \left(t\_0 \cdot \left(A + A\right)\right)\right)}}{-t\_0}\\
    
    \mathbf{else}:\\
    \;\;\;\;\sqrt{-\frac{F}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000002e-210

      1. Initial program 18.5%

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

        \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \color{blue}{\left(A - -1 \cdot A\right)}}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
      4. Step-by-step derivation
        1. cancel-sign-sub-invN/A

          \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \color{blue}{\left(A + \left(\mathsf{neg}\left(-1\right)\right) \cdot A\right)}}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
        2. metadata-evalN/A

          \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + \color{blue}{1} \cdot A\right)}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
        3. *-lft-identityN/A

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\color{blue}{\left(-8 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)} \cdot \left(A + A\right)}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
      7. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\color{blue}{\left(-8 \cdot \left(A \cdot \left(C \cdot F\right)\right)\right)} \cdot \left(A + A\right)}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
        2. lower-*.f64N/A

          \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\left(-8 \cdot \color{blue}{\left(A \cdot \left(C \cdot F\right)\right)}\right) \cdot \left(A + A\right)}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
        3. lower-*.f6437.8

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

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

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

      if 5.0000000000000002e-210 < (pow.f64 B #s(literal 2 binary64)) < 5e50

      1. Initial program 35.8%

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

        \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \color{blue}{\left(A - -1 \cdot A\right)}}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
      4. Step-by-step derivation
        1. cancel-sign-sub-invN/A

          \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \color{blue}{\left(A + \left(\mathsf{neg}\left(-1\right)\right) \cdot A\right)}}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
        2. metadata-evalN/A

          \[\leadsto \frac{\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + \color{blue}{1} \cdot A\right)}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
        3. *-lft-identityN/A

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

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

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

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

          \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}\right)\right)\right)}{\mathsf{neg}\left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right)\right)}} \]
        3. lift-neg.f64N/A

          \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}\right)\right)}\right)}{\mathsf{neg}\left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right)\right)} \]
        4. remove-double-negN/A

          \[\leadsto \frac{\color{blue}{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}}{\mathsf{neg}\left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right)\right)} \]
        5. lift--.f64N/A

          \[\leadsto \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{\mathsf{neg}\left(\color{blue}{\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right)}\right)} \]
        6. sub-negN/A

          \[\leadsto \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{\mathsf{neg}\left(\color{blue}{\left({B}^{2} + \left(\mathsf{neg}\left(\left(4 \cdot A\right) \cdot C\right)\right)\right)}\right)} \]
        7. lift-*.f64N/A

          \[\leadsto \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{\mathsf{neg}\left(\left({B}^{2} + \left(\mathsf{neg}\left(\color{blue}{\left(4 \cdot A\right) \cdot C}\right)\right)\right)\right)} \]
        8. *-commutativeN/A

          \[\leadsto \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{\mathsf{neg}\left(\left({B}^{2} + \left(\mathsf{neg}\left(\color{blue}{C \cdot \left(4 \cdot A\right)}\right)\right)\right)\right)} \]
        9. distribute-rgt-neg-inN/A

          \[\leadsto \frac{\sqrt{\left(2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \left(A + A\right)}}{\mathsf{neg}\left(\left({B}^{2} + \color{blue}{C \cdot \left(\mathsf{neg}\left(4 \cdot A\right)\right)}\right)\right)} \]
        10. lift-*.f64N/A

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

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

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

          \[\leadsto \frac{\sqrt{2 \cdot \color{blue}{\left(\left(A + A\right) \cdot \left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right)\right)}}}{\mathsf{neg}\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\right)} \]
        3. lift-*.f64N/A

          \[\leadsto \frac{\sqrt{2 \cdot \left(\left(A + A\right) \cdot \color{blue}{\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right) \cdot F\right)}\right)}}{\mathsf{neg}\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\right)} \]
        4. associate-*r*N/A

          \[\leadsto \frac{\sqrt{2 \cdot \color{blue}{\left(\left(\left(A + A\right) \cdot \mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\right) \cdot F\right)}}}{\mathsf{neg}\left(\mathsf{fma}\left(B, B, C \cdot \left(A \cdot -4\right)\right)\right)} \]
        5. lower-*.f64N/A

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

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

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

      if 5e50 < (pow.f64 B #s(literal 2 binary64))

      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 F around 0

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

          \[\leadsto \color{blue}{\mathsf{neg}\left(\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \sqrt{2}\right)} \]
        2. distribute-rgt-neg-inN/A

          \[\leadsto \color{blue}{\sqrt{\frac{F \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}{{B}^{2} - 4 \cdot \left(A \cdot C\right)}} \cdot \left(\mathsf{neg}\left(\sqrt{2}\right)\right)} \]
        3. lower-*.f64N/A

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

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

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

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

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

      Reproduce

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