Average Error: 52.5 → 31.0
Time: 29.6s
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} \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.1357925545184748 \cdot 10^{-225}:\\ \;\;\;\;\frac{-\sqrt{2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}}}{{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:\\ \;\;\;\;-\sqrt{\sqrt{F}} \cdot \sqrt{-\frac{\sqrt{F}}{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 \infty:\\ \;\;\;\;\frac{-\left(C \cdot \left(\sqrt{2} \cdot \sqrt{\left(A \cdot F\right) \cdot -8}\right) + \frac{\left(B \cdot B\right) \cdot \left(F \cdot \sqrt{2}\right)}{\sqrt{\left(A \cdot F\right) \cdot -8}}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{F} \cdot \sqrt{\frac{-1}{A}}\\ \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}\;\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.1357925545184748 \cdot 10^{-225}:\\
\;\;\;\;\frac{-\sqrt{2 \cdot \left(\left({B}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)} \cdot \sqrt{\left(A + C\right) + \sqrt{{B}^{2} + {\left(A - C\right)}^{2}}}}{{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:\\
\;\;\;\;-\sqrt{\sqrt{F}} \cdot \sqrt{-\frac{\sqrt{F}}{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 \infty:\\
\;\;\;\;\frac{-\left(C \cdot \left(\sqrt{2} \cdot \sqrt{\left(A \cdot F\right) \cdot -8}\right) + \frac{\left(B \cdot B\right) \cdot \left(F \cdot \sqrt{2}\right)}{\sqrt{\left(A \cdot F\right) \cdot -8}}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\

\mathbf{else}:\\
\;\;\;\;-\sqrt{F} \cdot \sqrt{\frac{-1}{A}}\\

\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 (<=
      (/
       (-
        (sqrt
         (*
          (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F))
          (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
       (- (pow B 2.0) (* (* 4.0 A) C)))
      (- INFINITY))
   (- (* (sqrt F) (sqrt (/ -1.0 A))))
   (if (<=
        (/
         (-
          (sqrt
           (*
            (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F))
            (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
         (- (pow B 2.0) (* (* 4.0 A) C)))
        -1.1357925545184748e-225)
     (/
      (-
       (*
        (sqrt (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)))
        (sqrt (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
      (- (pow B 2.0) (* (* 4.0 A) C)))
     (if (<=
          (/
           (-
            (sqrt
             (*
              (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F))
              (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
           (- (pow B 2.0) (* (* 4.0 A) C)))
          0.0)
       (- (* (sqrt (sqrt F)) (sqrt (- (/ (sqrt F) A)))))
       (if (<=
            (/
             (-
              (sqrt
               (*
                (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F))
                (+ (+ A C) (sqrt (+ (pow B 2.0) (pow (- A C) 2.0)))))))
             (- (pow B 2.0) (* (* 4.0 A) C)))
            INFINITY)
         (/
          (-
           (+
            (* C (* (sqrt 2.0) (sqrt (* (* A F) -8.0))))
            (/ (* (* B B) (* F (sqrt 2.0))) (sqrt (* (* A F) -8.0)))))
          (- (pow B 2.0) (* (* 4.0 A) C)))
         (- (* (sqrt F) (sqrt (/ -1.0 A)))))))))
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 ((-sqrt((2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * ((A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C))) <= -((double) INFINITY)) {
		tmp = -(sqrt(F) * sqrt(-1.0 / A));
	} else if ((-sqrt((2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * ((A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C))) <= -1.1357925545184748e-225) {
		tmp = -(sqrt(2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * sqrt((A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C));
	} else if ((-sqrt((2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * ((A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C))) <= 0.0) {
		tmp = -(sqrt(sqrt(F)) * sqrt(-(sqrt(F) / A)));
	} else if ((-sqrt((2.0 * ((pow(B, 2.0) - ((4.0 * A) * C)) * F)) * ((A + C) + sqrt(pow(B, 2.0) + pow((A - C), 2.0)))) / (pow(B, 2.0) - ((4.0 * A) * C))) <= ((double) INFINITY)) {
		tmp = -((C * (sqrt(2.0) * sqrt((A * F) * -8.0))) + (((B * B) * (F * sqrt(2.0))) / sqrt((A * F) * -8.0))) / (pow(B, 2.0) - ((4.0 * A) * C));
	} else {
		tmp = -(sqrt(F) * sqrt(-1.0 / A));
	}
	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 4 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 +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 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. Taylor expanded around inf 47.2

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

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

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

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

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

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

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

      \[\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.13579255451847484e-225

    1. Initial program 1.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. Using strategy rm
    3. Applied sqrt-prod_binary64_35041.3

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

    if -1.13579255451847484e-225 < (/.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

    1. Initial program 61.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. Taylor expanded around inf 32.9

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

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

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

      \[\leadsto -\sqrt{\color{blue}{-\frac{F}{A}}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity_binary64_348832.7

      \[\leadsto -\sqrt{-\frac{F}{\color{blue}{1 \cdot A}}}\]
    9. Applied add-sqr-sqrt_binary64_351032.8

      \[\leadsto -\sqrt{-\frac{\color{blue}{\sqrt{F} \cdot \sqrt{F}}}{1 \cdot A}}\]
    10. Applied times-frac_binary64_349432.8

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

      \[\leadsto -\sqrt{\color{blue}{\frac{\sqrt{F}}{1} \cdot \left(-\frac{\sqrt{F}}{A}\right)}}\]
    12. Applied sqrt-prod_binary64_350428.7

      \[\leadsto -\color{blue}{\sqrt{\frac{\sqrt{F}}{1}} \cdot \sqrt{-\frac{\sqrt{F}}{A}}}\]
    13. Simplified28.7

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

    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 39.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. Taylor expanded around inf 15.1

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

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

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

Reproduce

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