Average Error: 34.5 → 10.1
Time: 5.7s
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.2448541423515275 \cdot 10^{126}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.0821834876358133 \cdot 10^{-90}:\\ \;\;\;\;\frac{\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}\\ \mathbf{elif}\;b \le 8.2848430749814326 \cdot 10^{-57}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 8.1723280032294423 \cdot 10^{-43}:\\ \;\;\;\;\frac{\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}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \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.2448541423515275 \cdot 10^{126}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le 2.0821834876358133 \cdot 10^{-90}:\\
\;\;\;\;\frac{\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}\\

\mathbf{elif}\;b \le 8.2848430749814326 \cdot 10^{-57}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\mathbf{elif}\;b \le 8.1723280032294423 \cdot 10^{-43}:\\
\;\;\;\;\frac{\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}\\

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

\end{array}
double f(double a, double b, double c) {
        double r102794 = b;
        double r102795 = -r102794;
        double r102796 = r102794 * r102794;
        double r102797 = 3.0;
        double r102798 = a;
        double r102799 = r102797 * r102798;
        double r102800 = c;
        double r102801 = r102799 * r102800;
        double r102802 = r102796 - r102801;
        double r102803 = sqrt(r102802);
        double r102804 = r102795 + r102803;
        double r102805 = r102804 / r102799;
        return r102805;
}

double f(double a, double b, double c) {
        double r102806 = b;
        double r102807 = -1.2448541423515275e+126;
        bool r102808 = r102806 <= r102807;
        double r102809 = 0.5;
        double r102810 = c;
        double r102811 = r102810 / r102806;
        double r102812 = r102809 * r102811;
        double r102813 = 0.6666666666666666;
        double r102814 = a;
        double r102815 = r102806 / r102814;
        double r102816 = r102813 * r102815;
        double r102817 = r102812 - r102816;
        double r102818 = 2.0821834876358133e-90;
        bool r102819 = r102806 <= r102818;
        double r102820 = -r102806;
        double r102821 = cbrt(r102820);
        double r102822 = r102821 * r102821;
        double r102823 = r102806 * r102806;
        double r102824 = 3.0;
        double r102825 = r102824 * r102814;
        double r102826 = r102825 * r102810;
        double r102827 = r102823 - r102826;
        double r102828 = sqrt(r102827);
        double r102829 = fma(r102822, r102821, r102828);
        double r102830 = r102829 / r102825;
        double r102831 = 8.284843074981433e-57;
        bool r102832 = r102806 <= r102831;
        double r102833 = -0.5;
        double r102834 = r102833 * r102811;
        double r102835 = 8.172328003229442e-43;
        bool r102836 = r102806 <= r102835;
        double r102837 = r102836 ? r102830 : r102834;
        double r102838 = r102832 ? r102834 : r102837;
        double r102839 = r102819 ? r102830 : r102838;
        double r102840 = r102808 ? r102817 : r102839;
        return r102840;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -1.2448541423515275e+126

    1. Initial program 53.8

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}}\]

    if -1.2448541423515275e+126 < b < 2.0821834876358133e-90 or 8.284843074981433e-57 < b < 8.172328003229442e-43

    1. Initial program 12.8

      \[\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-cbrt13.0

      \[\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-def13.0

      \[\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}\]

    if 2.0821834876358133e-90 < b < 8.284843074981433e-57 or 8.172328003229442e-43 < b

    1. Initial program 53.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.2448541423515275 \cdot 10^{126}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.0821834876358133 \cdot 10^{-90}:\\ \;\;\;\;\frac{\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}\\ \mathbf{elif}\;b \le 8.2848430749814326 \cdot 10^{-57}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 8.1723280032294423 \cdot 10^{-43}:\\ \;\;\;\;\frac{\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}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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