ABCF->ab-angle b

Percentage Accurate: 19.5% → 46.6%
Time: 19.8s
Alternatives: 7
Speedup: 4.9×

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: 19.5% 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.6% accurate, 1.5× speedup?

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

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


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

    1. Initial program 23.6%

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

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

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

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

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

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

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

    if 1e51 < (pow.f64 B 2)

    1. Initial program 11.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. Simplified11.8%

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

      \[\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. associate-*r*9.5%

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

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

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

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

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

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

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

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

Alternative 2: 35.4% accurate, 2.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(A + \mathsf{fma}\left(-0.5, \frac{\left(B \cdot B + A \cdot A\right) - A \cdot A}{C}, A\right)\right)}}{t_0}\\


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

    1. Initial program 21.9%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e26 < C

    1. Initial program 3.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. Simplified3.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 32.7% accurate, 2.7× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(A + A\right)}}{t_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if C < 5.2e18

    1. Initial program 21.4%

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

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

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

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

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

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

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

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

    if 5.2e18 < C

    1. Initial program 6.2%

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

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

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

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

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

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

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

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

Alternative 4: 29.1% accurate, 4.7× speedup?

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

\mathbf{elif}\;B \leq 1.3 \cdot 10^{+129}:\\
\;\;\;\;\frac{-\sqrt{t_1 \cdot \left(A + \left(C - B\right)\right)}}{t_0}\\

\mathbf{else}:\\
\;\;\;\;-1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if B < 3.8000000000000002e45

    1. Initial program 18.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. Simplified18.8%

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

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

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

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

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

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

    if 3.8000000000000002e45 < B < 1.30000000000000006e129

    1. Initial program 38.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. Simplified38.0%

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

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

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

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

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

    if 1.30000000000000006e129 < B

    1. Initial program 0.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification16.2%

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

Alternative 5: 27.1% accurate, 4.9× speedup?

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

\mathbf{else}:\\
\;\;\;\;-1\\


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

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

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

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

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

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

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

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

    if 8.3999999999999995e77 < B

    1. Initial program 5.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. Simplified5.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.2%

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

Alternative 6: 5.3% accurate, 634.0× speedup?

\[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ -64 \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 -64.0)
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
	return -64.0;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    code = -64.0d0
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
	return -64.0;
}
B = abs(B)
[A, C] = sort([A, C])
def code(A, B, C, F):
	return -64.0
B = abs(B)
A, C = sort([A, C])
function code(A, B, C, F)
	return -64.0
end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
	tmp = -64.0;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := -64.0
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-64
\end{array}
Derivation
  1. Initial program 18.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. Simplified18.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-64} \]
  6. Final simplification4.9%

    \[\leadsto -64 \]

Alternative 7: 5.3% accurate, 634.0× speedup?

\[\begin{array}{l} B = |B|\\ [A, C] = \mathsf{sort}([A, C])\\ \\ -1 \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 -1.0)
B = abs(B);
assert(A < C);
double code(double A, double B, double C, double F) {
	return -1.0;
}
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
real(8) function code(a, b, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    code = -1.0d0
end function
B = Math.abs(B);
assert A < C;
public static double code(double A, double B, double C, double F) {
	return -1.0;
}
B = abs(B)
[A, C] = sort([A, C])
def code(A, B, C, F):
	return -1.0
B = abs(B)
A, C = sort([A, C])
function code(A, B, C, F)
	return -1.0
end
B = abs(B)
A, C = num2cell(sort([A, C])){:}
function tmp = code(A, B, C, F)
	tmp = -1.0;
end
NOTE: B should be positive before calling this function
NOTE: A and C should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := -1.0
\begin{array}{l}
B = |B|\\
[A, C] = \mathsf{sort}([A, C])\\
\\
-1
\end{array}
Derivation
  1. Initial program 18.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. Simplified18.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-1}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \cdot \sqrt{\left(A + \left(C - \mathsf{hypot}\left(B, A - C\right)\right)\right) \cdot \left(\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right) \cdot \left(2 \cdot F\right)\right)}} \]
  5. Applied egg-rr5.0%

    \[\leadsto \color{blue}{-1} \]
  6. Final simplification5.0%

    \[\leadsto -1 \]

Reproduce

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