Average Error: 33.3 → 9.6
Time: 18.4s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.2957079292059776 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 2}{2}\\ \mathbf{elif}\;b \le 3.822016447114454 \cdot 10^{-57}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{b} \cdot -2}{2}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -1.2957079292059776 \cdot 10^{+154}:\\
\;\;\;\;\frac{\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 2}{2}\\

\mathbf{elif}\;b \le 3.822016447114454 \cdot 10^{-57}:\\
\;\;\;\;\frac{\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a}}{2}\\

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

\end{array}
double f(double a, double b, double c) {
        double r841080 = b;
        double r841081 = -r841080;
        double r841082 = r841080 * r841080;
        double r841083 = 4.0;
        double r841084 = a;
        double r841085 = r841083 * r841084;
        double r841086 = c;
        double r841087 = r841085 * r841086;
        double r841088 = r841082 - r841087;
        double r841089 = sqrt(r841088);
        double r841090 = r841081 + r841089;
        double r841091 = 2.0;
        double r841092 = r841091 * r841084;
        double r841093 = r841090 / r841092;
        return r841093;
}

double f(double a, double b, double c) {
        double r841094 = b;
        double r841095 = -1.2957079292059776e+154;
        bool r841096 = r841094 <= r841095;
        double r841097 = c;
        double r841098 = r841097 / r841094;
        double r841099 = a;
        double r841100 = r841094 / r841099;
        double r841101 = r841098 - r841100;
        double r841102 = 2.0;
        double r841103 = r841101 * r841102;
        double r841104 = r841103 / r841102;
        double r841105 = 3.822016447114454e-57;
        bool r841106 = r841094 <= r841105;
        double r841107 = r841094 * r841094;
        double r841108 = 4.0;
        double r841109 = r841097 * r841099;
        double r841110 = r841108 * r841109;
        double r841111 = r841107 - r841110;
        double r841112 = sqrt(r841111);
        double r841113 = r841112 - r841094;
        double r841114 = r841113 / r841099;
        double r841115 = r841114 / r841102;
        double r841116 = -2.0;
        double r841117 = r841098 * r841116;
        double r841118 = r841117 / r841102;
        double r841119 = r841106 ? r841115 : r841118;
        double r841120 = r841096 ? r841104 : r841119;
        return r841120;
}

Error

Bits error versus a

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 3 regimes
  2. if b < -1.2957079292059776e+154

    1. Initial program 60.9

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{2}}\]
    3. Using strategy rm
    4. Applied div-inv60.9

      \[\leadsto \frac{\color{blue}{\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right) \cdot \frac{1}{a}}}{2}\]
    5. Taylor expanded around -inf 1.8

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{c}{b} - 2 \cdot \frac{b}{a}}}{2}\]
    6. Simplified1.8

      \[\leadsto \frac{\color{blue}{\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 2}}{2}\]

    if -1.2957079292059776e+154 < b < 3.822016447114454e-57

    1. Initial program 12.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified12.6

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{2}}\]
    3. Using strategy rm
    4. Applied div-inv12.7

      \[\leadsto \frac{\color{blue}{\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right) \cdot \frac{1}{a}}}{2}\]
    5. Using strategy rm
    6. Applied un-div-inv12.6

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}}{2}\]

    if 3.822016447114454e-57 < b

    1. Initial program 52.9

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{2}}\]
    3. Taylor expanded around inf 8.0

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{c}{b}}}{2}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.2957079292059776 \cdot 10^{+154}:\\ \;\;\;\;\frac{\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 2}{2}\\ \mathbf{elif}\;b \le 3.822016447114454 \cdot 10^{-57}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{b} \cdot -2}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019155 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))