Average Error: 52.3 → 33.1
Time: 42.8s
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)\\ \mathbf{if}\;C \leq -9.383027144283094 \cdot 10^{-186}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{C \cdot -16} \cdot \sqrt{F}}{C}\\ \mathbf{elif}\;C \leq 2.874342306042804 \cdot 10^{-58}:\\ \;\;\;\;\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}\\ \mathbf{elif}\;C \leq 9.739838238220798 \cdot 10^{+53}:\\ \;\;\;\;-0.25 \cdot \left(\frac{1}{C} \cdot \sqrt{-16 \cdot \left(C \cdot F\right)}\right)\\ \mathbf{elif}\;C \leq 8.229399684641769 \cdot 10^{+106}:\\ \;\;\;\;\frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(F \cdot \mathsf{fma}\left(A, 2, -0.5 \cdot \frac{B \cdot B}{C}\right)\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;-0.25 \cdot \frac{{\left(e^{0.25 \cdot \left(\log C + \log \left(-16 \cdot F\right)\right)}\right)}^{2}}{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)\\
\mathbf{if}\;C \leq -9.383027144283094 \cdot 10^{-186}:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{C \cdot -16} \cdot \sqrt{F}}{C}\\

\mathbf{elif}\;C \leq 2.874342306042804 \cdot 10^{-58}:\\
\;\;\;\;\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}\\

\mathbf{elif}\;C \leq 9.739838238220798 \cdot 10^{+53}:\\
\;\;\;\;-0.25 \cdot \left(\frac{1}{C} \cdot \sqrt{-16 \cdot \left(C \cdot F\right)}\right)\\

\mathbf{elif}\;C \leq 8.229399684641769 \cdot 10^{+106}:\\
\;\;\;\;\frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(F \cdot \mathsf{fma}\left(A, 2, -0.5 \cdot \frac{B \cdot B}{C}\right)\right)\right)}}{t_0}\\

\mathbf{else}:\\
\;\;\;\;-0.25 \cdot \frac{{\left(e^{0.25 \cdot \left(\log C + \log \left(-16 \cdot F\right)\right)}\right)}^{2}}{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))))
   (if (<= C -9.383027144283094e-186)
     (* -0.25 (/ (* (sqrt (* C -16.0)) (sqrt F)) C))
     (if (<= C 2.874342306042804e-58)
       (/
        (- (* (sqrt t_0) (sqrt (* 2.0 (* F (- (+ C A) (hypot B (- A C))))))))
        t_0)
       (if (<= C 9.739838238220798e+53)
         (* -0.25 (* (/ 1.0 C) (sqrt (* -16.0 (* C F)))))
         (if (<= C 8.229399684641769e+106)
           (/
            (- (sqrt (* t_0 (* 2.0 (* F (fma A 2.0 (* -0.5 (/ (* B B) C))))))))
            t_0)
           (*
            -0.25
            (/ (pow (exp (* 0.25 (+ (log C) (log (* -16.0 F))))) 2.0) 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 tmp;
	if (C <= -9.383027144283094e-186) {
		tmp = -0.25 * ((sqrt((C * -16.0)) * sqrt(F)) / C);
	} else if (C <= 2.874342306042804e-58) {
		tmp = -(sqrt(t_0) * sqrt((2.0 * (F * ((C + A) - hypot(B, (A - C))))))) / t_0;
	} else if (C <= 9.739838238220798e+53) {
		tmp = -0.25 * ((1.0 / C) * sqrt((-16.0 * (C * F))));
	} else if (C <= 8.229399684641769e+106) {
		tmp = -sqrt((t_0 * (2.0 * (F * fma(A, 2.0, (-0.5 * ((B * B) / C))))))) / t_0;
	} else {
		tmp = -0.25 * (pow(exp((0.25 * (log(C) + log((-16.0 * F))))), 2.0) / 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 < -9.38302714428309379e-186

    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. Simplified43.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 C 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 - 0.5 \cdot \frac{{B}^{2}}{C}\right)}\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \]
    4. Taylor expanded in A around -inf 32.1

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

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

    if -9.38302714428309379e-186 < C < 2.87434230604280395e-58

    1. Initial program 43.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. Simplified38.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. Applied egg-rr34.0

      \[\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.87434230604280395e-58 < C < 9.7398382382207985e53

    1. Initial program 50.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. Simplified48.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 C around inf 45.2

      \[\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. Taylor expanded in A around -inf 37.8

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

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

    if 9.7398382382207985e53 < C < 8.229399684641769e106

    1. Initial program 57.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. Simplified56.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 C around inf 38.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 - 0.5 \cdot \frac{{B}^{2}}{C}\right)}\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \]
    4. Applied egg-rr38.5

      \[\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 \mathsf{fma}\left(A, 2, -0.5 \cdot \frac{B \cdot B}{C}\right)\right)\right)}}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \]

    if 8.229399684641769e106 < C

    1. Initial program 63.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. Simplified62.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 C around inf 42.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 - 0.5 \cdot \frac{{B}^{2}}{C}\right)}\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \]
    4. Taylor expanded in A around -inf 40.5

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

      \[\leadsto -0.25 \cdot \frac{\color{blue}{{\left({\left(-16 \cdot \left(C \cdot F\right)\right)}^{0.25}\right)}^{2}}}{C} \]
    6. Taylor expanded in C around 0 31.8

      \[\leadsto -0.25 \cdot \frac{{\color{blue}{\left(e^{0.25 \cdot \left(\log C + \log \left(-16 \cdot F\right)\right)}\right)}}^{2}}{C} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification33.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;C \leq -9.383027144283094 \cdot 10^{-186}:\\ \;\;\;\;-0.25 \cdot \frac{\sqrt{C \cdot -16} \cdot \sqrt{F}}{C}\\ \mathbf{elif}\;C \leq 2.874342306042804 \cdot 10^{-58}:\\ \;\;\;\;\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.739838238220798 \cdot 10^{+53}:\\ \;\;\;\;-0.25 \cdot \left(\frac{1}{C} \cdot \sqrt{-16 \cdot \left(C \cdot F\right)}\right)\\ \mathbf{elif}\;C \leq 8.229399684641769 \cdot 10^{+106}:\\ \;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right) \cdot \left(2 \cdot \left(F \cdot \mathsf{fma}\left(A, 2, -0.5 \cdot \frac{B \cdot B}{C}\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}\\ \mathbf{else}:\\ \;\;\;\;-0.25 \cdot \frac{{\left(e^{0.25 \cdot \left(\log C + \log \left(-16 \cdot F\right)\right)}\right)}^{2}}{C}\\ \end{array} \]

Reproduce

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