Average Error: 32.9 → 10.6
Time: 24.9s
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 -6.1701110130378705 \cdot 10^{+68}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 1.4352467544377554 \cdot 10^{-114}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}} - \frac{b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \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 -6.1701110130378705 \cdot 10^{+68}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r1576202 = b;
        double r1576203 = -r1576202;
        double r1576204 = r1576202 * r1576202;
        double r1576205 = 4.0;
        double r1576206 = a;
        double r1576207 = r1576205 * r1576206;
        double r1576208 = c;
        double r1576209 = r1576207 * r1576208;
        double r1576210 = r1576204 - r1576209;
        double r1576211 = sqrt(r1576210);
        double r1576212 = r1576203 + r1576211;
        double r1576213 = 2.0;
        double r1576214 = r1576213 * r1576206;
        double r1576215 = r1576212 / r1576214;
        return r1576215;
}

double f(double a, double b, double c) {
        double r1576216 = b;
        double r1576217 = -6.1701110130378705e+68;
        bool r1576218 = r1576216 <= r1576217;
        double r1576219 = c;
        double r1576220 = r1576219 / r1576216;
        double r1576221 = a;
        double r1576222 = r1576216 / r1576221;
        double r1576223 = r1576220 - r1576222;
        double r1576224 = 1.4352467544377554e-114;
        bool r1576225 = r1576216 <= r1576224;
        double r1576226 = 1.0;
        double r1576227 = 2.0;
        double r1576228 = r1576221 * r1576227;
        double r1576229 = r1576216 * r1576216;
        double r1576230 = 4.0;
        double r1576231 = r1576219 * r1576221;
        double r1576232 = r1576230 * r1576231;
        double r1576233 = r1576229 - r1576232;
        double r1576234 = sqrt(r1576233);
        double r1576235 = r1576228 / r1576234;
        double r1576236 = r1576226 / r1576235;
        double r1576237 = r1576216 / r1576228;
        double r1576238 = r1576236 - r1576237;
        double r1576239 = -r1576220;
        double r1576240 = r1576225 ? r1576238 : r1576239;
        double r1576241 = r1576218 ? r1576223 : r1576240;
        return r1576241;
}

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 < -6.1701110130378705e+68

    1. Initial program 38.1

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}{2 \cdot a} - \frac{b}{2 \cdot a}\]
    7. Applied associate-/l*38.1

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}} - \frac{b}{2 \cdot a}\]
    8. Using strategy rm
    9. Applied add-sqr-sqrt38.2

      \[\leadsto \frac{1}{\frac{2 \cdot a}{\color{blue}{\sqrt{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}} \cdot \sqrt{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}}} - \frac{b}{2 \cdot a}\]
    10. Applied times-frac38.2

      \[\leadsto \frac{1}{\color{blue}{\frac{2}{\sqrt{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}} \cdot \frac{a}{\sqrt{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}}} - \frac{b}{2 \cdot a}\]
    11. Applied *-un-lft-identity38.2

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{\frac{2}{\sqrt{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}} \cdot \frac{a}{\sqrt{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}} - \frac{b}{2 \cdot a}\]
    12. Applied times-frac38.2

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

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]

    if -6.1701110130378705e+68 < b < 1.4352467544377554e-114

    1. Initial program 12.0

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}}{2 \cdot a} - \frac{b}{2 \cdot a}\]
    7. Applied associate-/l*12.1

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

    if 1.4352467544377554e-114 < b

    1. Initial program 50.9

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    4. Simplified11.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -6.1701110130378705 \cdot 10^{+68}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 1.4352467544377554 \cdot 10^{-114}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 2}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}} - \frac{b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

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