Average Error: 52.2 → 35.1
Time: 38.7s
Precision: binary64
\[[A, C]=\mathsf{sort}([A, C])\]
\[\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} \mathbf{if}\;C \leq -4.583468965674152 \cdot 10^{-60}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := 2 \cdot \left(F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)\\ t_1 := \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\\ \mathbf{if}\;C \leq -4.1890341447133404 \cdot 10^{-268}:\\ \;\;\;\;\frac{-1}{\frac{t_1}{\sqrt{t_1 \cdot t_0}}}\\ \mathbf{elif}\;C \leq 2.595610150498829 \cdot 10^{-95}:\\ \;\;\;\;-\frac{\sqrt{t_0}}{\sqrt{t_1}}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := \frac{-1}{0.5 \cdot \sqrt{-4 \cdot \frac{C}{F}}}\\ \mathbf{if}\;C \leq 1.3072799572480792 \cdot 10^{+67}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := \frac{-\sqrt{t_1 \cdot \left(2 \cdot \left(F \cdot \mathsf{fma}\left(2, A, -0.5 \cdot \frac{B \cdot B}{C}\right)\right)\right)}}{t_1}\\ \mathbf{if}\;C \leq 1.4999553372101038 \cdot 10^{+103}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;C \leq 2.1421053442050514 \cdot 10^{+178}:\\ \;\;\;\;-2 \cdot \sqrt{-0.25 \cdot \frac{F}{C}}\\ \mathbf{elif}\;C \leq 1.9355356954408794 \cdot 10^{+298}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array}\\ \end{array}\\ \end{array}\\ \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}
\mathbf{if}\;C \leq -4.583468965674152 \cdot 10^{-60}:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := 2 \cdot \left(F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)\\
t_1 := \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\\
\mathbf{if}\;C \leq -4.1890341447133404 \cdot 10^{-268}:\\
\;\;\;\;\frac{-1}{\frac{t_1}{\sqrt{t_1 \cdot t_0}}}\\

\mathbf{elif}\;C \leq 2.595610150498829 \cdot 10^{-95}:\\
\;\;\;\;-\frac{\sqrt{t_0}}{\sqrt{t_1}}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := \frac{-1}{0.5 \cdot \sqrt{-4 \cdot \frac{C}{F}}}\\
\mathbf{if}\;C \leq 1.3072799572480792 \cdot 10^{+67}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \frac{-\sqrt{t_1 \cdot \left(2 \cdot \left(F \cdot \mathsf{fma}\left(2, A, -0.5 \cdot \frac{B \cdot B}{C}\right)\right)\right)}}{t_1}\\
\mathbf{if}\;C \leq 1.4999553372101038 \cdot 10^{+103}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;C \leq 2.1421053442050514 \cdot 10^{+178}:\\
\;\;\;\;-2 \cdot \sqrt{-0.25 \cdot \frac{F}{C}}\\

\mathbf{elif}\;C \leq 1.9355356954408794 \cdot 10^{+298}:\\
\;\;\;\;t_3\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}\\


\end{array}\\


\end{array}\\


\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
 (if (<= C -4.583468965674152e-60)
   (* -0.25 (/ (sqrt (* -16.0 (* C F))) C))
   (let* ((t_0 (* 2.0 (* F (- (+ C A) (hypot B (- A C))))))
          (t_1 (fma A (* C -4.0) (* B B))))
     (if (<= C -4.1890341447133404e-268)
       (/ -1.0 (/ t_1 (sqrt (* t_1 t_0))))
       (if (<= C 2.595610150498829e-95)
         (- (/ (sqrt t_0) (sqrt t_1)))
         (let* ((t_2 (/ -1.0 (* 0.5 (sqrt (* -4.0 (/ C F)))))))
           (if (<= C 1.3072799572480792e+67)
             t_2
             (let* ((t_3
                     (/
                      (-
                       (sqrt
                        (*
                         t_1
                         (* 2.0 (* F (fma 2.0 A (* -0.5 (/ (* B B) C))))))))
                      t_1)))
               (if (<= C 1.4999553372101038e+103)
                 t_3
                 (if (<= C 2.1421053442050514e+178)
                   (* -2.0 (sqrt (* -0.25 (/ F C))))
                   (if (<= C 1.9355356954408794e+298) t_3 t_2)))))))))))
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 tmp;
	if (C <= -4.583468965674152e-60) {
		tmp = -0.25 * (sqrt(-16.0 * (C * F)) / C);
	} else {
		double t_0 = 2.0 * (F * ((C + A) - hypot(B, (A - C))));
		double t_1 = fma(A, (C * -4.0), (B * B));
		double tmp_1;
		if (C <= -4.1890341447133404e-268) {
			tmp_1 = -1.0 / (t_1 / sqrt(t_1 * t_0));
		} else if (C <= 2.595610150498829e-95) {
			tmp_1 = -(sqrt(t_0) / sqrt(t_1));
		} else {
			double t_2 = -1.0 / (0.5 * sqrt(-4.0 * (C / F)));
			double tmp_2;
			if (C <= 1.3072799572480792e+67) {
				tmp_2 = t_2;
			} else {
				double t_3 = -sqrt(t_1 * (2.0 * (F * fma(2.0, A, (-0.5 * ((B * B) / C)))))) / t_1;
				double tmp_3;
				if (C <= 1.4999553372101038e+103) {
					tmp_3 = t_3;
				} else if (C <= 2.1421053442050514e+178) {
					tmp_3 = -2.0 * sqrt(-0.25 * (F / C));
				} else if (C <= 1.9355356954408794e+298) {
					tmp_3 = t_3;
				} else {
					tmp_3 = t_2;
				}
				tmp_2 = tmp_3;
			}
			tmp_1 = tmp_2;
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus A

Bits error versus B

Bits error versus C

Bits error versus F

Derivation

  1. Split input into 6 regimes
  2. if C < -4.58346896567415184e-60

    1. Initial program 54.1

      \[\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. Simplified50.2

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

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

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

    if -4.58346896567415184e-60 < C < -4.1890341447133404e-268

    1. Initial program 41.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. Simplified33.8

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right) \cdot \left(2 \cdot \left(F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \]
    4. Applied associate-/l*_binary6433.9

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

    if -4.1890341447133404e-268 < C < 2.59561015049882893e-95

    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. Simplified38.4

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

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

      \[\leadsto \frac{-\color{blue}{\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \cdot \sqrt{2 \cdot \left(F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}}{\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \cdot \sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}} \]
    5. Applied distribute-lft-neg-in_binary6431.6

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

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

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

    if 2.59561015049882893e-95 < C < 1.30727995724807923e67 or 1.93553569544087942e298 < C

    1. Initial program 50.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. Simplified49.0

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right) \cdot \left(2 \cdot \left(F \cdot \left(2 \cdot A\right)\right)\right)}}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \]
    5. Applied associate-/l*_binary6448.4

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

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

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

    if 1.30727995724807923e67 < C < 1.4999553372101038e103 or 2.1421053442050514e178 < C < 1.93553569544087942e298

    1. Initial program 63.1

      \[\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. Simplified61.8

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

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

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

    if 1.4999553372101038e103 < C < 2.1421053442050514e178

    1. Initial program 62.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. Simplified61.6

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

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

      \[\leadsto \color{blue}{-2 \cdot \sqrt{-0.25 \cdot \frac{F}{C}}} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification35.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;C \leq -4.583468965674152 \cdot 10^{-60}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\ \mathbf{elif}\;C \leq -4.1890341447133404 \cdot 10^{-268}:\\ \;\;\;\;\frac{-1}{\frac{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}{\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right) \cdot \left(2 \cdot \left(F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)}}}\\ \mathbf{elif}\;C \leq 2.595610150498829 \cdot 10^{-95}:\\ \;\;\;\;-\frac{\sqrt{2 \cdot \left(F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}}\\ \mathbf{elif}\;C \leq 1.3072799572480792 \cdot 10^{+67}:\\ \;\;\;\;\frac{-1}{0.5 \cdot \sqrt{-4 \cdot \frac{C}{F}}}\\ \mathbf{elif}\;C \leq 1.4999553372101038 \cdot 10^{+103}:\\ \;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right) \cdot \left(2 \cdot \left(F \cdot \mathsf{fma}\left(2, A, -0.5 \cdot \frac{B \cdot B}{C}\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}\\ \mathbf{elif}\;C \leq 2.1421053442050514 \cdot 10^{+178}:\\ \;\;\;\;-2 \cdot \sqrt{-0.25 \cdot \frac{F}{C}}\\ \mathbf{elif}\;C \leq 1.9355356954408794 \cdot 10^{+298}:\\ \;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right) \cdot \left(2 \cdot \left(F \cdot \mathsf{fma}\left(2, A, -0.5 \cdot \frac{B \cdot B}{C}\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{0.5 \cdot \sqrt{-4 \cdot \frac{C}{F}}}\\ \end{array} \]

Reproduce

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