ABCF->ab-angle a

Percentage Accurate: 19.1% → 46.4%
Time: 18.4s
Alternatives: 9
Speedup: 2.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.1% 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: 46.4% accurate, 0.3× speedup?

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

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

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

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;t_3\\

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


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

Alternative 2: 35.5% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;{B_m}^{2} \leq 10^{-34}:\\
\;\;\;\;\frac{-\sqrt{t_2 \cdot t_3}}{t_0}\\

\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{+292}:\\
\;\;\;\;\sqrt{F \cdot \left(C + \mathsf{hypot}\left(B_m, C\right)\right)} \cdot t_1\\

\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot t_3} \cdot t_1\\


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

Alternative 3: 35.3% accurate, 1.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} t_0 := \frac{-\sqrt{2}}{B_m}\\ t_1 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\ t_2 := \mathsf{fma}\left(B_m, B_m, A \cdot \left(C \cdot -4\right)\right)\\ \mathbf{if}\;{B_m}^{2} \leq 2 \cdot 10^{-294}:\\ \;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(t_1 \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t_1}\\ \mathbf{elif}\;{B_m}^{2} \leq 10^{-112}:\\ \;\;\;\;-\frac{\sqrt{\left(t_2 \cdot \left(2 \cdot F\right)\right) \cdot \left(A + A\right)}}{t_2}\\ \mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{+292}:\\ \;\;\;\;\sqrt{F \cdot \left(C + \mathsf{hypot}\left(B_m, C\right)\right)} \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A + \mathsf{hypot}\left(B_m, A\right)\right)} \cdot t_0\\ \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))
        (t_1 (- (pow B_m 2.0) (* (* 4.0 A) C)))
        (t_2 (fma B_m B_m (* A (* C -4.0)))))
   (if (<= (pow B_m 2.0) 2e-294)
     (/ (- (sqrt (* (* 2.0 (* t_1 F)) (* 2.0 C)))) t_1)
     (if (<= (pow B_m 2.0) 1e-112)
       (- (/ (sqrt (* (* t_2 (* 2.0 F)) (+ A A))) t_2))
       (if (<= (pow B_m 2.0) 5e+292)
         (* (sqrt (* F (+ C (hypot B_m C)))) t_0)
         (* (sqrt (* F (+ A (hypot B_m A)))) t_0))))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
	double t_0 = -sqrt(2.0) / B_m;
	double t_1 = pow(B_m, 2.0) - ((4.0 * A) * C);
	double t_2 = fma(B_m, B_m, (A * (C * -4.0)));
	double tmp;
	if (pow(B_m, 2.0) <= 2e-294) {
		tmp = -sqrt(((2.0 * (t_1 * F)) * (2.0 * C))) / t_1;
	} else if (pow(B_m, 2.0) <= 1e-112) {
		tmp = -(sqrt(((t_2 * (2.0 * F)) * (A + A))) / t_2);
	} else if (pow(B_m, 2.0) <= 5e+292) {
		tmp = sqrt((F * (C + hypot(B_m, C)))) * t_0;
	} else {
		tmp = sqrt((F * (A + hypot(B_m, A)))) * t_0;
	}
	return tmp;
}
B_m = abs(B)
function code(A, B_m, C, F)
	t_0 = Float64(Float64(-sqrt(2.0)) / B_m)
	t_1 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))
	t_2 = fma(B_m, B_m, Float64(A * Float64(C * -4.0)))
	tmp = 0.0
	if ((B_m ^ 2.0) <= 2e-294)
		tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_1 * F)) * Float64(2.0 * C)))) / t_1);
	elseif ((B_m ^ 2.0) <= 1e-112)
		tmp = Float64(-Float64(sqrt(Float64(Float64(t_2 * Float64(2.0 * F)) * Float64(A + A))) / t_2));
	elseif ((B_m ^ 2.0) <= 5e+292)
		tmp = Float64(sqrt(Float64(F * Float64(C + hypot(B_m, C)))) * t_0);
	else
		tmp = Float64(sqrt(Float64(F * Float64(A + hypot(B_m, A)))) * t_0);
	end
	return 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]}, Block[{t$95$1 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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], 2e-294], N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$1 * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-112], (-N[(N[Sqrt[N[(N[(t$95$2 * N[(2.0 * F), $MachinePrecision]), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision]), If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+292], N[(N[Sqrt[N[(F * N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A + N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
B_m = \left|B\right|

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

\mathbf{elif}\;{B_m}^{2} \leq 10^{-112}:\\
\;\;\;\;-\frac{\sqrt{\left(t_2 \cdot \left(2 \cdot F\right)\right) \cdot \left(A + A\right)}}{t_2}\\

\mathbf{elif}\;{B_m}^{2} \leq 5 \cdot 10^{+292}:\\
\;\;\;\;\sqrt{F \cdot \left(C + \mathsf{hypot}\left(B_m, C\right)\right)} \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A + \mathsf{hypot}\left(B_m, A\right)\right)} \cdot t_0\\


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

Alternative 4: 36.6% accurate, 1.5× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} t_0 := \mathsf{fma}\left(B_m, B_m, -4 \cdot \left(A \cdot C\right)\right)\\ t_1 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\ \mathbf{if}\;B_m \leq 6.8 \cdot 10^{-143}:\\ \;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(t_1 \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t_1}\\ \mathbf{elif}\;B_m \leq 1.15 \cdot 10^{-16}:\\ \;\;\;\;\frac{-\sqrt{\left(\left(\left(A + C\right) + \mathsf{hypot}\left(A - C, B_m\right)\right) \cdot t_0\right) \cdot \left(2 \cdot F\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A + \mathsf{hypot}\left(B_m, A\right)\right)} \cdot \frac{-\sqrt{2}}{B_m}\\ \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 (* -4.0 (* A C))))
        (t_1 (- (pow B_m 2.0) (* (* 4.0 A) C))))
   (if (<= B_m 6.8e-143)
     (/ (- (sqrt (* (* 2.0 (* t_1 F)) (* 2.0 C)))) t_1)
     (if (<= B_m 1.15e-16)
       (/ (- (sqrt (* (* (+ (+ A C) (hypot (- A C) B_m)) t_0) (* 2.0 F)))) t_0)
       (* (sqrt (* F (+ A (hypot B_m A)))) (/ (- (sqrt 2.0)) 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, (-4.0 * (A * C)));
	double t_1 = pow(B_m, 2.0) - ((4.0 * A) * C);
	double tmp;
	if (B_m <= 6.8e-143) {
		tmp = -sqrt(((2.0 * (t_1 * F)) * (2.0 * C))) / t_1;
	} else if (B_m <= 1.15e-16) {
		tmp = -sqrt(((((A + C) + hypot((A - C), B_m)) * t_0) * (2.0 * F))) / t_0;
	} else {
		tmp = sqrt((F * (A + hypot(B_m, A)))) * (-sqrt(2.0) / B_m);
	}
	return tmp;
}
B_m = abs(B)
function code(A, B_m, C, F)
	t_0 = fma(B_m, B_m, Float64(-4.0 * Float64(A * C)))
	t_1 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))
	tmp = 0.0
	if (B_m <= 6.8e-143)
		tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_1 * F)) * Float64(2.0 * C)))) / t_1);
	elseif (B_m <= 1.15e-16)
		tmp = Float64(Float64(-sqrt(Float64(Float64(Float64(Float64(A + C) + hypot(Float64(A - C), B_m)) * t_0) * Float64(2.0 * F)))) / t_0);
	else
		tmp = Float64(sqrt(Float64(F * Float64(A + hypot(B_m, A)))) * Float64(Float64(-sqrt(2.0)) / 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[(-4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 6.8e-143], N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$1 * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B$95$m, 1.15e-16], N[((-N[Sqrt[N[(N[(N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(2.0 * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A + N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|

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

\mathbf{elif}\;B_m \leq 1.15 \cdot 10^{-16}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(\left(A + C\right) + \mathsf{hypot}\left(A - C, B_m\right)\right) \cdot t_0\right) \cdot \left(2 \cdot F\right)}}{t_0}\\

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


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

Alternative 5: 38.4% accurate, 1.5× 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)\\ t_1 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\ \mathbf{if}\;B_m \leq 1.55 \cdot 10^{-143}:\\ \;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(t_1 \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t_1}\\ \mathbf{elif}\;B_m \leq 6.8 \cdot 10^{+14}:\\ \;\;\;\;\frac{-\sqrt{\left(t_0 \cdot \left(2 \cdot F\right)\right) \cdot \left(A + \left(C + \mathsf{hypot}\left(B_m, A - C\right)\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A + \mathsf{hypot}\left(B_m, A\right)\right)} \cdot \frac{-\sqrt{2}}{B_m}\\ \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))))
        (t_1 (- (pow B_m 2.0) (* (* 4.0 A) C))))
   (if (<= B_m 1.55e-143)
     (/ (- (sqrt (* (* 2.0 (* t_1 F)) (* 2.0 C)))) t_1)
     (if (<= B_m 6.8e+14)
       (/ (- (sqrt (* (* t_0 (* 2.0 F)) (+ A (+ C (hypot B_m (- A C))))))) t_0)
       (* (sqrt (* F (+ A (hypot B_m A)))) (/ (- (sqrt 2.0)) 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 t_1 = pow(B_m, 2.0) - ((4.0 * A) * C);
	double tmp;
	if (B_m <= 1.55e-143) {
		tmp = -sqrt(((2.0 * (t_1 * F)) * (2.0 * C))) / t_1;
	} else if (B_m <= 6.8e+14) {
		tmp = -sqrt(((t_0 * (2.0 * F)) * (A + (C + hypot(B_m, (A - C)))))) / t_0;
	} else {
		tmp = sqrt((F * (A + hypot(B_m, A)))) * (-sqrt(2.0) / 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)))
	t_1 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C))
	tmp = 0.0
	if (B_m <= 1.55e-143)
		tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_1 * F)) * Float64(2.0 * C)))) / t_1);
	elseif (B_m <= 6.8e+14)
		tmp = Float64(Float64(-sqrt(Float64(Float64(t_0 * Float64(2.0 * F)) * Float64(A + Float64(C + hypot(B_m, Float64(A - C))))))) / t_0);
	else
		tmp = Float64(sqrt(Float64(F * Float64(A + hypot(B_m, A)))) * Float64(Float64(-sqrt(2.0)) / 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]}, Block[{t$95$1 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 1.55e-143], N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$1 * F), $MachinePrecision]), $MachinePrecision] * N[(2.0 * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision], If[LessEqual[B$95$m, 6.8e+14], N[((-N[Sqrt[N[(N[(t$95$0 * N[(2.0 * F), $MachinePrecision]), $MachinePrecision] * N[(A + N[(C + N[Sqrt[B$95$m ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A + N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $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)\\
t_1 := {B_m}^{2} - \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;B_m \leq 1.55 \cdot 10^{-143}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(t_1 \cdot F\right)\right) \cdot \left(2 \cdot C\right)}}{t_1}\\

\mathbf{elif}\;B_m \leq 6.8 \cdot 10^{+14}:\\
\;\;\;\;\frac{-\sqrt{\left(t_0 \cdot \left(2 \cdot F\right)\right) \cdot \left(A + \left(C + \mathsf{hypot}\left(B_m, A - C\right)\right)\right)}}{t_0}\\

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


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

Alternative 6: 33.9% accurate, 1.5× speedup?

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

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

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


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

Alternative 7: 31.1% accurate, 2.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ \begin{array}{l} t_0 := \frac{-\sqrt{2}}{B_m}\\ \mathbf{if}\;A \leq 10^{-127}:\\ \;\;\;\;\sqrt{F \cdot \left(C + \mathsf{hypot}\left(B_m, C\right)\right)} \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A + \mathsf{hypot}\left(B_m, A\right)\right)} \cdot t_0\\ \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 (<= A 1e-127)
     (* (sqrt (* F (+ C (hypot B_m C)))) t_0)
     (* (sqrt (* F (+ A (hypot B_m A)))) t_0))))
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 (A <= 1e-127) {
		tmp = sqrt((F * (C + hypot(B_m, C)))) * t_0;
	} else {
		tmp = sqrt((F * (A + hypot(B_m, A)))) * t_0;
	}
	return tmp;
}
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 (A <= 1e-127) {
		tmp = Math.sqrt((F * (C + Math.hypot(B_m, C)))) * t_0;
	} else {
		tmp = Math.sqrt((F * (A + Math.hypot(B_m, A)))) * t_0;
	}
	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 A <= 1e-127:
		tmp = math.sqrt((F * (C + math.hypot(B_m, C)))) * t_0
	else:
		tmp = math.sqrt((F * (A + math.hypot(B_m, A)))) * t_0
	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 (A <= 1e-127)
		tmp = Float64(sqrt(Float64(F * Float64(C + hypot(B_m, C)))) * t_0);
	else
		tmp = Float64(sqrt(Float64(F * Float64(A + hypot(B_m, A)))) * t_0);
	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 (A <= 1e-127)
		tmp = sqrt((F * (C + hypot(B_m, C)))) * t_0;
	else
		tmp = sqrt((F * (A + hypot(B_m, A)))) * t_0;
	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[A, 1e-127], N[(N[Sqrt[N[(F * N[(C + N[Sqrt[B$95$m ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A + N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|

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

\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \left(A + \mathsf{hypot}\left(B_m, A\right)\right)} \cdot t_0\\


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

Alternative 8: 29.0% accurate, 2.0× speedup?

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

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

Alternative 9: 0.0% accurate, 2.1× speedup?

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

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

Reproduce

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