Average Error: 28.9 → 16.8
Time: 1.2m
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 4456.382771474428:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b + \left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}}{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 4456.382771474428:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b + \left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}}{a \cdot 2}\\

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

\end{array}
double f(double a, double b, double c) {
        double r8291157 = b;
        double r8291158 = -r8291157;
        double r8291159 = r8291157 * r8291157;
        double r8291160 = 4.0;
        double r8291161 = a;
        double r8291162 = r8291160 * r8291161;
        double r8291163 = c;
        double r8291164 = r8291162 * r8291163;
        double r8291165 = r8291159 - r8291164;
        double r8291166 = sqrt(r8291165);
        double r8291167 = r8291158 + r8291166;
        double r8291168 = 2.0;
        double r8291169 = r8291168 * r8291161;
        double r8291170 = r8291167 / r8291169;
        return r8291170;
}

double f(double a, double b, double c) {
        double r8291171 = b;
        double r8291172 = 4456.382771474428;
        bool r8291173 = r8291171 <= r8291172;
        double r8291174 = r8291171 * r8291171;
        double r8291175 = 4.0;
        double r8291176 = c;
        double r8291177 = a;
        double r8291178 = r8291176 * r8291177;
        double r8291179 = r8291175 * r8291178;
        double r8291180 = r8291174 - r8291179;
        double r8291181 = sqrt(r8291180);
        double r8291182 = r8291180 * r8291181;
        double r8291183 = r8291174 * r8291171;
        double r8291184 = r8291182 - r8291183;
        double r8291185 = r8291174 + r8291180;
        double r8291186 = r8291171 * r8291181;
        double r8291187 = r8291185 + r8291186;
        double r8291188 = r8291184 / r8291187;
        double r8291189 = 2.0;
        double r8291190 = r8291177 * r8291189;
        double r8291191 = r8291188 / r8291190;
        double r8291192 = r8291176 / r8291171;
        double r8291193 = -r8291192;
        double r8291194 = r8291173 ? r8291191 : r8291193;
        return r8291194;
}

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

    1. Initial program 19.2

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

      \[\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 flip3--19.3

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

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

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

    if 4456.382771474428 < b

    1. Initial program 37.4

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

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

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

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

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

Reproduce

herbie shell --seed 2019125 
(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)))