Average Error: 28.7 → 16.3
Time: 17.3s
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{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}}{2 \cdot 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{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1201738 = b;
        double r1201739 = -r1201738;
        double r1201740 = r1201738 * r1201738;
        double r1201741 = 4.0;
        double r1201742 = a;
        double r1201743 = r1201741 * r1201742;
        double r1201744 = c;
        double r1201745 = r1201743 * r1201744;
        double r1201746 = r1201740 - r1201745;
        double r1201747 = sqrt(r1201746);
        double r1201748 = r1201739 + r1201747;
        double r1201749 = 2.0;
        double r1201750 = r1201749 * r1201742;
        double r1201751 = r1201748 / r1201750;
        return r1201751;
}

double f(double a, double b, double c) {
        double r1201752 = b;
        double r1201753 = 9131.721195784454;
        bool r1201754 = r1201752 <= r1201753;
        double r1201755 = r1201752 * r1201752;
        double r1201756 = 4.0;
        double r1201757 = c;
        double r1201758 = a;
        double r1201759 = r1201757 * r1201758;
        double r1201760 = r1201756 * r1201759;
        double r1201761 = r1201755 - r1201760;
        double r1201762 = r1201761 - r1201755;
        double r1201763 = sqrt(r1201761);
        double r1201764 = r1201752 + r1201763;
        double r1201765 = r1201762 / r1201764;
        double r1201766 = 2.0;
        double r1201767 = r1201766 * r1201758;
        double r1201768 = r1201765 / r1201767;
        double r1201769 = -r1201757;
        double r1201770 = r1201769 / r1201752;
        double r1201771 = r1201754 ? r1201768 : r1201770;
        return r1201771;
}

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{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip--19.0

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

      \[\leadsto \frac{\frac{\color{blue}{\left(b \cdot b - \left(c \cdot a\right) \cdot 4\right) - b \cdot b}}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}}{2 \cdot 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{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}}\]
    3. Taylor expanded around inf 14.7

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied associate-/l*14.8

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    7. 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{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}\]

Reproduce

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