Average Error: 34.3 → 12.6
Time: 18.1s
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.359648585223011851077522396013723801172 \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.331346421139204422600970774418791760561 \cdot 10^{-151}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(\left(a \cdot c\right) \cdot \left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right)\right) \cdot \sqrt[3]{3}} + \left(-b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.360533602471719816372113192105638652108 \cdot 10^{154}:\\ \;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{{b}^{2} - 3 \cdot \left(a \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 -1.359648585223011851077522396013723801172 \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.331346421139204422600970774418791760561 \cdot 10^{-151}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(\left(a \cdot c\right) \cdot \left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right)\right) \cdot \sqrt[3]{3}} + \left(-b\right)}{3 \cdot a}\\

\mathbf{elif}\;b \le 1.360533602471719816372113192105638652108 \cdot 10^{154}:\\
\;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{{b}^{2} - 3 \cdot \left(a \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 r78097 = b;
        double r78098 = -r78097;
        double r78099 = r78097 * r78097;
        double r78100 = 3.0;
        double r78101 = a;
        double r78102 = r78100 * r78101;
        double r78103 = c;
        double r78104 = r78102 * r78103;
        double r78105 = r78099 - r78104;
        double r78106 = sqrt(r78105);
        double r78107 = r78098 + r78106;
        double r78108 = r78107 / r78102;
        return r78108;
}

double f(double a, double b, double c) {
        double r78109 = b;
        double r78110 = -1.3596485852230119e+154;
        bool r78111 = r78109 <= r78110;
        double r78112 = a;
        double r78113 = c;
        double r78114 = r78112 * r78113;
        double r78115 = r78114 / r78109;
        double r78116 = 1.5;
        double r78117 = -2.0;
        double r78118 = r78117 * r78109;
        double r78119 = fma(r78115, r78116, r78118);
        double r78120 = 3.0;
        double r78121 = r78120 * r78112;
        double r78122 = r78119 / r78121;
        double r78123 = 4.3313464211392044e-151;
        bool r78124 = r78109 <= r78123;
        double r78125 = r78109 * r78109;
        double r78126 = cbrt(r78120);
        double r78127 = r78126 * r78126;
        double r78128 = r78114 * r78127;
        double r78129 = r78128 * r78126;
        double r78130 = r78125 - r78129;
        double r78131 = sqrt(r78130);
        double r78132 = -r78109;
        double r78133 = r78131 + r78132;
        double r78134 = r78133 / r78121;
        double r78135 = 1.3605336024717198e+154;
        bool r78136 = r78109 <= r78135;
        double r78137 = r78113 * r78121;
        double r78138 = 2.0;
        double r78139 = pow(r78109, r78138);
        double r78140 = r78120 * r78114;
        double r78141 = r78139 - r78140;
        double r78142 = sqrt(r78141);
        double r78143 = r78132 - r78142;
        double r78144 = r78137 / r78143;
        double r78145 = r78144 / r78121;
        double r78146 = -1.5;
        double r78147 = r78146 * r78115;
        double r78148 = r78147 / r78121;
        double r78149 = r78136 ? r78145 : r78148;
        double r78150 = r78124 ? r78134 : r78149;
        double r78151 = r78111 ? r78122 : r78150;
        return r78151;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < -1.3596485852230119e+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. Using strategy rm
    3. Applied pow164.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot \color{blue}{{c}^{1}}}}{3 \cdot a}\]
    4. Applied pow164.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot \color{blue}{{a}^{1}}\right) \cdot {c}^{1}}}{3 \cdot a}\]
    5. Applied pow164.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(\color{blue}{{3}^{1}} \cdot {a}^{1}\right) \cdot {c}^{1}}}{3 \cdot a}\]
    6. Applied pow-prod-down64.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(3 \cdot a\right)}^{1}} \cdot {c}^{1}}}{3 \cdot a}\]
    7. Applied pow-prod-down64.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\left(3 \cdot a\right) \cdot c\right)}^{1}}}}{3 \cdot a}\]
    8. Simplified64.0

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

      \[\leadsto \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]
    10. Simplified9.1

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

    if -1.3596485852230119e+154 < b < 4.3313464211392044e-151

    1. Initial program 10.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 pow110.8

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot \color{blue}{{c}^{1}}}}{3 \cdot a}\]
    4. Applied pow110.8

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot \color{blue}{{a}^{1}}\right) \cdot {c}^{1}}}{3 \cdot a}\]
    5. Applied pow110.8

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(\color{blue}{{3}^{1}} \cdot {a}^{1}\right) \cdot {c}^{1}}}{3 \cdot a}\]
    6. Applied pow-prod-down10.8

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(3 \cdot a\right)}^{1}} \cdot {c}^{1}}}{3 \cdot a}\]
    7. Applied pow-prod-down10.8

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\left(3 \cdot a\right) \cdot c\right)}^{1}}}}{3 \cdot a}\]
    8. Simplified10.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left(\left(a \cdot c\right) \cdot 3\right)}}^{1}}}{3 \cdot a}\]
    9. Using strategy rm
    10. Applied add-cube-cbrt10.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\left(\left(a \cdot c\right) \cdot \color{blue}{\left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}\right)}\right)}^{1}}}{3 \cdot a}\]
    11. Applied associate-*r*10.9

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

    if 4.3313464211392044e-151 < b < 1.3605336024717198e+154

    1. Initial program 41.0

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot \color{blue}{{c}^{1}}}}{3 \cdot a}\]
    4. Applied pow141.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot \color{blue}{{a}^{1}}\right) \cdot {c}^{1}}}{3 \cdot a}\]
    5. Applied pow141.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(\color{blue}{{3}^{1}} \cdot {a}^{1}\right) \cdot {c}^{1}}}{3 \cdot a}\]
    6. Applied pow-prod-down41.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(3 \cdot a\right)}^{1}} \cdot {c}^{1}}}{3 \cdot a}\]
    7. Applied pow-prod-down41.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(\left(3 \cdot a\right) \cdot c\right)}^{1}}}}{3 \cdot a}\]
    8. Simplified41.1

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - {\color{blue}{\left(\left(a \cdot c\right) \cdot 3\right)}}^{1}}}{3 \cdot a}\]
    9. Using strategy rm
    10. Applied flip-+41.1

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - {\left(\left(a \cdot c\right) \cdot 3\right)}^{1}} \cdot \sqrt{b \cdot b - {\left(\left(a \cdot c\right) \cdot 3\right)}^{1}}}{\left(-b\right) - \sqrt{b \cdot b - {\left(\left(a \cdot c\right) \cdot 3\right)}^{1}}}}}{3 \cdot a}\]
    11. Simplified15.6

      \[\leadsto \frac{\frac{\color{blue}{0 + c \cdot \left(3 \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - {\left(\left(a \cdot c\right) \cdot 3\right)}^{1}}}}{3 \cdot a}\]
    12. Simplified15.6

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

    if 1.3605336024717198e+154 < b

    1. Initial program 64.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.359648585223011851077522396013723801172 \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.331346421139204422600970774418791760561 \cdot 10^{-151}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(\left(a \cdot c\right) \cdot \left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right)\right) \cdot \sqrt[3]{3}} + \left(-b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.360533602471719816372113192105638652108 \cdot 10^{154}:\\ \;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{{b}^{2} - 3 \cdot \left(a \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 2019306 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))