ABCF->ab-angle b

Percentage Accurate: 19.0% → 45.2%
Time: 27.6s
Alternatives: 11
Speedup: 3.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 11 alternatives:

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

Initial Program: 19.0% accurate, 1.0× speedup?

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

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

Alternative 1: 45.2% accurate, 0.3× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} t_0 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\ t_1 := C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\\ t_2 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\ t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\ \mathbf{if}\;t_3 \leq -2 \cdot 10^{-197}:\\ \;\;\;\;\frac{\left(-\sqrt{t_0}\right) \cdot \sqrt{\left(2 \cdot F\right) \cdot t_1}}{t_0}\\ \mathbf{elif}\;t_3 \leq 0:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(-0.5 \cdot \frac{{B_m}^{2} + \left({A}^{2} - {\left(-A\right)}^{2}\right)}{C} + \left(A + A\right)\right)\right)\right)}}{t_0}\\ \mathbf{elif}\;t_3 \leq \infty:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot t_1\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (fma A (* C -4.0) (pow B_m 2.0)))
        (t_1 (+ C (- A (hypot B_m (- A C)))))
        (t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
        (t_3
         (/
          (-
           (sqrt
            (*
             (* 2.0 (* t_2 F))
             (- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0)))))))
          t_2)))
   (if (<= t_3 -2e-197)
     (/ (* (- (sqrt t_0)) (sqrt (* (* 2.0 F) t_1))) t_0)
     (if (<= t_3 0.0)
       (/
        (-
         (sqrt
          (*
           2.0
           (*
            t_0
            (*
             F
             (+
              (* -0.5 (/ (+ (pow B_m 2.0) (- (pow A 2.0) (pow (- A) 2.0))) C))
              (+ A A)))))))
        t_0)
       (if (<= t_3 INFINITY)
         (/ (- (sqrt (* 2.0 (* t_0 (* F t_1))))) t_0)
         (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m)))))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	double t_0 = fma(A, (C * -4.0), pow(B_m, 2.0));
	double t_1 = C + (A - hypot(B_m, (A - C)));
	double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
	double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_2;
	double tmp;
	if (t_3 <= -2e-197) {
		tmp = (-sqrt(t_0) * sqrt(((2.0 * F) * t_1))) / t_0;
	} else if (t_3 <= 0.0) {
		tmp = -sqrt((2.0 * (t_0 * (F * ((-0.5 * ((pow(B_m, 2.0) + (pow(A, 2.0) - pow(-A, 2.0))) / C)) + (A + A)))))) / t_0;
	} else if (t_3 <= ((double) INFINITY)) {
		tmp = -sqrt((2.0 * (t_0 * (F * t_1)))) / t_0;
	} else {
		tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
	}
	return tmp;
}
B_m = abs(B)
function code(A, B_m, C, F)
	t_0 = fma(A, Float64(C * -4.0), (B_m ^ 2.0))
	t_1 = Float64(C + Float64(A - hypot(B_m, Float64(A - C))))
	t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))
	t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2)
	tmp = 0.0
	if (t_3 <= -2e-197)
		tmp = Float64(Float64(Float64(-sqrt(t_0)) * sqrt(Float64(Float64(2.0 * F) * t_1))) / t_0);
	elseif (t_3 <= 0.0)
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(Float64(-0.5 * Float64(Float64((B_m ^ 2.0) + Float64((A ^ 2.0) - (Float64(-A) ^ 2.0))) / C)) + Float64(A + A))))))) / t_0);
	elseif (t_3 <= Inf)
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * t_1))))) / t_0);
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(C + N[(A - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -2e-197], N[(N[((-N[Sqrt[t$95$0], $MachinePrecision]) * N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$3, 0.0], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(N[(-0.5 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[(N[Power[A, 2.0], $MachinePrecision] - N[Power[(-A), 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision] + N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\
t_1 := C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\\
t_2 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq -2 \cdot 10^{-197}:\\
\;\;\;\;\frac{\left(-\sqrt{t_0}\right) \cdot \sqrt{\left(2 \cdot F\right) \cdot t_1}}{t_0}\\

\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(-0.5 \cdot \frac{{B_m}^{2} + \left({A}^{2} - {\left(-A\right)}^{2}\right)}{C} + \left(A + A\right)\right)\right)\right)}}{t_0}\\

\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot t_1\right)\right)}}{t_0}\\

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


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 2: 43.3% accurate, 0.3× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} t_0 := F \cdot \left(C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\\ t_1 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\ t_2 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\ t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\ \mathbf{if}\;t_3 \leq 0:\\ \;\;\;\;\frac{\sqrt{t_0} \cdot \left(-\sqrt{2 \cdot t_1}\right)}{t_1}\\ \mathbf{elif}\;t_3 \leq \infty:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot t_0\right)}}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (* F (+ C (- A (hypot B_m (- A C))))))
        (t_1 (fma A (* C -4.0) (pow B_m 2.0)))
        (t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
        (t_3
         (/
          (-
           (sqrt
            (*
             (* 2.0 (* t_2 F))
             (- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0)))))))
          t_2)))
   (if (<= t_3 0.0)
     (/ (* (sqrt t_0) (- (sqrt (* 2.0 t_1)))) t_1)
     (if (<= t_3 INFINITY)
       (/ (- (sqrt (* 2.0 (* t_1 t_0)))) t_1)
       (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m))))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	double t_0 = F * (C + (A - hypot(B_m, (A - C))));
	double t_1 = fma(A, (C * -4.0), pow(B_m, 2.0));
	double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
	double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_2;
	double tmp;
	if (t_3 <= 0.0) {
		tmp = (sqrt(t_0) * -sqrt((2.0 * t_1))) / t_1;
	} else if (t_3 <= ((double) INFINITY)) {
		tmp = -sqrt((2.0 * (t_1 * t_0))) / t_1;
	} else {
		tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
	}
	return tmp;
}
B_m = abs(B)
function code(A, B_m, C, F)
	t_0 = Float64(F * Float64(C + Float64(A - hypot(B_m, Float64(A - C)))))
	t_1 = fma(A, Float64(C * -4.0), (B_m ^ 2.0))
	t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))
	t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2)
	tmp = 0.0
	if (t_3 <= 0.0)
		tmp = Float64(Float64(sqrt(t_0) * Float64(-sqrt(Float64(2.0 * t_1)))) / t_1);
	elseif (t_3 <= Inf)
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * t_0)))) / t_1);
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(F * N[(C + N[(A - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, 0.0], N[(N[(N[Sqrt[t$95$0], $MachinePrecision] * (-N[Sqrt[N[(2.0 * t$95$1), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
B_m = \left|B\right|

\\
\begin{array}{l}
t_0 := F \cdot \left(C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\\
t_1 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\
t_2 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq 0:\\
\;\;\;\;\frac{\sqrt{t_0} \cdot \left(-\sqrt{2 \cdot t_1}\right)}{t_1}\\

\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot t_0\right)}}{t_1}\\

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


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 3: 43.4% accurate, 0.3× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} t_0 := C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\\ t_1 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\ t_2 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\ t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\ \mathbf{if}\;t_3 \leq 0:\\ \;\;\;\;\frac{\sqrt{\left(2 \cdot F\right) \cdot t_0} \cdot \left(-\sqrt{t_1}\right)}{t_1}\\ \mathbf{elif}\;t_3 \leq \infty:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot t_0\right)\right)}}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (+ C (- A (hypot B_m (- A C)))))
        (t_1 (fma A (* C -4.0) (pow B_m 2.0)))
        (t_2 (- (pow B_m 2.0) (* (* 4.0 A) C)))
        (t_3
         (/
          (-
           (sqrt
            (*
             (* 2.0 (* t_2 F))
             (- (+ A C) (sqrt (+ (pow B_m 2.0) (pow (- A C) 2.0)))))))
          t_2)))
   (if (<= t_3 0.0)
     (/ (* (sqrt (* (* 2.0 F) t_0)) (- (sqrt t_1))) t_1)
     (if (<= t_3 INFINITY)
       (/ (- (sqrt (* 2.0 (* t_1 (* F t_0))))) t_1)
       (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m))))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	double t_0 = C + (A - hypot(B_m, (A - C)));
	double t_1 = fma(A, (C * -4.0), pow(B_m, 2.0));
	double t_2 = pow(B_m, 2.0) - ((4.0 * A) * C);
	double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((pow(B_m, 2.0) + pow((A - C), 2.0)))))) / t_2;
	double tmp;
	if (t_3 <= 0.0) {
		tmp = (sqrt(((2.0 * F) * t_0)) * -sqrt(t_1)) / t_1;
	} else if (t_3 <= ((double) INFINITY)) {
		tmp = -sqrt((2.0 * (t_1 * (F * t_0)))) / t_1;
	} else {
		tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
	}
	return tmp;
}
B_m = abs(B)
function code(A, B_m, C, F)
	t_0 = Float64(C + Float64(A - hypot(B_m, Float64(A - C))))
	t_1 = fma(A, Float64(C * -4.0), (B_m ^ 2.0))
	t_2 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))
	t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64((B_m ^ 2.0) + (Float64(A - C) ^ 2.0))))))) / t_2)
	tmp = 0.0
	if (t_3 <= 0.0)
		tmp = Float64(Float64(sqrt(Float64(Float64(2.0 * F) * t_0)) * Float64(-sqrt(t_1))) / t_1);
	elseif (t_3 <= Inf)
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_1 * Float64(F * t_0))))) / t_1);
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(C + N[(A - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[B$95$m, 2.0], $MachinePrecision] + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, 0.0], N[(N[(N[Sqrt[N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[t$95$1], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[((-N[Sqrt[N[(2.0 * N[(t$95$1 * N[(F * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
B_m = \left|B\right|

\\
\begin{array}{l}
t_0 := C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\\
t_1 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\
t_2 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B_m}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_2}\\
\mathbf{if}\;t_3 \leq 0:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot F\right) \cdot t_0} \cdot \left(-\sqrt{t_1}\right)}{t_1}\\

\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_1 \cdot \left(F \cdot t_0\right)\right)}}{t_1}\\

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


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 4: 38.5% accurate, 0.9× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} t_0 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\ \mathbf{if}\;{B_m}^{2} \leq 10^{+149}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (fma A (* C -4.0) (pow B_m 2.0))))
   (if (<= (pow B_m 2.0) 1e+149)
     (/ (- (sqrt (* 2.0 (* t_0 (* F (+ C (- A (hypot B_m (- A C))))))))) t_0)
     (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m)))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	double t_0 = fma(A, (C * -4.0), pow(B_m, 2.0));
	double tmp;
	if (pow(B_m, 2.0) <= 1e+149) {
		tmp = -sqrt((2.0 * (t_0 * (F * (C + (A - hypot(B_m, (A - C)))))))) / t_0;
	} else {
		tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
	}
	return tmp;
}
B_m = abs(B)
function code(A, B_m, C, F)
	t_0 = fma(A, Float64(C * -4.0), (B_m ^ 2.0))
	tmp = 0.0
	if ((B_m ^ 2.0) <= 1e+149)
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(t_0 * Float64(F * Float64(C + Float64(A - hypot(B_m, Float64(A - C))))))))) / t_0);
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+149], N[((-N[Sqrt[N[(2.0 * N[(t$95$0 * N[(F * N[(C + N[(A - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)\\
\mathbf{if}\;{B_m}^{2} \leq 10^{+149}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(t_0 \cdot \left(F \cdot \left(C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)\right)}}{t_0}\\

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


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 5: 38.5% accurate, 1.2× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} t_0 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\ \mathbf{if}\;{B_m}^{2} \leq 10^{+147}:\\ \;\;\;\;\frac{-\sqrt{\left(F \cdot t_0\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (fma B_m B_m (* A (* C -4.0)))))
   (if (<= (pow B_m 2.0) 1e+147)
     (/ (- (sqrt (* (* F t_0) (* 2.0 (+ A (- C (hypot B_m (- A C)))))))) t_0)
     (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m)))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	double t_0 = fma(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (pow(B_m, 2.0) <= 1e+147) {
		tmp = -sqrt(((F * t_0) * (2.0 * (A + (C - hypot(B_m, (A - C))))))) / t_0;
	} else {
		tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
	}
	return tmp;
}
B_m = abs(B)
function code(A, B_m, C, F)
	t_0 = fma(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if ((B_m ^ 2.0) <= 1e+147)
		tmp = Float64(Float64(-sqrt(Float64(Float64(F * t_0) * Float64(2.0 * Float64(A + Float64(C - hypot(B_m, Float64(A - C)))))))) / t_0);
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(B$95$m * B$95$m + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e+147], N[((-N[Sqrt[N[(N[(F * t$95$0), $MachinePrecision] * N[(2.0 * N[(A + N[(C - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\
\mathbf{if}\;{B_m}^{2} \leq 10^{+147}:\\
\;\;\;\;\frac{-\sqrt{\left(F \cdot t_0\right) \cdot \left(2 \cdot \left(A + \left(C - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)}}{t_0}\\

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


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 6: 32.9% accurate, 1.5× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} \mathbf{if}\;B_m \leq 6.2 \cdot 10^{-7}:\\ \;\;\;\;\frac{0.25}{A \cdot C} \cdot \sqrt{2 \cdot \left(\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right) \cdot \left(F \cdot \left(C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (if (<= B_m 6.2e-7)
   (*
    (/ 0.25 (* A C))
    (sqrt
     (*
      2.0
      (*
       (fma A (* C -4.0) (pow B_m 2.0))
       (* F (+ C (- A (hypot B_m (- A C)))))))))
   (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 6.2e-7) {
		tmp = (0.25 / (A * C)) * sqrt((2.0 * (fma(A, (C * -4.0), pow(B_m, 2.0)) * (F * (C + (A - hypot(B_m, (A - C))))))));
	} else {
		tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
	}
	return tmp;
}
B_m = abs(B)
function code(A, B_m, C, F)
	tmp = 0.0
	if (B_m <= 6.2e-7)
		tmp = Float64(Float64(0.25 / Float64(A * C)) * sqrt(Float64(2.0 * Float64(fma(A, Float64(C * -4.0), (B_m ^ 2.0)) * Float64(F * Float64(C + Float64(A - hypot(B_m, Float64(A - C)))))))));
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 6.2e-7], N[(N[(0.25 / N[(A * C), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] * N[(F * N[(C + N[(A - N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|

\\
\begin{array}{l}
\mathbf{if}\;B_m \leq 6.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{A \cdot C} \cdot \sqrt{2 \cdot \left(\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right) \cdot \left(F \cdot \left(C + \left(A - \mathsf{hypot}\left(B_m, A - C\right)\right)\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 7: 32.3% accurate, 2.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} \mathbf{if}\;B_m \leq 6.2 \cdot 10^{-7}:\\ \;\;\;\;\sqrt{2 \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)\right)} \cdot \frac{1}{-\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (if (<= B_m 6.2e-7)
   (*
    (sqrt (* 2.0 (* -4.0 (* A (* C (* F (+ A A)))))))
    (/ 1.0 (- (fma A (* C -4.0) (pow B_m 2.0)))))
   (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 6.2e-7) {
		tmp = sqrt((2.0 * (-4.0 * (A * (C * (F * (A + A))))))) * (1.0 / -fma(A, (C * -4.0), pow(B_m, 2.0)));
	} else {
		tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
	}
	return tmp;
}
B_m = abs(B)
function code(A, B_m, C, F)
	tmp = 0.0
	if (B_m <= 6.2e-7)
		tmp = Float64(sqrt(Float64(2.0 * Float64(-4.0 * Float64(A * Float64(C * Float64(F * Float64(A + A))))))) * Float64(1.0 / Float64(-fma(A, Float64(C * -4.0), (B_m ^ 2.0)))));
	else
		tmp = Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 6.2e-7], N[(N[Sqrt[N[(2.0 * N[(-4.0 * N[(A * N[(C * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / (-N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|

\\
\begin{array}{l}
\mathbf{if}\;B_m \leq 6.2 \cdot 10^{-7}:\\
\;\;\;\;\sqrt{2 \cdot \left(-4 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)\right)} \cdot \frac{1}{-\mathsf{fma}\left(A, C \cdot -4, {B_m}^{2}\right)}\\

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


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 8: 28.6% accurate, 2.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} t_0 := \frac{-\sqrt{2}}{B_m}\\ \mathbf{if}\;C \leq 9.5 \cdot 10^{+68}:\\ \;\;\;\;t_0 \cdot \sqrt{F \cdot \left(C - B_m\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)}\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (let* ((t_0 (/ (- (sqrt 2.0)) B_m)))
   (if (<= C 9.5e+68)
     (* t_0 (sqrt (* F (- C B_m))))
     (* t_0 (sqrt (* F (* -0.5 (/ (pow B_m 2.0) C))))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	double t_0 = -sqrt(2.0) / B_m;
	double tmp;
	if (C <= 9.5e+68) {
		tmp = t_0 * sqrt((F * (C - B_m)));
	} else {
		tmp = t_0 * sqrt((F * (-0.5 * (pow(B_m, 2.0) / C))));
	}
	return tmp;
}
B_m = abs(B)
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -sqrt(2.0d0) / b_m
    if (c <= 9.5d+68) then
        tmp = t_0 * sqrt((f * (c - b_m)))
    else
        tmp = t_0 * sqrt((f * ((-0.5d0) * ((b_m ** 2.0d0) / c))))
    end if
    code = tmp
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
	double t_0 = -Math.sqrt(2.0) / B_m;
	double tmp;
	if (C <= 9.5e+68) {
		tmp = t_0 * Math.sqrt((F * (C - B_m)));
	} else {
		tmp = t_0 * Math.sqrt((F * (-0.5 * (Math.pow(B_m, 2.0) / C))));
	}
	return tmp;
}
B_m = math.fabs(B)
def code(A, B_m, C, F):
	t_0 = -math.sqrt(2.0) / B_m
	tmp = 0
	if C <= 9.5e+68:
		tmp = t_0 * math.sqrt((F * (C - B_m)))
	else:
		tmp = t_0 * math.sqrt((F * (-0.5 * (math.pow(B_m, 2.0) / C))))
	return tmp
B_m = abs(B)
function code(A, B_m, C, F)
	t_0 = Float64(Float64(-sqrt(2.0)) / B_m)
	tmp = 0.0
	if (C <= 9.5e+68)
		tmp = Float64(t_0 * sqrt(Float64(F * Float64(C - B_m))));
	else
		tmp = Float64(t_0 * sqrt(Float64(F * Float64(-0.5 * Float64((B_m ^ 2.0) / C)))));
	end
	return tmp
end
B_m = abs(B);
function tmp_2 = code(A, B_m, C, F)
	t_0 = -sqrt(2.0) / B_m;
	tmp = 0.0;
	if (C <= 9.5e+68)
		tmp = t_0 * sqrt((F * (C - B_m)));
	else
		tmp = t_0 * sqrt((F * (-0.5 * ((B_m ^ 2.0) / C))));
	end
	tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision]}, If[LessEqual[C, 9.5e+68], N[(t$95$0 * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Sqrt[N[(F * N[(-0.5 * N[(N[Power[B$95$m, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|

\\
\begin{array}{l}
t_0 := \frac{-\sqrt{2}}{B_m}\\
\mathbf{if}\;C \leq 9.5 \cdot 10^{+68}:\\
\;\;\;\;t_0 \cdot \sqrt{F \cdot \left(C - B_m\right)}\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \sqrt{F \cdot \left(-0.5 \cdot \frac{{B_m}^{2}}{C}\right)}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 9: 1.3% accurate, 3.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(B_m + A\right)} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (+ B_m A)))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	return (-sqrt(2.0) / B_m) * sqrt((F * (B_m + A)));
}
B_m = abs(B)
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    code = (-sqrt(2.0d0) / b_m) * sqrt((f * (b_m + a)))
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
	return (-Math.sqrt(2.0) / B_m) * Math.sqrt((F * (B_m + A)));
}
B_m = math.fabs(B)
def code(A, B_m, C, F):
	return (-math.sqrt(2.0) / B_m) * math.sqrt((F * (B_m + A)))
B_m = abs(B)
function code(A, B_m, C, F)
	return Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(B_m + A))))
end
B_m = abs(B);
function tmp = code(A, B_m, C, F)
	tmp = (-sqrt(2.0) / B_m) * sqrt((F * (B_m + A)));
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(B$95$m + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|

\\
\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(B_m + A\right)}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 10: 5.1% accurate, 3.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(2 \cdot C\right)} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (* 2.0 C)))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	return (-sqrt(2.0) / B_m) * sqrt((F * (2.0 * C)));
}
B_m = abs(B)
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    code = (-sqrt(2.0d0) / b_m) * sqrt((f * (2.0d0 * c)))
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
	return (-Math.sqrt(2.0) / B_m) * Math.sqrt((F * (2.0 * C)));
}
B_m = math.fabs(B)
def code(A, B_m, C, F):
	return (-math.sqrt(2.0) / B_m) * math.sqrt((F * (2.0 * C)))
B_m = abs(B)
function code(A, B_m, C, F)
	return Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(2.0 * C))))
end
B_m = abs(B);
function tmp = code(A, B_m, C, F)
	tmp = (-sqrt(2.0) / B_m) * sqrt((F * (2.0 * C)));
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|

\\
\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(2 \cdot C\right)}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 11: 26.4% accurate, 3.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)} \end{array} \]
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
 :precision binary64
 (* (/ (- (sqrt 2.0)) B_m) (sqrt (* F (- C B_m)))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	return (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
}
B_m = abs(B)
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    code = (-sqrt(2.0d0) / b_m) * sqrt((f * (c - b_m)))
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
	return (-Math.sqrt(2.0) / B_m) * Math.sqrt((F * (C - B_m)));
}
B_m = math.fabs(B)
def code(A, B_m, C, F):
	return (-math.sqrt(2.0) / B_m) * math.sqrt((F * (C - B_m)))
B_m = abs(B)
function code(A, B_m, C, F)
	return Float64(Float64(Float64(-sqrt(2.0)) / B_m) * sqrt(Float64(F * Float64(C - B_m))))
end
B_m = abs(B);
function tmp = code(A, B_m, C, F)
	tmp = (-sqrt(2.0) / B_m) * sqrt((F * (C - B_m)));
end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := N[(N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision] * N[Sqrt[N[(F * N[(C - B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|

\\
\frac{-\sqrt{2}}{B_m} \cdot \sqrt{F \cdot \left(C - B_m\right)}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Reproduce

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