Average Error: 52.4 → 35.7
Time: 35.9s
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 := \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\\ t_1 := \frac{-\sqrt{t_0} \cdot \sqrt{2 \cdot \left(F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{t_0}\\ t_2 := \sqrt{-16 \cdot \left(C \cdot F\right)}\\ \mathbf{if}\;C \leq -1.4798890101030842 \cdot 10^{-202}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{C \cdot -16} \cdot \sqrt{F}}{C}\\ \mathbf{elif}\;C \leq 2.3728370555847924 \cdot 10^{-122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;C \leq 9.773045125658437 \cdot 10^{-20}:\\ \;\;\;\;-0.25 \cdot \frac{t_2}{C}\\ \mathbf{elif}\;C \leq 1.386943960726298:\\ \;\;\;\;t_1\\ \mathbf{elif}\;C \leq 4.615178290867068 \cdot 10^{+256}:\\ \;\;\;\;-0.25 \cdot \left(t_2 \cdot \frac{-1}{-C}\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \sqrt{-0.25 \cdot \frac{F}{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{fma}\left(A, C \cdot -4, B \cdot B\right)\\
t_1 := \frac{-\sqrt{t_0} \cdot \sqrt{2 \cdot \left(F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{t_0}\\
t_2 := \sqrt{-16 \cdot \left(C \cdot F\right)}\\
\mathbf{if}\;C \leq -1.4798890101030842 \cdot 10^{-202}:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{C \cdot -16} \cdot \sqrt{F}}{C}\\

\mathbf{elif}\;C \leq 2.3728370555847924 \cdot 10^{-122}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;C \leq 9.773045125658437 \cdot 10^{-20}:\\
\;\;\;\;-0.25 \cdot \frac{t_2}{C}\\

\mathbf{elif}\;C \leq 1.386943960726298:\\
\;\;\;\;t_1\\

\mathbf{elif}\;C \leq 4.615178290867068 \cdot 10^{+256}:\\
\;\;\;\;-0.25 \cdot \left(t_2 \cdot \frac{-1}{-C}\right)\\

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


\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 A (* C -4.0) (* B B)))
        (t_1
         (/
          (- (* (sqrt t_0) (sqrt (* 2.0 (* F (- (+ C A) (hypot B (- A C))))))))
          t_0))
        (t_2 (sqrt (* -16.0 (* C F)))))
   (if (<= C -1.4798890101030842e-202)
     (* -0.25 (/ (* (sqrt (* C -16.0)) (sqrt F)) C))
     (if (<= C 2.3728370555847924e-122)
       t_1
       (if (<= C 9.773045125658437e-20)
         (* -0.25 (/ t_2 C))
         (if (<= C 1.386943960726298)
           t_1
           (if (<= C 4.615178290867068e+256)
             (* -0.25 (* t_2 (/ -1.0 (- C))))
             (* -2.0 (sqrt (* -0.25 (/ F 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 = fma(A, (C * -4.0), (B * B));
	double t_1 = -(sqrt(t_0) * sqrt((2.0 * (F * ((C + A) - hypot(B, (A - C))))))) / t_0;
	double t_2 = sqrt((-16.0 * (C * F)));
	double tmp;
	if (C <= -1.4798890101030842e-202) {
		tmp = -0.25 * ((sqrt((C * -16.0)) * sqrt(F)) / C);
	} else if (C <= 2.3728370555847924e-122) {
		tmp = t_1;
	} else if (C <= 9.773045125658437e-20) {
		tmp = -0.25 * (t_2 / C);
	} else if (C <= 1.386943960726298) {
		tmp = t_1;
	} else if (C <= 4.615178290867068e+256) {
		tmp = -0.25 * (t_2 * (-1.0 / -C));
	} else {
		tmp = -2.0 * sqrt((-0.25 * (F / C)));
	}
	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 < -1.47988901010308422e-202

    1. Initial program 47.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. Simplified41.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. Taylor expanded in A around -inf 45.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\right)}\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \]
    4. Taylor expanded in A around -inf 31.4

      \[\leadsto \color{blue}{-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}} \]
    5. Applied egg-rr25.6

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

    if -1.47988901010308422e-202 < C < 2.3728370555847924e-122 or 9.7730451256584371e-20 < C < 1.3869439607262981

    1. Initial program 45.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. Simplified39.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 egg-rr35.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)}}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \]

    if 2.3728370555847924e-122 < C < 9.7730451256584371e-20

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

      \[\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 47.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(2 \cdot A\right)}\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \]
    4. Taylor expanded in A around -inf 39.7

      \[\leadsto \color{blue}{-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}} \]
    5. Applied egg-rr39.7

      \[\leadsto -0.25 \cdot \color{blue}{{\left(\frac{C}{\sqrt{-16 \cdot \left(C \cdot F\right)}}\right)}^{-1}} \]
    6. Applied egg-rr39.7

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

    if 1.3869439607262981 < C < 4.61517829086706772e256

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

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

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

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

      \[\leadsto -0.25 \cdot \color{blue}{{\left(\frac{C}{\sqrt{-16 \cdot \left(C \cdot F\right)}}\right)}^{-1}} \]
    6. Applied egg-rr38.5

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

    if 4.61517829086706772e256 < 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. Simplified62.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 A around -inf 49.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;C \leq -1.4798890101030842 \cdot 10^{-202}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{C \cdot -16} \cdot \sqrt{F}}{C}\\ \mathbf{elif}\;C \leq 2.3728370555847924 \cdot 10^{-122}:\\ \;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \cdot \sqrt{2 \cdot \left(F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}\\ \mathbf{elif}\;C \leq 9.773045125658437 \cdot 10^{-20}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\ \mathbf{elif}\;C \leq 1.386943960726298:\\ \;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \cdot \sqrt{2 \cdot \left(F \cdot \left(\left(C + A\right) - \mathsf{hypot}\left(B, A - C\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}\\ \mathbf{elif}\;C \leq 4.615178290867068 \cdot 10^{+256}:\\ \;\;\;\;-0.25 \cdot \left(\sqrt{-16 \cdot \left(C \cdot F\right)} \cdot \frac{-1}{-C}\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \sqrt{-0.25 \cdot \frac{F}{C}}\\ \end{array} \]

Reproduce

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