Average Error: 43.8 → 10.0
Time: 44.9s
Precision: 64
\[1.1102230246251565 \cdot 10^{-16} \lt a \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt b \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt c \lt 9007199254740992.0\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -1.503380988770847 \cdot 10^{-06}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right) \cdot \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}, b + \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}, b \cdot b\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}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -1.503380988770847 \cdot 10^{-06}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right) \cdot \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}, b + \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}, b \cdot b\right)}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1499562 = b;
        double r1499563 = -r1499562;
        double r1499564 = r1499562 * r1499562;
        double r1499565 = 4.0;
        double r1499566 = a;
        double r1499567 = r1499565 * r1499566;
        double r1499568 = c;
        double r1499569 = r1499567 * r1499568;
        double r1499570 = r1499564 - r1499569;
        double r1499571 = sqrt(r1499570);
        double r1499572 = r1499563 + r1499571;
        double r1499573 = 2.0;
        double r1499574 = r1499573 * r1499566;
        double r1499575 = r1499572 / r1499574;
        return r1499575;
}

double f(double a, double b, double c) {
        double r1499576 = b;
        double r1499577 = r1499576 * r1499576;
        double r1499578 = 4.0;
        double r1499579 = a;
        double r1499580 = r1499578 * r1499579;
        double r1499581 = c;
        double r1499582 = r1499580 * r1499581;
        double r1499583 = r1499577 - r1499582;
        double r1499584 = sqrt(r1499583);
        double r1499585 = -r1499576;
        double r1499586 = r1499584 + r1499585;
        double r1499587 = 2.0;
        double r1499588 = r1499587 * r1499579;
        double r1499589 = r1499586 / r1499588;
        double r1499590 = -1.503380988770847e-06;
        bool r1499591 = r1499589 <= r1499590;
        double r1499592 = -4.0;
        double r1499593 = r1499581 * r1499579;
        double r1499594 = fma(r1499592, r1499593, r1499577);
        double r1499595 = sqrt(r1499594);
        double r1499596 = r1499594 * r1499595;
        double r1499597 = r1499576 * r1499577;
        double r1499598 = r1499596 - r1499597;
        double r1499599 = r1499576 + r1499595;
        double r1499600 = fma(r1499595, r1499599, r1499577);
        double r1499601 = r1499598 / r1499600;
        double r1499602 = r1499601 / r1499588;
        double r1499603 = r1499581 / r1499576;
        double r1499604 = -r1499603;
        double r1499605 = r1499591 ? r1499602 : r1499604;
        return r1499605;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) < -1.503380988770847e-06

    1. Initial program 21.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip3-+21.5

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

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} \cdot \mathsf{fma}\left(-4, c \cdot a, b \cdot b\right) - b \cdot \left(b \cdot b\right)}}{\left(-b\right) \cdot \left(-b\right) + \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - \left(-b\right) \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}{2 \cdot a}\]
    5. Simplified20.8

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

    if -1.503380988770847e-06 < (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))

    1. Initial program 52.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around inf 5.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -1.503380988770847 \cdot 10^{-06}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right) \cdot \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}, b + \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}, b \cdot b\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019143 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))