Average Error: 52.8 → 41.3
Time: 33.4s
Precision: binary64
\[\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{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\ t_1 := F \cdot t_0\\ t_2 := \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}\\ \mathbf{if}\;C \leq -1.15 \cdot 10^{-12}:\\ \;\;\;\;-\sqrt{-\frac{F}{C}}\\ \mathbf{elif}\;C \leq 9 \cdot 10^{-272}:\\ \;\;\;\;\frac{{\left(2 \cdot t_1\right)}^{0.5} \cdot \left(-t_2\right)}{t_0}\\ \mathbf{elif}\;C \leq 8 \cdot 10^{-87}:\\ \;\;\;\;-\sqrt{-\frac{F}{A}}\\ \mathbf{else}:\\ \;\;\;\;\left(t_2 \cdot \left({2}^{0.5} \cdot {t_1}^{0.5}\right)\right) \cdot \frac{-1}{t_0}\\ \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 (fma B B (* A (* C -4.0))))
        (t_1 (* F t_0))
        (t_2 (sqrt (+ C (+ A (hypot B (- A C)))))))
   (if (<= C -1.15e-12)
     (- (sqrt (- (/ F C))))
     (if (<= C 9e-272)
       (/ (* (pow (* 2.0 t_1) 0.5) (- t_2)) t_0)
       (if (<= C 8e-87)
         (- (sqrt (- (/ F A))))
         (* (* t_2 (* (pow 2.0 0.5) (pow t_1 0.5))) (/ -1.0 t_0)))))))
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 = fma(B, B, (A * (C * -4.0)));
	double t_1 = F * t_0;
	double t_2 = sqrt((C + (A + hypot(B, (A - C)))));
	double tmp;
	if (C <= -1.15e-12) {
		tmp = -sqrt(-(F / C));
	} else if (C <= 9e-272) {
		tmp = (pow((2.0 * t_1), 0.5) * -t_2) / t_0;
	} else if (C <= 8e-87) {
		tmp = -sqrt(-(F / A));
	} else {
		tmp = (t_2 * (pow(2.0, 0.5) * pow(t_1, 0.5))) * (-1.0 / t_0);
	}
	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 = fma(B, B, Float64(A * Float64(C * -4.0)))
	t_1 = Float64(F * t_0)
	t_2 = sqrt(Float64(C + Float64(A + hypot(B, Float64(A - C)))))
	tmp = 0.0
	if (C <= -1.15e-12)
		tmp = Float64(-sqrt(Float64(-Float64(F / C))));
	elseif (C <= 9e-272)
		tmp = Float64(Float64((Float64(2.0 * t_1) ^ 0.5) * Float64(-t_2)) / t_0);
	elseif (C <= 8e-87)
		tmp = Float64(-sqrt(Float64(-Float64(F / A))));
	else
		tmp = Float64(Float64(t_2 * Float64((2.0 ^ 0.5) * (t_1 ^ 0.5))) * Float64(-1.0 / t_0));
	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[(B * B + N[(A * N[(C * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(F * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(C + N[(A + N[Sqrt[B ^ 2 + N[(A - C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[C, -1.15e-12], (-N[Sqrt[(-N[(F / C), $MachinePrecision])], $MachinePrecision]), If[LessEqual[C, 9e-272], N[(N[(N[Power[N[(2.0 * t$95$1), $MachinePrecision], 0.5], $MachinePrecision] * (-t$95$2)), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[C, 8e-87], (-N[Sqrt[(-N[(F / A), $MachinePrecision])], $MachinePrecision]), N[(N[(t$95$2 * N[(N[Power[2.0, 0.5], $MachinePrecision] * N[Power[t$95$1, 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $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{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)\\
t_1 := F \cdot t_0\\
t_2 := \sqrt{C + \left(A + \mathsf{hypot}\left(B, A - C\right)\right)}\\
\mathbf{if}\;C \leq -1.15 \cdot 10^{-12}:\\
\;\;\;\;-\sqrt{-\frac{F}{C}}\\

\mathbf{elif}\;C \leq 9 \cdot 10^{-272}:\\
\;\;\;\;\frac{{\left(2 \cdot t_1\right)}^{0.5} \cdot \left(-t_2\right)}{t_0}\\

\mathbf{elif}\;C \leq 8 \cdot 10^{-87}:\\
\;\;\;\;-\sqrt{-\frac{F}{A}}\\

\mathbf{else}:\\
\;\;\;\;\left(t_2 \cdot \left({2}^{0.5} \cdot {t_1}^{0.5}\right)\right) \cdot \frac{-1}{t_0}\\


\end{array}

Error

Bits error versus A

Bits error versus B

Bits error versus C

Bits error versus F

Derivation

  1. Split input into 4 regimes
  2. if C < -1.14999999999999995e-12

    1. Initial program 60.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. Simplified59.5

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

      \[\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{\left(C + A\right) + \mathsf{hypot}\left(B, A - C\right)}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    4. Applied egg-rr59.0

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

      \[\leadsto \color{blue}{-1 \cdot \sqrt{-1 \cdot \frac{F}{C}}} \]
    6. Simplified39.4

      \[\leadsto \color{blue}{-\sqrt{-\frac{F}{C}}} \]

    if -1.14999999999999995e-12 < C < 8.9999999999999995e-272

    1. Initial program 49.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. Simplified45.1

      \[\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-rr41.5

      \[\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{\left(C + A\right) + \mathsf{hypot}\left(B, A - C\right)}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    4. Applied egg-rr41.7

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

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

    if 8.9999999999999995e-272 < C < 8.00000000000000014e-87

    1. Initial program 48.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. Simplified43.5

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

      \[\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{\left(C + A\right) + \mathsf{hypot}\left(B, A - C\right)}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    4. Applied egg-rr40.2

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

      \[\leadsto \color{blue}{-1 \cdot \sqrt{-1 \cdot \frac{F}{A}}} \]
    6. Simplified49.3

      \[\leadsto \color{blue}{-\sqrt{-\frac{F}{A}}} \]

    if 8.00000000000000014e-87 < C

    1. Initial program 51.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. Simplified45.3

      \[\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-rr39.4

      \[\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{\left(C + A\right) + \mathsf{hypot}\left(B, A - C\right)}}}{\mathsf{fma}\left(B, B, A \cdot \left(C \cdot -4\right)\right)} \]
    4. Applied egg-rr39.5

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

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

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

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

Reproduce

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