Average Error: 34.3 → 15.4
Time: 19.3s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.350676057343211554491874986591947593393 \cdot 10^{154}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a \cdot c}{b}, 1.5, -2 \cdot b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 4.102989996811911866204947960625153691584 \cdot 10^{-44}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -1.350676057343211554491874986591947593393 \cdot 10^{154}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{a \cdot c}{b}, 1.5, -2 \cdot b\right)}{3 \cdot a}\\

\mathbf{elif}\;b \le 4.102989996811911866204947960625153691584 \cdot 10^{-44}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r67696 = b;
        double r67697 = -r67696;
        double r67698 = r67696 * r67696;
        double r67699 = 3.0;
        double r67700 = a;
        double r67701 = r67699 * r67700;
        double r67702 = c;
        double r67703 = r67701 * r67702;
        double r67704 = r67698 - r67703;
        double r67705 = sqrt(r67704);
        double r67706 = r67697 + r67705;
        double r67707 = r67706 / r67701;
        return r67707;
}

double f(double a, double b, double c) {
        double r67708 = b;
        double r67709 = -1.3506760573432116e+154;
        bool r67710 = r67708 <= r67709;
        double r67711 = a;
        double r67712 = c;
        double r67713 = r67711 * r67712;
        double r67714 = r67713 / r67708;
        double r67715 = 1.5;
        double r67716 = -2.0;
        double r67717 = r67716 * r67708;
        double r67718 = fma(r67714, r67715, r67717);
        double r67719 = 3.0;
        double r67720 = r67719 * r67711;
        double r67721 = r67718 / r67720;
        double r67722 = 4.102989996811912e-44;
        bool r67723 = r67708 <= r67722;
        double r67724 = r67708 * r67708;
        double r67725 = r67720 * r67712;
        double r67726 = r67724 - r67725;
        double r67727 = sqrt(r67726);
        double r67728 = r67727 - r67708;
        double r67729 = r67728 / r67720;
        double r67730 = -1.5;
        double r67731 = r67730 * r67714;
        double r67732 = r67731 / r67720;
        double r67733 = r67723 ? r67729 : r67732;
        double r67734 = r67710 ? r67721 : r67733;
        return r67734;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -1.3506760573432116e+154

    1. Initial program 64.0

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

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

      \[\leadsto \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]
    4. Simplified12.0

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

    if -1.3506760573432116e+154 < b < 4.102989996811912e-44

    1. Initial program 13.5

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]

    if 4.102989996811912e-44 < b

    1. Initial program 54.5

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

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification15.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.350676057343211554491874986591947593393 \cdot 10^{154}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{a \cdot c}{b}, 1.5, -2 \cdot b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 4.102989996811911866204947960625153691584 \cdot 10^{-44}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019303 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))