Average Error: 52.3 → 30.8
Time: 39.6s
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} t_0 := \sqrt{F \cdot -0.5}\\ t_1 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\ t_2 := \frac{-\sqrt{\left(2 \cdot \left(t_1 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_1}\\ t_3 := -\frac{t_0}{\sqrt{C}} \cdot \sqrt{2}\\ \mathbf{if}\;t_2 \leq -4.252930674637676 \cdot 10^{+216}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_4 := \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\\ \mathbf{if}\;t_2 \leq -1.7291938347211952 \cdot 10^{-222}:\\ \;\;\;\;\frac{-\sqrt{\left(2 \cdot t_4\right) \cdot \left(F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{t_4}\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\begin{array}{l} t_5 := \sqrt{-8 \cdot \left(C \cdot F\right)}\\ \frac{\mathsf{fma}\left(A, \sqrt{2} \cdot t_5, \frac{F \cdot \left(\sqrt{2} \cdot \left(B \cdot B\right)\right)}{t_5}\right)}{t_4} \end{array}\\ \mathbf{else}:\\ \;\;\;\;-\frac{t_0 \cdot \sqrt{2}}{\sqrt{C}}\\ \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{F \cdot -0.5}\\
t_1 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_2 := \frac{-\sqrt{\left(2 \cdot \left(t_1 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{t_1}\\
t_3 := -\frac{t_0}{\sqrt{C}} \cdot \sqrt{2}\\
\mathbf{if}\;t_2 \leq -4.252930674637676 \cdot 10^{+216}:\\
\;\;\;\;t_3\\

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

\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\begin{array}{l}
t_5 := \sqrt{-8 \cdot \left(C \cdot F\right)}\\
\frac{\mathsf{fma}\left(A, \sqrt{2} \cdot t_5, \frac{F \cdot \left(\sqrt{2} \cdot \left(B \cdot B\right)\right)}{t_5}\right)}{t_4}
\end{array}\\

\mathbf{else}:\\
\;\;\;\;-\frac{t_0 \cdot \sqrt{2}}{\sqrt{C}}\\


\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 (* F -0.5)))
        (t_1 (- (pow B 2.0) (* (* 4.0 A) C)))
        (t_2
         (/
          (-
           (sqrt
            (*
             (* 2.0 (* t_1 F))
             (- (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
          t_1))
        (t_3 (- (* (/ t_0 (sqrt C)) (sqrt 2.0)))))
   (if (<= t_2 -4.252930674637676e+216)
     t_3
     (let* ((t_4 (fma A (* C -4.0) (* B B))))
       (if (<= t_2 -1.7291938347211952e-222)
         (/ (- (sqrt (* (* 2.0 t_4) (* F (- (+ A C) (hypot B (- A C))))))) t_4)
         (if (<= t_2 0.0)
           t_3
           (if (<= t_2 INFINITY)
             (let* ((t_5 (sqrt (* -8.0 (* C F)))))
               (/
                (fma A (* (sqrt 2.0) t_5) (/ (* F (* (sqrt 2.0) (* B B))) t_5))
                t_4))
             (- (/ (* t_0 (sqrt 2.0)) (sqrt C))))))))))
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(F * -0.5);
	double t_1 = pow(B, 2.0) - ((4.0 * A) * C);
	double t_2 = -sqrt((2.0 * (t_1 * F)) * ((A + C) - sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / t_1;
	double t_3 = -((t_0 / sqrt(C)) * sqrt(2.0));
	double tmp;
	if (t_2 <= -4.252930674637676e+216) {
		tmp = t_3;
	} else {
		double t_4 = fma(A, (C * -4.0), (B * B));
		double tmp_1;
		if (t_2 <= -1.7291938347211952e-222) {
			tmp_1 = -sqrt((2.0 * t_4) * (F * ((A + C) - hypot(B, (A - C))))) / t_4;
		} else if (t_2 <= 0.0) {
			tmp_1 = t_3;
		} else if (t_2 <= ((double) INFINITY)) {
			double t_5 = sqrt(-8.0 * (C * F));
			tmp_1 = fma(A, (sqrt(2.0) * t_5), ((F * (sqrt(2.0) * (B * B))) / t_5)) / t_4;
		} else {
			tmp_1 = -((t_0 * sqrt(2.0)) / sqrt(C));
		}
		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 4 regimes
  2. if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -4.2529306746376758e216 or -1.7291938347211952e-222 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -0.0

    1. Initial program 62.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. Simplified56.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 A around -inf 32.8

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

      \[\leadsto \color{blue}{-\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}} \]
    5. Applied associate-*r/_binary6432.7

      \[\leadsto -\sqrt{\color{blue}{\frac{-0.5 \cdot F}{C}}} \cdot \sqrt{2} \]
    6. Applied sqrt-div_binary6424.9

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

    if -4.2529306746376758e216 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < -1.7291938347211952e-222

    1. Initial program 1.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. Simplified1.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. Applied associate-*r*_binary641.2

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

    if -0.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C))) < +inf.0

    1. Initial program 39.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. Simplified27.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 -inf 15.6

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

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

    if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 2 (*.f64 (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) 2) (pow.f64 B 2))))))) (-.f64 (pow.f64 B 2) (*.f64 (*.f64 4 A) C)))

    1. Initial program 64.0

      \[\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. Simplified63.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 -inf 52.4

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

      \[\leadsto \color{blue}{-\sqrt{-0.5 \cdot \frac{F}{C}} \cdot \sqrt{2}} \]
    5. Applied associate-*r/_binary6452.4

      \[\leadsto -\sqrt{\color{blue}{\frac{-0.5 \cdot F}{C}}} \cdot \sqrt{2} \]
    6. Applied sqrt-div_binary6448.5

      \[\leadsto -\color{blue}{\frac{\sqrt{-0.5 \cdot F}}{\sqrt{C}}} \cdot \sqrt{2} \]
    7. Applied associate-*l/_binary6448.5

      \[\leadsto -\color{blue}{\frac{\sqrt{-0.5 \cdot F} \cdot \sqrt{2}}{\sqrt{C}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification30.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\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{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \leq -4.252930674637676 \cdot 10^{+216}:\\ \;\;\;\;-\frac{\sqrt{F \cdot -0.5}}{\sqrt{C}} \cdot \sqrt{2}\\ \mathbf{elif}\;\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{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \leq -1.7291938347211952 \cdot 10^{-222}:\\ \;\;\;\;\frac{-\sqrt{\left(2 \cdot \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\right) \cdot \left(F \cdot \left(\left(A + C\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}\\ \mathbf{elif}\;\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{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \leq 0:\\ \;\;\;\;-\frac{\sqrt{F \cdot -0.5}}{\sqrt{C}} \cdot \sqrt{2}\\ \mathbf{elif}\;\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{{B}^{2} + {\left(A - C\right)}^{2}}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \leq \infty:\\ \;\;\;\;\frac{\mathsf{fma}\left(A, \sqrt{2} \cdot \sqrt{-8 \cdot \left(C \cdot F\right)}, \frac{F \cdot \left(\sqrt{2} \cdot \left(B \cdot B\right)\right)}{\sqrt{-8 \cdot \left(C \cdot F\right)}}\right)}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}\\ \mathbf{else}:\\ \;\;\;\;-\frac{\sqrt{F \cdot -0.5} \cdot \sqrt{2}}{\sqrt{C}}\\ \end{array} \]

Reproduce

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