Average Error: 52.2 → 33.0
Time: 15.1s
Precision: binary64
\[ \begin{array}{c}[A, C] = \mathsf{sort}([A, C])\\ \end{array} \]
\[\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} \]
\[\begin{array}{l} t_0 := \mathsf{hypot}\left(B, A - C\right)\\ t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\ t_2 := \sqrt{C + t_0}\\ \mathbf{if}\;A \leq -1 \cdot 10^{-50}:\\ \;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{-0.5 \cdot F}{A}}\right)\\ \mathbf{elif}\;A \leq 2.4 \cdot 10^{-298}:\\ \;\;\;\;\left(\sqrt{2 \cdot t_1} \cdot \left(-\sqrt{F}\right)\right) \cdot \frac{\sqrt{t_0 + \left(A + C\right)}}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(t_2, t_2, A\right)} \cdot \left(-\sqrt{2 \cdot \left(F \cdot t_1\right)}\right)}{t_1}\\ \end{array} \]
(FPCore (A B C F)
 :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))))
(FPCore (A B C F)
 :precision binary64
 (let* ((t_0 (hypot B (- A C)))
        (t_1 (fma B B (* A (* C -4.0))))
        (t_2 (sqrt (+ C t_0))))
   (if (<= A -1e-50)
     (* (sqrt 2.0) (- (sqrt (/ (* -0.5 F) A))))
     (if (<= A 2.4e-298)
       (* (* (sqrt (* 2.0 t_1)) (- (sqrt F))) (/ (sqrt (+ t_0 (+ A C))) t_1))
       (/ (* (sqrt (fma t_2 t_2 A)) (- (sqrt (* 2.0 (* F t_1))))) t_1)))))
double code(double A, double B, double C, double F) {
	return -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));
}
double code(double A, double B, double C, double F) {
	double t_0 = hypot(B, (A - C));
	double t_1 = fma(B, B, (A * (C * -4.0)));
	double t_2 = sqrt((C + t_0));
	double tmp;
	if (A <= -1e-50) {
		tmp = sqrt(2.0) * -sqrt(((-0.5 * F) / A));
	} else if (A <= 2.4e-298) {
		tmp = (sqrt((2.0 * t_1)) * -sqrt(F)) * (sqrt((t_0 + (A + C))) / t_1);
	} else {
		tmp = (sqrt(fma(t_2, t_2, A)) * -sqrt((2.0 * (F * t_1)))) / t_1;
	}
	return tmp;
}
function code(A, B, C, F)
	return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) * F)) * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)))
end
function code(A, B, C, F)
	t_0 = hypot(B, Float64(A - C))
	t_1 = fma(B, B, Float64(A * Float64(C * -4.0)))
	t_2 = sqrt(Float64(C + t_0))
	tmp = 0.0
	if (A <= -1e-50)
		tmp = Float64(sqrt(2.0) * Float64(-sqrt(Float64(Float64(-0.5 * F) / A))));
	elseif (A <= 2.4e-298)
		tmp = Float64(Float64(sqrt(Float64(2.0 * t_1)) * Float64(-sqrt(F))) * Float64(sqrt(Float64(t_0 + Float64(A + C))) / t_1));
	else
		tmp = Float64(Float64(sqrt(fma(t_2, t_2, A)) * Float64(-sqrt(Float64(2.0 * Float64(F * t_1))))) / t_1);
	end
	return tmp
end
code[A_, B_, C_, F_] := N[((-N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision] * 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]) / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[A_, B_, C_, F_] := Block[{t$95$0 = N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(C + t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[A, -1e-50], N[(N[Sqrt[2.0], $MachinePrecision] * (-N[Sqrt[N[(N[(-0.5 * F), $MachinePrecision] / A), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[A, 2.4e-298], N[(N[(N[Sqrt[N[(2.0 * t$95$1), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[F], $MachinePrecision])), $MachinePrecision] * N[(N[Sqrt[N[(t$95$0 + N[(A + C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(t$95$2 * t$95$2 + A), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[N[(2.0 * N[(F * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / t$95$1), $MachinePrecision]]]]]]
\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}
\begin{array}{l}
t_0 := \mathsf{hypot}\left(B, A - C\right)\\
t_1 := \mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_2 := \sqrt{C + t_0}\\
\mathbf{if}\;A \leq -1 \cdot 10^{-50}:\\
\;\;\;\;\sqrt{2} \cdot \left(-\sqrt{\frac{-0.5 \cdot F}{A}}\right)\\

\mathbf{elif}\;A \leq 2.4 \cdot 10^{-298}:\\
\;\;\;\;\left(\sqrt{2 \cdot t_1} \cdot \left(-\sqrt{F}\right)\right) \cdot \frac{\sqrt{t_0 + \left(A + C\right)}}{t_1}\\

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


\end{array}

Error

Derivation

  1. Split input into 3 regimes
  2. if A < -1.00000000000000001e-50

    1. Initial program 59.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. Simplified55.8

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}\right)} \]
    7. Simplified37.9

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

    if -1.00000000000000001e-50 < A < 2.39999999999999987e-298

    1. Initial program 43.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. Simplified39.0

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

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

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

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

    if 2.39999999999999987e-298 < A

    1. Initial program 46.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. Simplified41.4

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

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

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

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

Reproduce

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