Average Error: 43.8 → 11.2
Time: 7.2s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\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 9.210093240442333720544021424814218335086 \cdot 10^{-4}:\\ \;\;\;\;\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 9.210093240442333720544021424814218335086 \cdot 10^{-4}:\\
\;\;\;\;\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 r18807 = b;
        double r18808 = -r18807;
        double r18809 = r18807 * r18807;
        double r18810 = 4.0;
        double r18811 = a;
        double r18812 = r18810 * r18811;
        double r18813 = c;
        double r18814 = r18812 * r18813;
        double r18815 = r18809 - r18814;
        double r18816 = sqrt(r18815);
        double r18817 = r18808 + r18816;
        double r18818 = 2.0;
        double r18819 = r18818 * r18811;
        double r18820 = r18817 / r18819;
        return r18820;
}

double f(double a, double b, double c) {
        double r18821 = b;
        double r18822 = 0.0009210093240442334;
        bool r18823 = r18821 <= r18822;
        double r18824 = r18821 * r18821;
        double r18825 = 4.0;
        double r18826 = a;
        double r18827 = r18825 * r18826;
        double r18828 = c;
        double r18829 = r18827 * r18828;
        double r18830 = r18824 - r18829;
        double r18831 = r18830 - r18824;
        double r18832 = sqrt(r18830);
        double r18833 = r18832 + r18821;
        double r18834 = r18831 / r18833;
        double r18835 = 2.0;
        double r18836 = r18835 * r18826;
        double r18837 = r18834 / r18836;
        double r18838 = -1.0;
        double r18839 = r18828 / r18821;
        double r18840 = r18838 * r18839;
        double r18841 = r18823 ? r18837 : r18840;
        return r18841;
}

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

    1. Initial program 20.3

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

      \[\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.4

      \[\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.4

      \[\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 0.0009210093240442334 < b

    1. Initial program 45.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 9.210093240442333720544021424814218335086 \cdot 10^{-4}:\\ \;\;\;\;\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 2019350 
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))