Average Error: 34.0 → 16.4
Time: 4.9s
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 -4.1322156516434321 \cdot 10^{148}:\\ \;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.6860323728047766 \cdot 10^{-117}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \left(\sqrt[3]{\sqrt[3]{-b}} \cdot \sqrt[3]{\sqrt[3]{-b}}\right) \cdot \sqrt[3]{\sqrt[3]{-b}}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{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 -4.1322156516434321 \cdot 10^{148}:\\
\;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\

\mathbf{elif}\;b \le 2.6860323728047766 \cdot 10^{-117}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \left(\sqrt[3]{\sqrt[3]{-b}} \cdot \sqrt[3]{\sqrt[3]{-b}}\right) \cdot \sqrt[3]{\sqrt[3]{-b}}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{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 r84639 = b;
        double r84640 = -r84639;
        double r84641 = r84639 * r84639;
        double r84642 = 3.0;
        double r84643 = a;
        double r84644 = r84642 * r84643;
        double r84645 = c;
        double r84646 = r84644 * r84645;
        double r84647 = r84641 - r84646;
        double r84648 = sqrt(r84647);
        double r84649 = r84640 + r84648;
        double r84650 = r84649 / r84644;
        return r84650;
}

double f(double a, double b, double c) {
        double r84651 = b;
        double r84652 = -4.132215651643432e+148;
        bool r84653 = r84651 <= r84652;
        double r84654 = -r84651;
        double r84655 = 1.5;
        double r84656 = a;
        double r84657 = c;
        double r84658 = r84656 * r84657;
        double r84659 = r84658 / r84651;
        double r84660 = r84655 * r84659;
        double r84661 = r84660 - r84651;
        double r84662 = r84654 + r84661;
        double r84663 = 3.0;
        double r84664 = r84663 * r84656;
        double r84665 = r84662 / r84664;
        double r84666 = 2.6860323728047766e-117;
        bool r84667 = r84651 <= r84666;
        double r84668 = cbrt(r84654);
        double r84669 = r84668 * r84668;
        double r84670 = cbrt(r84668);
        double r84671 = r84670 * r84670;
        double r84672 = r84671 * r84670;
        double r84673 = r84651 * r84651;
        double r84674 = r84664 * r84657;
        double r84675 = r84673 - r84674;
        double r84676 = sqrt(r84675);
        double r84677 = fma(r84669, r84672, r84676);
        double r84678 = r84677 / r84664;
        double r84679 = -1.5;
        double r84680 = r84679 * r84659;
        double r84681 = r84680 / r84664;
        double r84682 = r84667 ? r84678 : r84681;
        double r84683 = r84653 ? r84665 : r84682;
        return r84683;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -4.132215651643432e+148

    1. Initial program 60.5

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

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

    if -4.132215651643432e+148 < b < 2.6860323728047766e-117

    1. Initial program 11.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt11.5

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}\right) \cdot \sqrt[3]{-b}} + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    4. Applied fma-def11.5

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt11.6

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

    if 2.6860323728047766e-117 < b

    1. Initial program 51.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.1322156516434321 \cdot 10^{148}:\\ \;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.6860323728047766 \cdot 10^{-117}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \left(\sqrt[3]{\sqrt[3]{-b}} \cdot \sqrt[3]{\sqrt[3]{-b}}\right) \cdot \sqrt[3]{\sqrt[3]{-b}}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

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