Average Error: 28.7 → 16.3
Time: 20.6s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\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 9131.721195784454:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - c \cdot \left(4 \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}{2}}{a}\\ \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 9131.721195784454:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b - c \cdot \left(4 \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}{2}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r912071 = b;
        double r912072 = -r912071;
        double r912073 = r912071 * r912071;
        double r912074 = 4.0;
        double r912075 = a;
        double r912076 = r912074 * r912075;
        double r912077 = c;
        double r912078 = r912076 * r912077;
        double r912079 = r912073 - r912078;
        double r912080 = sqrt(r912079);
        double r912081 = r912072 + r912080;
        double r912082 = 2.0;
        double r912083 = r912082 * r912075;
        double r912084 = r912081 / r912083;
        return r912084;
}

double f(double a, double b, double c) {
        double r912085 = b;
        double r912086 = 9131.721195784454;
        bool r912087 = r912085 <= r912086;
        double r912088 = r912085 * r912085;
        double r912089 = c;
        double r912090 = 4.0;
        double r912091 = a;
        double r912092 = r912090 * r912091;
        double r912093 = r912089 * r912092;
        double r912094 = r912088 - r912093;
        double r912095 = r912094 - r912088;
        double r912096 = sqrt(r912094);
        double r912097 = r912085 + r912096;
        double r912098 = r912095 / r912097;
        double r912099 = 2.0;
        double r912100 = r912098 / r912099;
        double r912101 = r912100 / r912091;
        double r912102 = r912089 / r912085;
        double r912103 = -r912102;
        double r912104 = r912087 ? r912101 : r912103;
        return r912104;
}

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

    1. Initial program 19.0

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

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

      \[\leadsto \frac{\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}}{a}\]
    5. Simplified18.0

      \[\leadsto \frac{\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}}{a}\]

    if 9131.721195784454 < b

    1. Initial program 38.3

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

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

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

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

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

Reproduce

herbie shell --seed 2019134 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :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)))