Average Error: 52.5 → 30.9
Time: 20.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} \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 -4.363331496186755 \cdot 10^{+189}:\\ \;\;\;\;-\frac{\sqrt{-F}}{\sqrt{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 -1.3291605124856879 \cdot 10^{-210}:\\ \;\;\;\;\frac{-1}{\frac{B \cdot B - 4 \cdot \left(A \cdot C\right)}{\sqrt{\left(2 \cdot \left(F \cdot \left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right)\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + B \cdot B}\right)}}}\\ \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:\\ \;\;\;\;\left(\sqrt{2} \cdot \sqrt{F \cdot -0.5}\right) \cdot \frac{-1}{\sqrt{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 \infty:\\ \;\;\;\;\frac{\sqrt{-8 \cdot \left(C \cdot F\right)} \cdot \left(A \cdot \sqrt{2}\right) + \frac{{B}^{2} \cdot \left(F \cdot \sqrt{2}\right)}{\sqrt{-8 \cdot \left(C \cdot F\right)}}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\ \mathbf{else}:\\ \;\;\;\;-\frac{\sqrt{-F}}{\sqrt{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}
\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 -4.363331496186755 \cdot 10^{+189}:\\
\;\;\;\;-\frac{\sqrt{-F}}{\sqrt{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 -1.3291605124856879 \cdot 10^{-210}:\\
\;\;\;\;\frac{-1}{\frac{B \cdot B - 4 \cdot \left(A \cdot C\right)}{\sqrt{\left(2 \cdot \left(F \cdot \left(B \cdot B - 4 \cdot \left(A \cdot C\right)\right)\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + B \cdot B}\right)}}}\\

\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:\\
\;\;\;\;\left(\sqrt{2} \cdot \sqrt{F \cdot -0.5}\right) \cdot \frac{-1}{\sqrt{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 \infty:\\
\;\;\;\;\frac{\sqrt{-8 \cdot \left(C \cdot F\right)} \cdot \left(A \cdot \sqrt{2}\right) + \frac{{B}^{2} \cdot \left(F \cdot \sqrt{2}\right)}{\sqrt{-8 \cdot \left(C \cdot F\right)}}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\

\mathbf{else}:\\
\;\;\;\;-\frac{\sqrt{-F}}{\sqrt{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
 (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)))
      -4.363331496186755e+189)
   (- (/ (sqrt (- F)) (sqrt 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)))
        -1.3291605124856879e-210)
     (/
      -1.0
      (/
       (- (* B B) (* 4.0 (* A C)))
       (sqrt
        (*
         (* 2.0 (* F (- (* B B) (* 4.0 (* A C)))))
         (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (* B B))))))))
     (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 2.0) (sqrt (* F -0.5))) (/ -1.0 (sqrt 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)))
            INFINITY)
         (/
          (+
           (* (sqrt (* -8.0 (* C F))) (* A (sqrt 2.0)))
           (/ (* (pow B 2.0) (* F (sqrt 2.0))) (sqrt (* -8.0 (* C F)))))
          (- (pow B 2.0) (* (* 4.0 A) C)))
         (- (/ (sqrt (- F)) (sqrt 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 ((-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))) <= -4.363331496186755e+189) {
		tmp = -(sqrt(-F) / sqrt(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))) <= -1.3291605124856879e-210) {
		tmp = -1.0 / (((B * B) - (4.0 * (A * C))) / sqrt((2.0 * (F * ((B * B) - (4.0 * (A * C))))) * ((A + C) - sqrt(pow((A - C), 2.0) + (B * B)))));
	} 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(2.0) * sqrt(F * -0.5)) * (-1.0 / sqrt(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))) <= ((double) INFINITY)) {
		tmp = ((sqrt(-8.0 * (C * F)) * (A * sqrt(2.0))) + ((pow(B, 2.0) * (F * sqrt(2.0))) / sqrt(-8.0 * (C * F)))) / (pow(B, 2.0) - ((4.0 * A) * C));
	} else {
		tmp = -(sqrt(-F) / sqrt(C));
	}
	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))) < -4.36333149618675521e189 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.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. Taylor expanded around -inf 46.5

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

      \[\leadsto \color{blue}{-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{C}}}\]
    4. Using strategy rm
    5. Applied associate-*r/_binary6446.5

      \[\leadsto -\sqrt{2} \cdot \sqrt{\color{blue}{\frac{-0.5 \cdot F}{C}}}\]
    6. Applied sqrt-div_binary6440.1

      \[\leadsto -\sqrt{2} \cdot \color{blue}{\frac{\sqrt{-0.5 \cdot F}}{\sqrt{C}}}\]
    7. Applied associate-*r/_binary6440.1

      \[\leadsto -\color{blue}{\frac{\sqrt{2} \cdot \sqrt{-0.5 \cdot F}}{\sqrt{C}}}\]
    8. Simplified40.1

      \[\leadsto -\frac{\color{blue}{\sqrt{2} \cdot \sqrt{F \cdot -0.5}}}{\sqrt{C}}\]
    9. Using strategy rm
    10. Applied sqrt-unprod_binary6440.0

      \[\leadsto -\frac{\color{blue}{\sqrt{2 \cdot \left(F \cdot -0.5\right)}}}{\sqrt{C}}\]
    11. Simplified40.0

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

    if -4.36333149618675521e189 < (/.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.32916051248568789e-210

    1. Initial program 1.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. Using strategy rm
    3. Applied neg-mul-1_binary641.6

      \[\leadsto \frac{\color{blue}{-1 \cdot \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}\]
    4. Applied associate-/l*_binary641.7

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

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

    if -1.32916051248568789e-210 < (/.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.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. Taylor expanded around -inf 31.1

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

      \[\leadsto \color{blue}{-\sqrt{2} \cdot \sqrt{-0.5 \cdot \frac{F}{C}}}\]
    4. Using strategy rm
    5. Applied associate-*r/_binary6431.1

      \[\leadsto -\sqrt{2} \cdot \sqrt{\color{blue}{\frac{-0.5 \cdot F}{C}}}\]
    6. Applied sqrt-div_binary6427.5

      \[\leadsto -\sqrt{2} \cdot \color{blue}{\frac{\sqrt{-0.5 \cdot F}}{\sqrt{C}}}\]
    7. Applied associate-*r/_binary6427.5

      \[\leadsto -\color{blue}{\frac{\sqrt{2} \cdot \sqrt{-0.5 \cdot F}}{\sqrt{C}}}\]
    8. Simplified27.5

      \[\leadsto -\frac{\color{blue}{\sqrt{2} \cdot \sqrt{F \cdot -0.5}}}{\sqrt{C}}\]
    9. Using strategy rm
    10. Applied div-inv_binary6427.5

      \[\leadsto -\color{blue}{\left(\sqrt{2} \cdot \sqrt{F \cdot -0.5}\right) \cdot \frac{1}{\sqrt{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 39.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. Taylor expanded around -inf 15.6

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

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

Alternatives

Reproduce

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