Average Error: 28.5 → 16.8
Time: 13.0s
Precision: 64
\[1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt a \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt b \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt c \lt 94906265.62425155937671661376953125\]
\[\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 22199.5756480432464741170406341552734375:\\ \;\;\;\;\frac{\frac{\left({b}^{2} - 4 \cdot \left(a \cdot c\right)\right) - b \cdot b}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \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 22199.5756480432464741170406341552734375:\\
\;\;\;\;\frac{\frac{\left({b}^{2} - 4 \cdot \left(a \cdot c\right)\right) - b \cdot b}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r27097 = b;
        double r27098 = -r27097;
        double r27099 = r27097 * r27097;
        double r27100 = 4.0;
        double r27101 = a;
        double r27102 = r27100 * r27101;
        double r27103 = c;
        double r27104 = r27102 * r27103;
        double r27105 = r27099 - r27104;
        double r27106 = sqrt(r27105);
        double r27107 = r27098 + r27106;
        double r27108 = 2.0;
        double r27109 = r27108 * r27101;
        double r27110 = r27107 / r27109;
        return r27110;
}

double f(double a, double b, double c) {
        double r27111 = b;
        double r27112 = 22199.575648043246;
        bool r27113 = r27111 <= r27112;
        double r27114 = 2.0;
        double r27115 = pow(r27111, r27114);
        double r27116 = 4.0;
        double r27117 = a;
        double r27118 = c;
        double r27119 = r27117 * r27118;
        double r27120 = r27116 * r27119;
        double r27121 = r27115 - r27120;
        double r27122 = r27111 * r27111;
        double r27123 = r27121 - r27122;
        double r27124 = r27116 * r27117;
        double r27125 = r27124 * r27118;
        double r27126 = r27122 - r27125;
        double r27127 = sqrt(r27126);
        double r27128 = r27127 + r27111;
        double r27129 = r27123 / r27128;
        double r27130 = 2.0;
        double r27131 = r27130 * r27117;
        double r27132 = r27129 / r27131;
        double r27133 = -1.0;
        double r27134 = r27118 / r27111;
        double r27135 = r27133 * r27134;
        double r27136 = r27113 ? r27132 : r27135;
        return r27136;
}

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 2 regimes
  2. if b < 22199.575648043246

    1. Initial program 20.1

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

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

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

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

    if 22199.575648043246 < b

    1. Initial program 39.0

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

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

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied clear-num14.1

      \[\leadsto \frac{-2 \cdot \color{blue}{\frac{1}{\frac{b}{a \cdot c}}}}{2 \cdot a}\]
    6. Taylor expanded around 0 14.0

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

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

Reproduce

herbie shell --seed 2019325 
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))