Average Error: 53.0 → 42.0
Time: 1.0min
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} \mathbf{if}\;A \leq -0.03519957118389417:\\ \;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := \mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)\\ \mathbf{if}\;A \leq -7.136749298156744 \cdot 10^{-75}:\\ \;\;\;\;\begin{array}{l} t_1 := {C}^{2} + {B}^{2}\\ \frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(F \cdot \left(\left(A + \left(C + \sqrt{t_1}\right)\right) - \left(A \cdot C\right) \cdot \sqrt{\frac{1}{t_1}}\right)\right)\right)}}{t_0} \end{array}\\ \mathbf{elif}\;A \leq 1.0029344104796189 \cdot 10^{-196}:\\ \;\;\;\;\begin{array}{l} t_2 := \sqrt{\mathsf{hypot}\left(\sqrt{A \cdot \left(C \cdot -4\right)}, B\right)}\\ -\frac{\sqrt{2} \cdot \sqrt{F \cdot \left(C + \mathsf{hypot}\left(B, C\right)\right)}}{t_2 \cdot t_2} \end{array}\\ \mathbf{elif}\;A \leq 1.20576307541013 \cdot 10^{+208}:\\ \;\;\;\;\frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(F \cdot \left(A + \left(C + \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{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}
\mathbf{if}\;A \leq -0.03519957118389417:\\
\;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}\\

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

\mathbf{elif}\;A \leq 1.0029344104796189 \cdot 10^{-196}:\\
\;\;\;\;\begin{array}{l}
t_2 := \sqrt{\mathsf{hypot}\left(\sqrt{A \cdot \left(C \cdot -4\right)}, B\right)}\\
-\frac{\sqrt{2} \cdot \sqrt{F \cdot \left(C + \mathsf{hypot}\left(B, C\right)\right)}}{t_2 \cdot t_2}
\end{array}\\

\mathbf{elif}\;A \leq 1.20576307541013 \cdot 10^{+208}:\\
\;\;\;\;\frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(F \cdot \left(A + \left(C + \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{t_0}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{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
 (if (<= A -0.03519957118389417)
   (- (* (sqrt 2.0) (sqrt (* -0.5 (/ F A)))))
   (let* ((t_0 (fma A (* C -4.0) (* B B))))
     (if (<= A -7.136749298156744e-75)
       (let* ((t_1 (+ (pow C 2.0) (pow B 2.0))))
         (/
          (-
           (sqrt
            (*
             t_0
             (*
              2.0
              (*
               F
               (- (+ A (+ C (sqrt t_1))) (* (* A C) (sqrt (/ 1.0 t_1)))))))))
          t_0))
       (if (<= A 1.0029344104796189e-196)
         (let* ((t_2 (sqrt (hypot (sqrt (* A (* C -4.0))) B))))
           (- (/ (* (sqrt 2.0) (sqrt (* F (+ C (hypot B C))))) (* t_2 t_2))))
         (if (<= A 1.20576307541013e+208)
           (/
            (- (sqrt (* t_0 (* 2.0 (* F (+ A (+ C (hypot B (- A C)))))))))
            t_0)
           (- (* (sqrt 2.0) (sqrt (* -0.5 (/ 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 tmp;
	if (A <= -0.03519957118389417) {
		tmp = -(sqrt(2.0) * sqrt(-0.5 * (F / A)));
	} else {
		double t_0 = fma(A, (C * -4.0), (B * B));
		double tmp_1;
		if (A <= -7.136749298156744e-75) {
			double t_1_2 = pow(C, 2.0) + pow(B, 2.0);
			tmp_1 = -sqrt(t_0 * (2.0 * (F * ((A + (C + sqrt(t_1_2))) - ((A * C) * sqrt(1.0 / t_1_2)))))) / t_0;
		} else if (A <= 1.0029344104796189e-196) {
			double t_2 = sqrt(hypot(sqrt(A * (C * -4.0)), B));
			tmp_1 = -((sqrt(2.0) * sqrt(F * (C + hypot(B, C)))) / (t_2 * t_2));
		} else if (A <= 1.20576307541013e+208) {
			tmp_1 = -sqrt(t_0 * (2.0 * (F * (A + (C + hypot(B, (A - C))))))) / t_0;
		} else {
			tmp_1 = -(sqrt(2.0) * sqrt(-0.5 * (F / 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 5 regimes
  2. if A < -0.0351995711838941697

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

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

    if -0.0351995711838941697 < A < -7.13674929815674432e-75

    1. Initial program 50.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. Simplified47.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 0 46.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(\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 -7.13674929815674432e-75 < A < 1.00293441047961894e-196

    1. Initial program 49.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. Simplified46.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 add-sqr-sqrt_binary6448.6

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

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

      \[\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_binary6443.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. Simplified42.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 add-sqr-sqrt_binary6442.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{\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}}}} \]
    9. Simplified47.1

      \[\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{\mathsf{hypot}\left(\sqrt{A \cdot \left(C \cdot -4\right)}, B\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}}} \]
    10. Simplified40.4

      \[\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{\mathsf{hypot}\left(\sqrt{A \cdot \left(C \cdot -4\right)}, B\right)} \cdot \color{blue}{\sqrt{\mathsf{hypot}\left(\sqrt{A \cdot \left(C \cdot -4\right)}, B\right)}}} \]
    11. Taylor expanded in A around 0 49.6

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

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

    if 1.00293441047961894e-196 < A < 1.20576307541013e208

    1. Initial program 47.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. Simplified43.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. Applied associate-+l+_binary6442.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(A + \left(C + \mathsf{hypot}\left(B, A - C\right)\right)\right)}\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)} \]

    if 1.20576307541013e208 < A

    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. Simplified55.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 45.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;A \leq -0.03519957118389417:\\ \;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}\\ \mathbf{elif}\;A \leq -7.136749298156744 \cdot 10^{-75}:\\ \;\;\;\;\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(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)}\\ \mathbf{elif}\;A \leq 1.0029344104796189 \cdot 10^{-196}:\\ \;\;\;\;-\frac{\sqrt{2} \cdot \sqrt{F \cdot \left(C + \mathsf{hypot}\left(B, C\right)\right)}}{\sqrt{\mathsf{hypot}\left(\sqrt{A \cdot \left(C \cdot -4\right)}, B\right)} \cdot \sqrt{\mathsf{hypot}\left(\sqrt{A \cdot \left(C \cdot -4\right)}, B\right)}}\\ \mathbf{elif}\;A \leq 1.20576307541013 \cdot 10^{+208}:\\ \;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right) \cdot \left(2 \cdot \left(F \cdot \left(A + \left(C + \mathsf{hypot}\left(B, A - C\right)\right)\right)\right)\right)}}{\mathsf{fma}\left(A, C \cdot -4, B \cdot B\right)}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{C}}\\ \end{array} \]

Reproduce

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