ABCF->ab-angle b

Percentage Accurate: 19.1% → 44.5%
Time: 23.3s
Alternatives: 7
Speedup: 3.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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.1% accurate, 1.0× speedup?

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

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

Alternative 1: 44.5% accurate, 2.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;B\_m \leq 1.7 \cdot 10^{-106}:\\ \;\;\;\;\frac{-\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B\_m}^{2}\right)}\\ \mathbf{elif}\;B\_m \leq 4.3 \cdot 10^{+28}:\\ \;\;\;\;\sqrt{-0.5 \cdot \frac{F \cdot {B\_m}^{2}}{C}} \cdot \frac{-\sqrt{2}}{B\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (if (<= B_m 1.7e-106)
   (/
    (- (sqrt (* -8.0 (* (* A C) (* F (+ A A))))))
    (fma A (* C -4.0) (pow B_m 2.0)))
   (if (<= B_m 4.3e+28)
     (* (sqrt (* -0.5 (/ (* F (pow B_m 2.0)) C))) (/ (- (sqrt 2.0)) B_m))
     (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A)))))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 1.7e-106) {
		tmp = -sqrt((-8.0 * ((A * C) * (F * (A + A))))) / fma(A, (C * -4.0), pow(B_m, 2.0));
	} else if (B_m <= 4.3e+28) {
		tmp = sqrt((-0.5 * ((F * pow(B_m, 2.0)) / C))) * (-sqrt(2.0) / B_m);
	} else {
		tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
	}
	return tmp;
}
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if (B_m <= 1.7e-106)
		tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(Float64(A * C) * Float64(F * Float64(A + A)))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0)));
	elseif (B_m <= 4.3e+28)
		tmp = Float64(sqrt(Float64(-0.5 * Float64(Float64(F * (B_m ^ 2.0)) / C))) * Float64(Float64(-sqrt(2.0)) / B_m));
	else
		tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A))))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 1.7e-106], N[((-N[Sqrt[N[(-8.0 * N[(N[(A * C), $MachinePrecision] * N[(F * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 4.3e+28], N[(N[Sqrt[N[(-0.5 * N[(N[(F * N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 1.7 \cdot 10^{-106}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(\left(A \cdot C\right) \cdot \left(F \cdot \left(A + A\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B\_m}^{2}\right)}\\

\mathbf{elif}\;B\_m \leq 4.3 \cdot 10^{+28}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F \cdot {B\_m}^{2}}{C}} \cdot \frac{-\sqrt{2}}{B\_m}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if B < 1.69999999999999991e-106

    1. Initial program 16.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. Simplified22.0%

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

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

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

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

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

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

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

    if 1.69999999999999991e-106 < B < 4.29999999999999975e28

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

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

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

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

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

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

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

        \[\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-def14.0%

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

      \[\leadsto \color{blue}{\sqrt{F \cdot \left(C - \mathsf{hypot}\left(B, C\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)} \]
    7. Taylor expanded in C around inf 22.5%

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

    if 4.29999999999999975e28 < B

    1. Initial program 8.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. Simplified7.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 44.1% accurate, 2.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \begin{array}{l} \mathbf{if}\;B\_m \leq 4.7 \cdot 10^{-107}:\\ \;\;\;\;\frac{-\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A \cdot 2\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B\_m}^{2}\right)}\\ \mathbf{elif}\;B\_m \leq 1.05 \cdot 10^{+27}:\\ \;\;\;\;\sqrt{-0.5 \cdot \frac{F \cdot {B\_m}^{2}}{C}} \cdot \frac{-\sqrt{2}}{B\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)\\ \end{array} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (if (<= B_m 4.7e-107)
   (/
    (- (sqrt (* -8.0 (* A (* C (* F (* A 2.0)))))))
    (fma A (* C -4.0) (pow B_m 2.0)))
   (if (<= B_m 1.05e+27)
     (* (sqrt (* -0.5 (/ (* F (pow B_m 2.0)) C))) (/ (- (sqrt 2.0)) B_m))
     (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A)))))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	double tmp;
	if (B_m <= 4.7e-107) {
		tmp = -sqrt((-8.0 * (A * (C * (F * (A * 2.0)))))) / fma(A, (C * -4.0), pow(B_m, 2.0));
	} else if (B_m <= 1.05e+27) {
		tmp = sqrt((-0.5 * ((F * pow(B_m, 2.0)) / C))) * (-sqrt(2.0) / B_m);
	} else {
		tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
	}
	return tmp;
}
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	tmp = 0.0
	if (B_m <= 4.7e-107)
		tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A * 2.0))))))) / fma(A, Float64(C * -4.0), (B_m ^ 2.0)));
	elseif (B_m <= 1.05e+27)
		tmp = Float64(sqrt(Float64(-0.5 * Float64(Float64(F * (B_m ^ 2.0)) / C))) * Float64(Float64(-sqrt(2.0)) / B_m));
	else
		tmp = Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A))))));
	end
	return tmp
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := If[LessEqual[B$95$m, 4.7e-107], N[((-N[Sqrt[N[(-8.0 * N[(A * N[(C * N[(F * N[(A * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(A * N[(C * -4.0), $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[B$95$m, 1.05e+27], N[(N[Sqrt[N[(-0.5 * N[(N[(F * N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[((-N[Sqrt[2.0], $MachinePrecision]) / B$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B\_m \leq 4.7 \cdot 10^{-107}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A \cdot 2\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B\_m}^{2}\right)}\\

\mathbf{elif}\;B\_m \leq 1.05 \cdot 10^{+27}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F \cdot {B\_m}^{2}}{C}} \cdot \frac{-\sqrt{2}}{B\_m}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if B < 4.69999999999999998e-107

    1. Initial program 16.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. Simplified22.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-\sqrt{-8 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(A \cdot \left(C \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)\right)} - 1\right)}}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)} \]
    9. Step-by-step derivation
      1. expm1-def8.4%

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

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

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

    if 4.69999999999999998e-107 < B < 1.04999999999999997e27

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

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

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

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

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

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

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

        \[\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-def14.0%

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

      \[\leadsto \color{blue}{\sqrt{F \cdot \left(C - \mathsf{hypot}\left(B, C\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)} \]
    7. Taylor expanded in C around inf 22.5%

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

    if 1.04999999999999997e27 < B

    1. Initial program 8.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. Simplified7.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 32.5% accurate, 2.0× speedup?

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

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


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

    1. Initial program 16.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{F \cdot \left(\left(C + \left(A - \mathsf{hypot}\left(B, A - C\right)\right)\right) \cdot \left(2 \cdot \mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, {B}^{2}\right)}} \]
    3. Add Preprocessing
    4. Taylor expanded in A around 0 4.4%

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

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

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

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

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

        \[\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-def6.0%

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

      \[\leadsto \color{blue}{\sqrt{F \cdot \left(C - \mathsf{hypot}\left(B, C\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)} \]
    7. Taylor expanded in C around inf 8.6%

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

    if 1.10000000000000001e24 < B

    1. Initial program 8.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. Simplified7.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 32.0% accurate, 2.0× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right) \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (* (/ (sqrt 2.0) B_m) (- (sqrt (* F (- A (hypot B_m A)))))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	return (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
}
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	return (Math.sqrt(2.0) / B_m) * -Math.sqrt((F * (A - Math.hypot(B_m, A))));
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	return (math.sqrt(2.0) / B_m) * -math.sqrt((F * (A - math.hypot(B_m, A))))
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	return Float64(Float64(sqrt(2.0) / B_m) * Float64(-sqrt(Float64(F * Float64(A - hypot(B_m, A))))))
end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
	tmp = (sqrt(2.0) / B_m) * -sqrt((F * (A - hypot(B_m, A))));
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := N[(N[(N[Sqrt[2.0], $MachinePrecision] / B$95$m), $MachinePrecision] * (-N[Sqrt[N[(F * N[(A - N[Sqrt[B$95$m ^ 2 + A ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{2}}{B\_m} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B\_m, A\right)\right)}\right)
\end{array}
Derivation
  1. Initial program 14.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. Simplified18.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sqrt{2}}{B} \cdot \left(-\sqrt{F \cdot \left(A - \mathsf{hypot}\left(B, A\right)\right)}\right) \]
  8. Add Preprocessing

Alternative 5: 26.8% accurate, 3.0× speedup?

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

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

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

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

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

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

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

      \[\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-def14.6%

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

    \[\leadsto \color{blue}{\sqrt{F \cdot \left(C - \mathsf{hypot}\left(B, C\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)} \]
  7. Taylor expanded in C around 0 12.5%

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

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

      \[\leadsto \sqrt{\color{blue}{\left(-B\right)} \cdot F} \cdot \left(-\frac{\sqrt{2}}{B}\right) \]
  9. Simplified12.5%

    \[\leadsto \sqrt{\color{blue}{\left(-B\right) \cdot F}} \cdot \left(-\frac{\sqrt{2}}{B}\right) \]
  10. Final simplification12.5%

    \[\leadsto \frac{-\sqrt{2}}{B} \cdot \sqrt{B \cdot \left(-F\right)} \]
  11. Add Preprocessing

Alternative 6: 0.6% accurate, 3.0× speedup?

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

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

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

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

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

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

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

      \[\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-def14.6%

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

    \[\leadsto \color{blue}{\sqrt{F \cdot \left(C - \mathsf{hypot}\left(B, C\right)\right)} \cdot \left(-\frac{\sqrt{2}}{B}\right)} \]
  7. Taylor expanded in B around -inf 1.4%

    \[\leadsto \sqrt{F \cdot \color{blue}{B}} \cdot \left(-\frac{\sqrt{2}}{B}\right) \]
  8. Final simplification1.4%

    \[\leadsto \frac{\sqrt{2}}{B} \cdot \left(-\sqrt{B \cdot F}\right) \]
  9. Add Preprocessing

Alternative 7: 0.0% accurate, 3.1× speedup?

\[\begin{array}{l} B_m = \left|B\right| \\ [A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\ \\ \left(0.25 \cdot \sqrt{\frac{F}{C}}\right) \cdot \sqrt{-16} \end{array} \]
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
 :precision binary64
 (* (* 0.25 (sqrt (/ F C))) (sqrt -16.0)))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
	return (0.25 * sqrt((F / C))) * sqrt(-16.0);
}
B_m = abs(B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
real(8) function code(a, b_m, c, f)
    real(8), intent (in) :: a
    real(8), intent (in) :: b_m
    real(8), intent (in) :: c
    real(8), intent (in) :: f
    code = (0.25d0 * sqrt((f / c))) * sqrt((-16.0d0))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
	return (0.25 * Math.sqrt((F / C))) * Math.sqrt(-16.0);
}
B_m = math.fabs(B)
[A, B_m, C, F] = sort([A, B_m, C, F])
def code(A, B_m, C, F):
	return (0.25 * math.sqrt((F / C))) * math.sqrt(-16.0)
B_m = abs(B)
A, B_m, C, F = sort([A, B_m, C, F])
function code(A, B_m, C, F)
	return Float64(Float64(0.25 * sqrt(Float64(F / C))) * sqrt(-16.0))
end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
	tmp = (0.25 * sqrt((F / C))) * sqrt(-16.0);
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := N[(N[(0.25 * N[Sqrt[N[(F / C), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[-16.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\left(0.25 \cdot \sqrt{\frac{F}{C}}\right) \cdot \sqrt{-16}
\end{array}
Derivation
  1. Initial program 14.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. Simplified18.6%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.25 \cdot \left(\sqrt{\frac{F}{C}} \cdot \sqrt{-16}\right)} \]
  8. Step-by-step derivation
    1. associate-*r*0.0%

      \[\leadsto \color{blue}{\left(0.25 \cdot \sqrt{\frac{F}{C}}\right) \cdot \sqrt{-16}} \]
  9. Simplified0.0%

    \[\leadsto \color{blue}{\left(0.25 \cdot \sqrt{\frac{F}{C}}\right) \cdot \sqrt{-16}} \]
  10. Final simplification0.0%

    \[\leadsto \left(0.25 \cdot \sqrt{\frac{F}{C}}\right) \cdot \sqrt{-16} \]
  11. Add Preprocessing

Reproduce

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