Average Error: 33.8 → 17.1
Time: 25.4s
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 7.454923183150117 \cdot 10^{-53}:\\ \;\;\;\;\frac{\frac{1}{3}}{\frac{a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-2 \cdot \frac{b}{c}}\\ \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 7.454923183150117 \cdot 10^{-53}:\\
\;\;\;\;\frac{\frac{1}{3}}{\frac{a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}}\\

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2926796 = b;
        double r2926797 = -r2926796;
        double r2926798 = r2926796 * r2926796;
        double r2926799 = 3.0;
        double r2926800 = a;
        double r2926801 = r2926799 * r2926800;
        double r2926802 = c;
        double r2926803 = r2926801 * r2926802;
        double r2926804 = r2926798 - r2926803;
        double r2926805 = sqrt(r2926804);
        double r2926806 = r2926797 + r2926805;
        double r2926807 = r2926806 / r2926801;
        return r2926807;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r2926808 = b;
        double r2926809 = 7.454923183150117e-53;
        bool r2926810 = r2926808 <= r2926809;
        double r2926811 = 0.3333333333333333;
        double r2926812 = a;
        double r2926813 = c;
        double r2926814 = -3.0;
        double r2926815 = r2926814 * r2926812;
        double r2926816 = r2926808 * r2926808;
        double r2926817 = fma(r2926813, r2926815, r2926816);
        double r2926818 = sqrt(r2926817);
        double r2926819 = r2926818 - r2926808;
        double r2926820 = r2926812 / r2926819;
        double r2926821 = r2926811 / r2926820;
        double r2926822 = 1.0;
        double r2926823 = -2.0;
        double r2926824 = r2926808 / r2926813;
        double r2926825 = r2926823 * r2926824;
        double r2926826 = r2926822 / r2926825;
        double r2926827 = r2926810 ? r2926821 : r2926826;
        return r2926827;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 2 regimes
  2. if b < 7.454923183150117e-53

    1. Initial program 22.0

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

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity21.9

      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - \color{blue}{1 \cdot b}}{3 \cdot a}\]
    5. Applied *-un-lft-identity21.9

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}} - 1 \cdot b}{3 \cdot a}\]
    6. Applied distribute-lft-out--21.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right)}}{3 \cdot a}\]
    7. Applied associate-/l*22.0

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity22.0

      \[\leadsto \frac{1}{\frac{3 \cdot a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - \color{blue}{1 \cdot b}}}\]
    10. Applied *-un-lft-identity22.0

      \[\leadsto \frac{1}{\frac{3 \cdot a}{\color{blue}{1 \cdot \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}} - 1 \cdot b}}\]
    11. Applied distribute-lft-out--22.0

      \[\leadsto \frac{1}{\frac{3 \cdot a}{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right)}}}\]
    12. Applied times-frac22.0

      \[\leadsto \frac{1}{\color{blue}{\frac{3}{1} \cdot \frac{a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}}}\]
    13. Applied associate-/r*22.0

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

      \[\leadsto \frac{\color{blue}{\frac{1}{3}}}{\frac{a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}}\]
    15. Using strategy rm
    16. Applied *-un-lft-identity22.0

      \[\leadsto \frac{\frac{1}{3}}{\frac{a}{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right)}}}\]
    17. Applied associate-/r*22.0

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

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

    if 7.454923183150117e-53 < 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. Simplified53.7

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity53.7

      \[\leadsto \frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - \color{blue}{1 \cdot b}}{3 \cdot a}\]
    5. Applied *-un-lft-identity53.7

      \[\leadsto \frac{\color{blue}{1 \cdot \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)}} - 1 \cdot b}{3 \cdot a}\]
    6. Applied distribute-lft-out--53.7

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b\right)}}{3 \cdot a}\]
    7. Applied associate-/l*53.8

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}}}\]
    8. Taylor expanded around 0 8.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 7.454923183150117 \cdot 10^{-53}:\\ \;\;\;\;\frac{\frac{1}{3}}{\frac{a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{-2 \cdot \frac{b}{c}}\\ \end{array}\]

Reproduce

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