Average Error: 52.0 → 30.3
Time: 22.3s
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 \sqrt{\frac{-1}{A}}\\ 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 -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_3 \leq -1.0680617888819873 \cdot 10^{-199}:\\ \;\;\;\;\frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(F \cdot \left(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}:\\ \;\;\;\;\begin{array}{l} t_4 := \sqrt{-8 \cdot \left(A \cdot F\right)}\\ \frac{-\left(\left(C \cdot \sqrt{2}\right) \cdot t_4 + \frac{F \cdot \left(\left(B \cdot B\right) \cdot \sqrt{2}\right)}{t_4}\right)}{t_2} \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 := \left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\\
t_1 := -\sqrt{F} \cdot \sqrt{\frac{-1}{A}}\\
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 -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_3 \leq -1.0680617888819873 \cdot 10^{-199}:\\
\;\;\;\;\frac{-\sqrt{t_0 \cdot \left(2 \cdot \left(F \cdot \left(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}:\\
\;\;\;\;\begin{array}{l}
t_4 := \sqrt{-8 \cdot \left(A \cdot F\right)}\\
\frac{-\left(\left(C \cdot \sqrt{2}\right) \cdot t_4 + \frac{F \cdot \left(\left(B \cdot B\right) \cdot \sqrt{2}\right)}{t_4}\right)}{t_2}
\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 (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))
        (t_1 (- (* (sqrt F) (sqrt (/ -1.0 A)))))
        (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 (- INFINITY))
     t_1
     (if (<= t_3 -1.0680617888819873e-199)
       (/ (- (sqrt (* t_0 (* 2.0 (* F (- (* B B) (* 4.0 (* A C)))))))) t_2)
       (if (or (<= t_3 0.0) (not (<= t_3 INFINITY)))
         t_1
         (let* ((t_4 (sqrt (* -8.0 (* A F)))))
           (/
            (-
             (+ (* (* C (sqrt 2.0)) t_4) (/ (* F (* (* B B) (sqrt 2.0))) t_4)))
            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) * sqrt(-1.0 / A));
	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 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_3 <= -1.0680617888819873e-199) {
		tmp = -sqrt(t_0 * (2.0 * (F * ((B * B) - (4.0 * (A * C)))))) / t_2;
	} else if ((t_3 <= 0.0) || !(t_3 <= ((double) INFINITY))) {
		tmp = t_1;
	} else {
		double t_4 = sqrt(-8.0 * (A * F));
		tmp = -(((C * sqrt(2.0)) * t_4) + ((F * ((B * B) * sqrt(2.0))) / t_4)) / 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))) < -inf.0 or -1.0680617888819873e-199 < (/.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 63.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 43.3

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

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

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

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

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

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

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

      \[\leadsto -\sqrt{F} \cdot \color{blue}{\sqrt{\frac{-1}{A}}} \]

    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.0680617888819873e-199

    1. Initial program 1.5

      \[\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 *-un-lft-identity_binary641.5

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

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

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

    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 37.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. Taylor expanded around inf 16.9

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

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

    \[\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 -\infty:\\ \;\;\;\;-\sqrt{F} \cdot \sqrt{\frac{-1}{A}}\\ \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.0680617888819873 \cdot 10^{-199}:\\ \;\;\;\;\frac{-\sqrt{\left(\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}\right) \cdot \left(2 \cdot \left(F \cdot \left(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 \sqrt{\frac{-1}{A}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\left(\left(C \cdot \sqrt{2}\right) \cdot \sqrt{-8 \cdot \left(A \cdot F\right)} + \frac{F \cdot \left(\left(B \cdot B\right) \cdot \sqrt{2}\right)}{\sqrt{-8 \cdot \left(A \cdot F\right)}}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\ \end{array} \]

Reproduce

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