Average Error: 19.0 → 12.7
Time: 32.3s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le 1.673041355293174 \cdot 10^{+137}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\left(\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{-\left(b + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

\end{array}
\begin{array}{l}
\mathbf{if}\;b \le 1.673041355293174 \cdot 10^{+137}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\left(\sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, a \cdot c, b \cdot b\right)}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\

\end{array}\\

\mathbf{elif}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{-\left(b + b\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\

\end{array}
double f(double a, double b, double c) {
        double r1052636 = b;
        double r1052637 = 0.0;
        bool r1052638 = r1052636 >= r1052637;
        double r1052639 = 2.0;
        double r1052640 = c;
        double r1052641 = r1052639 * r1052640;
        double r1052642 = -r1052636;
        double r1052643 = r1052636 * r1052636;
        double r1052644 = 4.0;
        double r1052645 = a;
        double r1052646 = r1052644 * r1052645;
        double r1052647 = r1052646 * r1052640;
        double r1052648 = r1052643 - r1052647;
        double r1052649 = sqrt(r1052648);
        double r1052650 = r1052642 - r1052649;
        double r1052651 = r1052641 / r1052650;
        double r1052652 = r1052642 + r1052649;
        double r1052653 = r1052639 * r1052645;
        double r1052654 = r1052652 / r1052653;
        double r1052655 = r1052638 ? r1052651 : r1052654;
        return r1052655;
}

double f(double a, double b, double c) {
        double r1052656 = b;
        double r1052657 = 1.673041355293174e+137;
        bool r1052658 = r1052656 <= r1052657;
        double r1052659 = 0.0;
        bool r1052660 = r1052656 >= r1052659;
        double r1052661 = 2.0;
        double r1052662 = c;
        double r1052663 = r1052661 * r1052662;
        double r1052664 = -r1052656;
        double r1052665 = -4.0;
        double r1052666 = a;
        double r1052667 = r1052666 * r1052662;
        double r1052668 = r1052656 * r1052656;
        double r1052669 = fma(r1052665, r1052667, r1052668);
        double r1052670 = cbrt(r1052669);
        double r1052671 = r1052670 * r1052670;
        double r1052672 = r1052671 * r1052670;
        double r1052673 = sqrt(r1052672);
        double r1052674 = r1052664 - r1052673;
        double r1052675 = r1052663 / r1052674;
        double r1052676 = r1052665 * r1052662;
        double r1052677 = fma(r1052676, r1052666, r1052668);
        double r1052678 = sqrt(r1052677);
        double r1052679 = r1052678 - r1052656;
        double r1052680 = r1052679 / r1052661;
        double r1052681 = r1052680 / r1052666;
        double r1052682 = r1052660 ? r1052675 : r1052681;
        double r1052683 = r1052656 + r1052656;
        double r1052684 = -r1052683;
        double r1052685 = r1052663 / r1052684;
        double r1052686 = r1052660 ? r1052685 : r1052681;
        double r1052687 = r1052658 ? r1052682 : r1052686;
        return r1052687;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 1.673041355293174e+137

    1. Initial program 15.3

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified15.3

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}}\]
    3. Taylor expanded around 0 15.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)} - b}{2}}{a}\\ \end{array}\]
    4. Simplified15.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt15.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]

    if 1.673041355293174e+137 < b

    1. Initial program 33.8

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified33.8

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}}\]
    3. Taylor expanded around 0 33.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)} - b}{2}}{a}\\ \end{array}\]
    4. Simplified33.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt33.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
    7. Using strategy rm
    8. Applied neg-sub033.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(0 - b\right)} - \sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
    9. Applied associate--l-33.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{0 - \left(b + \sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
    10. Simplified33.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{0 - \color{blue}{\left(\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} + b\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
    11. Taylor expanded around 0 1.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{0 - \left(\color{blue}{b} + b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b}{2}}{a}\\ \end{array}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification12.7

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

Reproduce

herbie shell --seed 2019143 +o rules:numerics
(FPCore (a b c)
  :name "jeff quadratic root 2"
  (if (>= b 0) (/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))))