ABCF->ab-angle b

Percentage Accurate: 18.8% → 47.0%
Time: 25.8s
Alternatives: 7
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 7 alternatives:

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

Initial Program: 18.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: 47.0% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 B 2) < 4.9999999999999999e-61

    1. Initial program 20.3%

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999999e-61 < (pow.f64 B 2)

    1. Initial program 23.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 41.4% accurate, 1.0× speedup?

\[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-56} \lor \neg \left({B}^{2} \leq 4 \cdot 10^{+55}\right) \land {B}^{2} \leq 2 \cdot 10^{+116}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(C - \mathsf{hypot}\left(B, C\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\ \end{array} \end{array} \]
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
 :precision binary64
 (if (or (<= (pow B 2.0) 2e-56)
         (and (not (<= (pow B 2.0) 4e+55)) (<= (pow B 2.0) 2e+116)))
   (/
    (- (sqrt (* 2.0 (* -4.0 (* (* A C) (* F (+ A A)))))))
    (fma B B (* A (* C -4.0))))
   (* (sqrt (* F (- C (hypot B C)))) (/ (- (sqrt 2.0)) B))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
	double tmp;
	if ((pow(B, 2.0) <= 2e-56) || (!(pow(B, 2.0) <= 4e+55) && (pow(B, 2.0) <= 2e+116))) {
		tmp = -sqrt((2.0 * (-4.0 * ((A * C) * (F * (A + A)))))) / fma(B, B, (A * (C * -4.0)));
	} else {
		tmp = sqrt((F * (C - hypot(B, C)))) * (-sqrt(2.0) / B);
	}
	return tmp;
}
B = abs(B)
A, C = sort([A, C])
function code(A, B, C, F)
	tmp = 0.0
	if (((B ^ 2.0) <= 2e-56) || (!((B ^ 2.0) <= 4e+55) && ((B ^ 2.0) <= 2e+116)))
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))))) / fma(B, B, Float64(A * Float64(C * -4.0))));
	else
		tmp = Float64(sqrt(Float64(F * Float64(C - hypot(B, C)))) * Float64(Float64(-sqrt(2.0)) / B));
	end
	return tmp
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := If[Or[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-56], And[N[Not[LessEqual[N[Power[B, 2.0], $MachinePrecision], 4e+55]], $MachinePrecision], LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e+116]]], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(C - N[Sqrt[B ^ 2 + C ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-56} \lor \neg \left({B}^{2} \leq 4 \cdot 10^{+55}\right) \land {B}^{2} \leq 2 \cdot 10^{+116}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 B 2) < 2.0000000000000001e-56 or 4.00000000000000004e55 < (pow.f64 B 2) < 2.00000000000000003e116

    1. Initial program 21.7%

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

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

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

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

        \[\leadsto \frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\color{blue}{\left(C \cdot A\right)} \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      3. cancel-sign-sub-inv26.3%

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

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

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

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

    if 2.0000000000000001e-56 < (pow.f64 B 2) < 4.00000000000000004e55 or 2.00000000000000003e116 < (pow.f64 B 2)

    1. Initial program 22.0%

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

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

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

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

        \[\leadsto -\color{blue}{\sqrt{F \cdot \left(C - \sqrt{{B}^{2} + {C}^{2}}\right)} \cdot \frac{\sqrt{2}}{B}} \]
      3. distribute-rgt-neg-in17.1%

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

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

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

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

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

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

Alternative 3: 46.8% accurate, 1.2× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 B 2) < 1.9999999999999999e-81

    1. Initial program 20.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. Simplified31.1%

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

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

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

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

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

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

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

    if 1.9999999999999999e-81 < (pow.f64 B 2)

    1. Initial program 22.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. Simplified26.6%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 45.5% accurate, 1.5× speedup?

\[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-156}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)} \cdot \frac{-\sqrt{2}}{B}\\ \end{array} \end{array} \]
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
 :precision binary64
 (if (<= (pow B 2.0) 5e-156)
   (/
    (- (sqrt (* 2.0 (* -4.0 (* (* A C) (* F (+ A A)))))))
    (fma B B (* A (* C -4.0))))
   (* (sqrt (* F (- A (hypot B A)))) (/ (- (sqrt 2.0)) B))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
	double tmp;
	if (pow(B, 2.0) <= 5e-156) {
		tmp = -sqrt((2.0 * (-4.0 * ((A * C) * (F * (A + A)))))) / fma(B, B, (A * (C * -4.0)));
	} else {
		tmp = sqrt((F * (A - hypot(B, A)))) * (-sqrt(2.0) / B);
	}
	return tmp;
}
B = abs(B)
A, C = sort([A, C])
function code(A, B, C, F)
	tmp = 0.0
	if ((B ^ 2.0) <= 5e-156)
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))))) / fma(B, B, Float64(A * Float64(C * -4.0))));
	else
		tmp = Float64(sqrt(Float64(F * Float64(A - hypot(B, A)))) * Float64(Float64(-sqrt(2.0)) / B));
	end
	return tmp
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e-156], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(F * N[(A - N[Sqrt[B ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-156}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 B 2) < 5.00000000000000007e-156

    1. Initial program 19.0%

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

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

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

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

        \[\leadsto \frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\color{blue}{\left(C \cdot A\right)} \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      3. cancel-sign-sub-inv28.3%

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

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

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

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

    if 5.00000000000000007e-156 < (pow.f64 B 2)

    1. Initial program 23.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. Simplified27.9%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 27.0% accurate, 2.0× speedup?

\[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ \begin{array}{l} \mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot {\left(A \cdot F\right)}^{0.5}\right) \cdot \frac{-1}{B}\\ \end{array} \end{array} \]
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F)
 :precision binary64
 (if (<= (pow B 2.0) 2e-8)
   (/
    (- (sqrt (* 2.0 (* -4.0 (* (* A C) (* F (+ A A)))))))
    (fma B B (* A (* C -4.0))))
   (* (* 2.0 (pow (* A F) 0.5)) (/ -1.0 B))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
	double tmp;
	if (pow(B, 2.0) <= 2e-8) {
		tmp = -sqrt((2.0 * (-4.0 * ((A * C) * (F * (A + A)))))) / fma(B, B, (A * (C * -4.0)));
	} else {
		tmp = (2.0 * pow((A * F), 0.5)) * (-1.0 / B);
	}
	return tmp;
}
B = abs(B)
A, C = sort([A, C])
function code(A, B, C, F)
	tmp = 0.0
	if ((B ^ 2.0) <= 2e-8)
		tmp = Float64(Float64(-sqrt(Float64(2.0 * Float64(-4.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A))))))) / fma(B, B, Float64(A * Float64(C * -4.0))));
	else
		tmp = Float64(Float64(2.0 * (Float64(A * F) ^ 0.5)) * Float64(-1.0 / B));
	end
	return tmp
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e-8], N[((-N[Sqrt[N[(2.0 * N[(-4.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(2 \cdot {\left(A \cdot F\right)}^{0.5}\right) \cdot \frac{-1}{B}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 B 2) < 2e-8

    1. Initial program 21.3%

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

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

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

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

        \[\leadsto \frac{-\sqrt{2 \cdot \left(-4 \cdot \left(\color{blue}{\left(C \cdot A\right)} \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)\right)}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
      3. cancel-sign-sub-inv25.7%

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

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

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

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

    if 2e-8 < (pow.f64 B 2)

    1. Initial program 22.3%

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

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

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

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

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

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

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

      \[\leadsto -\color{blue}{2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*3.7%

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

      \[\leadsto -\color{blue}{\left(2 \cdot \sqrt{A \cdot F}\right) \cdot \frac{1}{B}} \]
    9. Step-by-step derivation
      1. pow1/23.9%

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

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

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

Alternative 6: 8.9% accurate, 5.8× speedup?

\[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ \left(2 \cdot {\left(A \cdot F\right)}^{0.5}\right) \cdot \frac{-1}{B} \end{array} \]
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F) :precision binary64 (* (* 2.0 (pow (* A F) 0.5)) (/ -1.0 B)))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
	return (2.0 * pow((A * F), 0.5)) * (-1.0 / B);
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    code = (2.0d0 * ((a * f) ** 0.5d0)) * ((-1.0d0) / b)
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
	return (2.0 * Math.pow((A * F), 0.5)) * (-1.0 / B);
}
B = abs(B)
[A, C] = sort([A, C])
def code(A, B, C, F):
	return (2.0 * math.pow((A * F), 0.5)) * (-1.0 / B)
B = abs(B)
A, C = sort([A, C])
function code(A, B, C, F)
	return Float64(Float64(2.0 * (Float64(A * F) ^ 0.5)) * Float64(-1.0 / B))
end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
	tmp = (2.0 * ((A * F) ^ 0.5)) * (-1.0 / B);
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := N[(N[(2.0 * N[Power[N[(A * F), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / B), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\left(2 \cdot {\left(A \cdot F\right)}^{0.5}\right) \cdot \frac{-1}{B}
\end{array}
Derivation
  1. Initial program 21.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. Simplified28.3%

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

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

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

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

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

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

    \[\leadsto -\color{blue}{2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)} \]
  7. Step-by-step derivation
    1. associate-*r*2.8%

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

    \[\leadsto -\color{blue}{\left(2 \cdot \sqrt{A \cdot F}\right) \cdot \frac{1}{B}} \]
  9. Step-by-step derivation
    1. pow1/23.0%

      \[\leadsto -\left(2 \cdot \color{blue}{{\left(A \cdot F\right)}^{0.5}}\right) \cdot \frac{1}{B} \]
  10. Applied egg-rr3.0%

    \[\leadsto -\left(2 \cdot \color{blue}{{\left(A \cdot F\right)}^{0.5}}\right) \cdot \frac{1}{B} \]
  11. Final simplification3.0%

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

Alternative 7: 8.9% accurate, 5.9× speedup?

\[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ \frac{-2}{\frac{B}{\sqrt{A \cdot F}}} \end{array} \]
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
(FPCore (A B C F) :precision binary64 (/ (- 2.0) (/ B (sqrt (* A F)))))
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
	return -2.0 / (B / sqrt((A * F)));
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    code = -2.0d0 / (b / sqrt((a * f)))
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
	return -2.0 / (B / Math.sqrt((A * F)));
}
B = abs(B)
[A, C] = sort([A, C])
def code(A, B, C, F):
	return -2.0 / (B / math.sqrt((A * F)))
B = abs(B)
A, C = sort([A, C])
function code(A, B, C, F)
	return Float64(Float64(-2.0) / Float64(B / sqrt(Float64(A * F))))
end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
	tmp = -2.0 / (B / sqrt((A * F)));
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := N[((-2.0) / N[(B / N[Sqrt[N[(A * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
\frac{-2}{\frac{B}{\sqrt{A \cdot F}}}
\end{array}
Derivation
  1. Initial program 21.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. Simplified28.3%

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

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

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

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

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

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

    \[\leadsto -\color{blue}{2 \cdot \left(\sqrt{A \cdot F} \cdot \frac{1}{B}\right)} \]
  7. Step-by-step derivation
    1. associate-*r*2.8%

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

    \[\leadsto -\color{blue}{\left(2 \cdot \sqrt{A \cdot F}\right) \cdot \frac{1}{B}} \]
  9. Step-by-step derivation
    1. expm1-log1p-u2.7%

      \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(2 \cdot \sqrt{A \cdot F}\right) \cdot \frac{1}{B}\right)\right)} \]
    2. expm1-udef2.1%

      \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(\left(2 \cdot \sqrt{A \cdot F}\right) \cdot \frac{1}{B}\right)} - 1\right)} \]
    3. un-div-inv2.1%

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

    \[\leadsto -\color{blue}{\left(e^{\mathsf{log1p}\left(\frac{2 \cdot \sqrt{A \cdot F}}{B}\right)} - 1\right)} \]
  11. Step-by-step derivation
    1. expm1-def2.7%

      \[\leadsto -\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{2 \cdot \sqrt{A \cdot F}}{B}\right)\right)} \]
    2. expm1-log1p2.8%

      \[\leadsto -\color{blue}{\frac{2 \cdot \sqrt{A \cdot F}}{B}} \]
    3. associate-/l*2.8%

      \[\leadsto -\color{blue}{\frac{2}{\frac{B}{\sqrt{A \cdot F}}}} \]
  12. Simplified2.8%

    \[\leadsto -\color{blue}{\frac{2}{\frac{B}{\sqrt{A \cdot F}}}} \]
  13. Final simplification2.8%

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

Reproduce

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