Average Error: 52.3 → 42.1
Time: 35.9s
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 := -\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}\\ \mathbf{if}\;C \leq -8.822223828748478 \cdot 10^{+98}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\\ \mathbf{if}\;C \leq -3.402280393262435 \cdot 10^{+32}:\\ \;\;\;\;\begin{array}{l} t_2 := {C}^{2} + {B}^{2}\\ \frac{-\sqrt{t_1 \cdot \left(2 \cdot \left(F \cdot \left(\left(A + \left(C + \sqrt{t_2}\right)\right) - \left(C \cdot A\right) \cdot \sqrt{\frac{1}{t_2}}\right)\right)\right)}}{t_1} \end{array}\\ \mathbf{elif}\;C \leq -3.262389646343389 \cdot 10^{-33}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := 2 \cdot \left(F \cdot \left(\left(C + A\right) + \mathsf{hypot}\left(B, A - C\right)\right)\right)\\ \mathbf{if}\;C \leq 2.116237083777588 \cdot 10^{-116}:\\ \;\;\;\;-\frac{\sqrt{t_3}}{\mathsf{hypot}\left(\sqrt{A \cdot \left(C \cdot -4\right)}, B\right)}\\ \mathbf{elif}\;C \leq 1.5281556949108983 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{\frac{t_1}{-\sqrt{t_1 \cdot t_3}}}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}\\ \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}
t_0 := -\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}\\
\mathbf{if}\;C \leq -8.822223828748478 \cdot 10^{+98}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;C \leq -3.262389646343389 \cdot 10^{-33}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := 2 \cdot \left(F \cdot \left(\left(C + A\right) + \mathsf{hypot}\left(B, A - C\right)\right)\right)\\
\mathbf{if}\;C \leq 2.116237083777588 \cdot 10^{-116}:\\
\;\;\;\;-\frac{\sqrt{t_3}}{\mathsf{hypot}\left(\sqrt{A \cdot \left(C \cdot -4\right)}, B\right)}\\

\mathbf{elif}\;C \leq 1.5281556949108983 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{\frac{t_1}{-\sqrt{t_1 \cdot t_3}}}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}\\


\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
 (let* ((t_0 (- (* (sqrt (* -0.5 (/ F C))) (sqrt 2.0)))))
   (if (<= C -8.822223828748478e+98)
     t_0
     (let* ((t_1 (fma A (* C -4.0) (* B B))))
       (if (<= C -3.402280393262435e+32)
         (let* ((t_2 (+ (pow C 2.0) (pow B 2.0))))
           (/
            (-
             (sqrt
              (*
               t_1
               (*
                2.0
                (*
                 F
                 (- (+ A (+ C (sqrt t_2))) (* (* C A) (sqrt (/ 1.0 t_2)))))))))
            t_1))
         (if (<= C -3.262389646343389e-33)
           t_0
           (let* ((t_3 (* 2.0 (* F (+ (+ C A) (hypot B (- A C)))))))
             (if (<= C 2.116237083777588e-116)
               (- (/ (sqrt t_3) (hypot (sqrt (* A (* C -4.0))) B)))
               (if (<= C 1.5281556949108983e+153)
                 (/ 1.0 (/ t_1 (- (sqrt (* t_1 t_3)))))
                 (- (* (sqrt 2.0) (sqrt (* -0.5 (/ F A))))))))))))))
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 = -(sqrt(-0.5 * (F / C)) * sqrt(2.0));
	double tmp;
	if (C <= -8.822223828748478e+98) {
		tmp = t_0;
	} else {
		double t_1 = fma(A, (C * -4.0), (B * B));
		double tmp_1;
		if (C <= -3.402280393262435e+32) {
			double t_2_2 = pow(C, 2.0) + pow(B, 2.0);
			tmp_1 = -sqrt(t_1 * (2.0 * (F * ((A + (C + sqrt(t_2_2))) - ((C * A) * sqrt(1.0 / t_2_2)))))) / t_1;
		} else if (C <= -3.262389646343389e-33) {
			tmp_1 = t_0;
		} else {
			double t_3 = 2.0 * (F * ((C + A) + hypot(B, (A - C))));
			double tmp_3;
			if (C <= 2.116237083777588e-116) {
				tmp_3 = -(sqrt(t_3) / hypot(sqrt(A * (C * -4.0)), B));
			} else if (C <= 1.5281556949108983e+153) {
				tmp_3 = 1.0 / (t_1 / -sqrt(t_1 * t_3));
			} else {
				tmp_3 = -(sqrt(2.0) * sqrt(-0.5 * (F / A)));
			}
			tmp_1 = tmp_3;
		}
		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 5 regimes
  2. if C < -8.82222382874847772e98 or -3.4022803932624353e32 < C < -3.2623896463433888e-33

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

      \[\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 41.5

      \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}\right)} \]
    4. Simplified41.5

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

    if -8.82222382874847772e98 < C < -3.4022803932624353e32

    1. Initial program 58.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. Simplified56.5

      \[\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 0 46.3

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

    if -3.2623896463433888e-33 < C < 2.11623708377758811e-116

    1. Initial program 48.6

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

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

      \[\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_binary6442.3

      \[\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_binary6442.3

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

      \[\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. Simplified41.7

      \[\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)}} \]
    8. Applied *-un-lft-identity_binary6441.7

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

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

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

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

    if 2.11623708377758811e-116 < C < 1.5281556949108983e153

    1. Initial program 42.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. Simplified40.9

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

      \[\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 1.5281556949108983e153 < C

    1. Initial program 63.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. Simplified53.7

      \[\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 47.9

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

      \[\leadsto \color{blue}{-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification42.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;C \leq -8.822223828748478 \cdot 10^{+98}:\\ \;\;\;\;-\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}\\ \mathbf{elif}\;C \leq -3.402280393262435 \cdot 10^{+32}:\\ \;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right) \cdot \left(2 \cdot \left(F \cdot \left(\left(A + \left(C + \sqrt{{C}^{2} + {B}^{2}}\right)\right) - \left(C \cdot A\right) \cdot \sqrt{\frac{1}{{C}^{2} + {B}^{2}}}\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}\\ \mathbf{elif}\;C \leq -3.262389646343389 \cdot 10^{-33}:\\ \;\;\;\;-\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}\\ \mathbf{elif}\;C \leq 2.116237083777588 \cdot 10^{-116}:\\ \;\;\;\;-\frac{\sqrt{2 \cdot \left(F \cdot \left(\left(C + A\right) + \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\mathsf{hypot}\left(\sqrt{A \cdot \left(C \cdot -4\right)}, B\right)}\\ \mathbf{elif}\;C \leq 1.5281556949108983 \cdot 10^{+153}:\\ \;\;\;\;\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{else}:\\ \;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}\\ \end{array} \]

Reproduce

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