Average Error: 28.6 → 16.8
Time: 36.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 91.36334998724752:\\ \;\;\;\;\frac{\frac{\frac{\mathsf{fma}\left(b, b, \left(c \cdot \left(-4 \cdot a\right)\right)\right) - b \cdot b}{b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot \left(-4 \cdot a\right)\right)\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 91.36334998724752:\\
\;\;\;\;\frac{\frac{\frac{\mathsf{fma}\left(b, b, \left(c \cdot \left(-4 \cdot a\right)\right)\right) - b \cdot b}{b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot \left(-4 \cdot a\right)\right)\right)}}}{2}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1309637 = b;
        double r1309638 = -r1309637;
        double r1309639 = r1309637 * r1309637;
        double r1309640 = 4.0;
        double r1309641 = a;
        double r1309642 = r1309640 * r1309641;
        double r1309643 = c;
        double r1309644 = r1309642 * r1309643;
        double r1309645 = r1309639 - r1309644;
        double r1309646 = sqrt(r1309645);
        double r1309647 = r1309638 + r1309646;
        double r1309648 = 2.0;
        double r1309649 = r1309648 * r1309641;
        double r1309650 = r1309647 / r1309649;
        return r1309650;
}

double f(double a, double b, double c) {
        double r1309651 = b;
        double r1309652 = 91.36334998724752;
        bool r1309653 = r1309651 <= r1309652;
        double r1309654 = c;
        double r1309655 = -4.0;
        double r1309656 = a;
        double r1309657 = r1309655 * r1309656;
        double r1309658 = r1309654 * r1309657;
        double r1309659 = fma(r1309651, r1309651, r1309658);
        double r1309660 = r1309651 * r1309651;
        double r1309661 = r1309659 - r1309660;
        double r1309662 = sqrt(r1309659);
        double r1309663 = r1309651 + r1309662;
        double r1309664 = r1309661 / r1309663;
        double r1309665 = 2.0;
        double r1309666 = r1309664 / r1309665;
        double r1309667 = r1309666 / r1309656;
        double r1309668 = -r1309654;
        double r1309669 = r1309668 / r1309651;
        double r1309670 = r1309653 ? r1309667 : r1309669;
        return r1309670;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 91.36334998724752

    1. Initial program 15.2

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

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

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

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

    if 91.36334998724752 < b

    1. Initial program 34.2

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

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

      \[\leadsto \frac{\frac{\color{blue}{-2 \cdot \frac{a \cdot c}{b}}}{2}}{a}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity17.9

      \[\leadsto \frac{\frac{-2 \cdot \frac{a \cdot c}{b}}{\color{blue}{1 \cdot 2}}}{a}\]
    6. Applied times-frac17.9

      \[\leadsto \frac{\color{blue}{\frac{-2}{1} \cdot \frac{\frac{a \cdot c}{b}}{2}}}{a}\]
    7. Applied associate-/l*17.9

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    9. Simplified17.8

      \[\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 91.36334998724752:\\ \;\;\;\;\frac{\frac{\frac{\mathsf{fma}\left(b, b, \left(c \cdot \left(-4 \cdot a\right)\right)\right) - b \cdot b}{b + \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot \left(-4 \cdot a\right)\right)\right)}}}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019128 +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)))