Average Error: 29.3 → 16.8
Time: 15.6s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot c}}{2}\]
\[\begin{array}{l} \mathbf{if}\;b \le 9.349379559044902 \cdot 10^{-102}:\\ \;\;\;\;\frac{\sqrt{-4 \cdot c + b \cdot b} - b}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-4 \cdot c}{\sqrt{-4 \cdot c + b \cdot b} + b}}{2}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot c}}{2}
\begin{array}{l}
\mathbf{if}\;b \le 9.349379559044902 \cdot 10^{-102}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot c + b \cdot b} - b}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{-4 \cdot c}{\sqrt{-4 \cdot c + b \cdot b} + b}}{2}\\

\end{array}
double f(double b, double c) {
        double r6670084 = b;
        double r6670085 = -r6670084;
        double r6670086 = 2.0;
        double r6670087 = pow(r6670084, r6670086);
        double r6670088 = 4.0;
        double r6670089 = c;
        double r6670090 = r6670088 * r6670089;
        double r6670091 = r6670087 - r6670090;
        double r6670092 = sqrt(r6670091);
        double r6670093 = r6670085 + r6670092;
        double r6670094 = r6670093 / r6670086;
        return r6670094;
}

double f(double b, double c) {
        double r6670095 = b;
        double r6670096 = 9.349379559044902e-102;
        bool r6670097 = r6670095 <= r6670096;
        double r6670098 = -4.0;
        double r6670099 = c;
        double r6670100 = r6670098 * r6670099;
        double r6670101 = r6670095 * r6670095;
        double r6670102 = r6670100 + r6670101;
        double r6670103 = sqrt(r6670102);
        double r6670104 = r6670103 - r6670095;
        double r6670105 = 2.0;
        double r6670106 = r6670104 / r6670105;
        double r6670107 = r6670103 + r6670095;
        double r6670108 = r6670100 / r6670107;
        double r6670109 = r6670108 / r6670105;
        double r6670110 = r6670097 ? r6670106 : r6670109;
        return r6670110;
}

Error

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if b < 9.349379559044902e-102

    1. Initial program 16.7

      \[\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot c}}{2}\]
    2. Simplified16.7

      \[\leadsto \color{blue}{\frac{\sqrt{-4 \cdot c + b \cdot b} - b}{2}}\]

    if 9.349379559044902e-102 < b

    1. Initial program 48.9

      \[\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot c}}{2}\]
    2. Simplified48.9

      \[\leadsto \color{blue}{\frac{\sqrt{-4 \cdot c + b \cdot b} - b}{2}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt48.9

      \[\leadsto \frac{\sqrt{\color{blue}{\sqrt{-4 \cdot c + b \cdot b} \cdot \sqrt{-4 \cdot c + b \cdot b}}} - b}{2}\]
    5. Applied sqrt-prod50.9

      \[\leadsto \frac{\color{blue}{\sqrt{\sqrt{-4 \cdot c + b \cdot b}} \cdot \sqrt{\sqrt{-4 \cdot c + b \cdot b}}} - b}{2}\]
    6. Using strategy rm
    7. Applied flip--50.9

      \[\leadsto \frac{\color{blue}{\frac{\left(\sqrt{\sqrt{-4 \cdot c + b \cdot b}} \cdot \sqrt{\sqrt{-4 \cdot c + b \cdot b}}\right) \cdot \left(\sqrt{\sqrt{-4 \cdot c + b \cdot b}} \cdot \sqrt{\sqrt{-4 \cdot c + b \cdot b}}\right) - b \cdot b}{\sqrt{\sqrt{-4 \cdot c + b \cdot b}} \cdot \sqrt{\sqrt{-4 \cdot c + b \cdot b}} + b}}}{2}\]
    8. Simplified17.0

      \[\leadsto \frac{\frac{\color{blue}{c \cdot -4}}{\sqrt{\sqrt{-4 \cdot c + b \cdot b}} \cdot \sqrt{\sqrt{-4 \cdot c + b \cdot b}} + b}}{2}\]
    9. Simplified16.8

      \[\leadsto \frac{\frac{c \cdot -4}{\color{blue}{b + \sqrt{c \cdot -4 + b \cdot b}}}}{2}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification16.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 9.349379559044902 \cdot 10^{-102}:\\ \;\;\;\;\frac{\sqrt{-4 \cdot c + b \cdot b} - b}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-4 \cdot c}{\sqrt{-4 \cdot c + b \cdot b} + b}}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (b c)
  :name "(-b+sqrt(b^2-4*c))/(2)"
  (/ (+ (- b) (sqrt (- (pow b 2) (* 4 c)))) 2))