Average Error: 28.5 → 16.6
Time: 11.6s
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 230.5116632738639736999175511300563812256:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\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 230.5116632738639736999175511300563812256:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\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 r30208 = b;
        double r30209 = -r30208;
        double r30210 = r30208 * r30208;
        double r30211 = 4.0;
        double r30212 = a;
        double r30213 = r30211 * r30212;
        double r30214 = c;
        double r30215 = r30213 * r30214;
        double r30216 = r30210 - r30215;
        double r30217 = sqrt(r30216);
        double r30218 = r30209 + r30217;
        double r30219 = 2.0;
        double r30220 = r30219 * r30212;
        double r30221 = r30218 / r30220;
        return r30221;
}

double f(double a, double b, double c) {
        double r30222 = b;
        double r30223 = 230.51166327386397;
        bool r30224 = r30222 <= r30223;
        double r30225 = r30222 * r30222;
        double r30226 = 4.0;
        double r30227 = a;
        double r30228 = r30226 * r30227;
        double r30229 = c;
        double r30230 = r30228 * r30229;
        double r30231 = r30225 - r30230;
        double r30232 = r30231 - r30225;
        double r30233 = sqrt(r30231);
        double r30234 = r30233 + r30222;
        double r30235 = r30232 / r30234;
        double r30236 = 2.0;
        double r30237 = r30236 * r30227;
        double r30238 = r30235 / r30237;
        double r30239 = -1.0;
        double r30240 = r30229 / r30222;
        double r30241 = r30239 * r30240;
        double r30242 = r30224 ? r30238 : r30241;
        return r30242;
}

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 < 230.51166327386397

    1. Initial program 16.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified16.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--16.1

      \[\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. Simplified15.1

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

    if 230.51166327386397 < b

    1. Initial program 34.9

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

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

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity17.5

      \[\leadsto \frac{-2 \cdot \frac{a \cdot c}{\color{blue}{1 \cdot b}}}{2 \cdot a}\]
    6. Applied times-frac17.4

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

      \[\leadsto \frac{-2 \cdot \left(\color{blue}{a} \cdot \frac{c}{b}\right)}{2 \cdot a}\]
    8. Taylor expanded around 0 17.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 230.5116632738639736999175511300563812256:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\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 2019212 
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (< 1.05367121277235087e-8 a 94906265.6242515594) (< 1.05367121277235087e-8 b 94906265.6242515594) (< 1.05367121277235087e-8 c 94906265.6242515594))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))