Average Error: 52.5 → 31.1
Time: 19.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 := \left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\\ t_1 := -\sqrt{F} \cdot {\left(\frac{-1}{A}\right)}^{0.5}\\ t_2 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\ t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot t_0}}{t_2}\\ \mathbf{if}\;t_3 \leq -3.821865190877986 \cdot 10^{+232}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_3 \leq -4.885000933447799 \cdot 10^{-179}:\\ \;\;\;\;\frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(\sqrt{t_2} \cdot \left(F \cdot \sqrt{B \cdot B - 4 \cdot \left(A \cdot C\right)}\right)\right)\right)}}{t_2}\\ \mathbf{elif}\;t_3 \leq 0 \lor \neg \left(t_3 \leq \infty\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{-\left(C \cdot \sqrt{2}\right) \cdot \sqrt{-8 \cdot \left(A \cdot F\right)}}{t_2}\\ \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 := \left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\\
t_1 := -\sqrt{F} \cdot {\left(\frac{-1}{A}\right)}^{0.5}\\
t_2 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t_2 \cdot F\right)\right) \cdot t_0}}{t_2}\\
\mathbf{if}\;t_3 \leq -3.821865190877986 \cdot 10^{+232}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_3 \leq -4.885000933447799 \cdot 10^{-179}:\\
\;\;\;\;\frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(\sqrt{t_2} \cdot \left(F \cdot \sqrt{B \cdot B - 4 \cdot \left(A \cdot C\right)}\right)\right)\right)}}{t_2}\\

\mathbf{elif}\;t_3 \leq 0 \lor \neg \left(t_3 \leq \infty\right):\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\frac{-\left(C \cdot \sqrt{2}\right) \cdot \sqrt{-8 \cdot \left(A \cdot F\right)}}{t_2}\\


\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 (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))
        (t_1 (- (* (sqrt F) (pow (/ -1.0 A) 0.5))))
        (t_2 (- (pow B 2.0) (* (* 4.0 A) C)))
        (t_3 (/ (- (sqrt (* (* 2.0 (* t_2 F)) t_0))) t_2)))
   (if (<= t_3 -3.821865190877986e+232)
     t_1
     (if (<= t_3 -4.885000933447799e-179)
       (/
        (-
         (sqrt
          (*
           t_0
           (* 2.0 (* (sqrt t_2) (* F (sqrt (- (* B B) (* 4.0 (* A C))))))))))
        t_2)
       (if (or (<= t_3 0.0) (not (<= t_3 INFINITY)))
         t_1
         (/ (- (* (* C (sqrt 2.0)) (sqrt (* -8.0 (* A F))))) t_2))))))
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 = (A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0));
	double t_1 = -(sqrt(F) * pow((-1.0 / A), 0.5));
	double t_2 = pow(B, 2.0) - ((4.0 * A) * C);
	double t_3 = -sqrt((2.0 * (t_2 * F)) * t_0) / t_2;
	double tmp;
	if (t_3 <= -3.821865190877986e+232) {
		tmp = t_1;
	} else if (t_3 <= -4.885000933447799e-179) {
		tmp = -sqrt(t_0 * (2.0 * (sqrt(t_2) * (F * sqrt((B * B) - (4.0 * (A * C))))))) / t_2;
	} else if ((t_3 <= 0.0) || !(t_3 <= ((double) INFINITY))) {
		tmp = t_1;
	} else {
		tmp = -((C * sqrt(2.0)) * sqrt(-8.0 * (A * F))) / t_2;
	}
	return tmp;
}

Error

Bits error versus A

Bits error versus B

Bits error versus C

Bits error versus F

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 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))) < -3.82186519087798615e232 or -4.8850009334477987e-179 < (/.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 or +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 62.8

      \[\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. Taylor expanded around inf 44.2

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

      \[\leadsto \color{blue}{-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{A}}} \]
    4. Using strategy rm
    5. Applied sqrt-unprod_binary6444.1

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

      \[\leadsto -\sqrt{\color{blue}{-\frac{F}{A}}} \]
    7. Using strategy rm
    8. Applied div-inv_binary6444.1

      \[\leadsto -\sqrt{-\color{blue}{F \cdot \frac{1}{A}}} \]
    9. Applied distribute-rgt-neg-in_binary6444.1

      \[\leadsto -\sqrt{\color{blue}{F \cdot \left(-\frac{1}{A}\right)}} \]
    10. Applied sqrt-prod_binary6438.0

      \[\leadsto -\color{blue}{\sqrt{F} \cdot \sqrt{-\frac{1}{A}}} \]
    11. Simplified38.0

      \[\leadsto -\sqrt{F} \cdot \color{blue}{\sqrt{\frac{-1}{A}}} \]
    12. Using strategy rm
    13. Applied pow1_binary6438.0

      \[\leadsto -\sqrt{F} \cdot \sqrt{\color{blue}{{\left(\frac{-1}{A}\right)}^{1}}} \]
    14. Applied sqrt-pow1_binary6438.0

      \[\leadsto -\sqrt{F} \cdot \color{blue}{{\left(\frac{-1}{A}\right)}^{\left(\frac{1}{2}\right)}} \]
    15. Simplified38.0

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

    if -3.82186519087798615e232 < (/.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.8850009334477987e-179

    1. Initial program 1.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. Using strategy rm
    3. Applied add-sqr-sqrt_binary641.3

      \[\leadsto \frac{-\sqrt{\left(2 \cdot \left(\color{blue}{\left(\sqrt{{B}^{2} - \left(4 \cdot A\right) \cdot C} \cdot \sqrt{{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} \]
    4. Applied associate-*l*_binary641.3

      \[\leadsto \frac{-\sqrt{\left(2 \cdot \color{blue}{\left(\sqrt{{B}^{2} - \left(4 \cdot A\right) \cdot C} \cdot \left(\sqrt{{B}^{2} - \left(4 \cdot A\right) \cdot C} \cdot F\right)\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} \]
    5. Simplified1.3

      \[\leadsto \frac{-\sqrt{\left(2 \cdot \left(\sqrt{{B}^{2} - \left(4 \cdot A\right) \cdot C} \cdot \color{blue}{\left(F \cdot \sqrt{B \cdot B - \left(C \cdot A\right) \cdot 4}\right)}\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} \]

    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 38.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. Taylor expanded around inf 15.7

      \[\leadsto \frac{-\color{blue}{\sqrt{-8 \cdot \left(A \cdot F\right)} \cdot \left(C \cdot \sqrt{2}\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
    3. Simplified15.7

      \[\leadsto \frac{-\color{blue}{\left(C \cdot \sqrt{2}\right) \cdot \sqrt{-8 \cdot \left(A \cdot F\right)}}}{{B}^{2} - \left(4 \cdot A\right) \cdot C} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification31.1

    \[\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 -3.821865190877986 \cdot 10^{+232}:\\ \;\;\;\;-\sqrt{F} \cdot {\left(\frac{-1}{A}\right)}^{0.5}\\ \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 -4.885000933447799 \cdot 10^{-179}:\\ \;\;\;\;\frac{-\sqrt{\left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right) \cdot \left(2 \cdot \left(\sqrt{{B}^{2} - \left(4 \cdot A\right) \cdot C} \cdot \left(F \cdot \sqrt{B \cdot B - 4 \cdot \left(A \cdot C\right)}\right)\right)\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\ \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 \lor \neg \left(\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\right):\\ \;\;\;\;-\sqrt{F} \cdot {\left(\frac{-1}{A}\right)}^{0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\left(C \cdot \sqrt{2}\right) \cdot \sqrt{-8 \cdot \left(A \cdot F\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\ \end{array} \]

Reproduce

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