Average Error: 33.5 → 9.4
Time: 1.4m
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.3284761160093318 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{\frac{3}{2} \cdot \frac{c \cdot a}{b}} \cdot \left(c \cdot \left(\left(-3 \cdot a\right) \cdot \frac{\frac{1}{3}}{a}\right)\right)\\ \mathbf{elif}\;b \le -5.994286173036276 \cdot 10^{-289}:\\ \;\;\;\;\frac{1}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3 \cdot a}}}\\ \mathbf{elif}\;b \le 5.599629231681757 \cdot 10^{+121}:\\ \;\;\;\;c \cdot \frac{-1}{b + \sqrt{\mathsf{fma}\left(\left(-3 \cdot a\right), c, \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{b}{c} \cdot -2}\\ \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.3284761160093318 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\frac{3}{2} \cdot \frac{c \cdot a}{b}} \cdot \left(c \cdot \left(\left(-3 \cdot a\right) \cdot \frac{\frac{1}{3}}{a}\right)\right)\\

\mathbf{elif}\;b \le -5.994286173036276 \cdot 10^{-289}:\\
\;\;\;\;\frac{1}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3 \cdot a}}}\\

\mathbf{elif}\;b \le 5.599629231681757 \cdot 10^{+121}:\\
\;\;\;\;c \cdot \frac{-1}{b + \sqrt{\mathsf{fma}\left(\left(-3 \cdot a\right), c, \left(b \cdot b\right)\right)}}\\

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r23805635 = b;
        double r23805636 = -r23805635;
        double r23805637 = r23805635 * r23805635;
        double r23805638 = 3.0;
        double r23805639 = a;
        double r23805640 = r23805638 * r23805639;
        double r23805641 = c;
        double r23805642 = r23805640 * r23805641;
        double r23805643 = r23805637 - r23805642;
        double r23805644 = sqrt(r23805643);
        double r23805645 = r23805636 + r23805644;
        double r23805646 = r23805645 / r23805640;
        return r23805646;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r23805647 = b;
        double r23805648 = -1.3284761160093318e+154;
        bool r23805649 = r23805647 <= r23805648;
        double r23805650 = 1.0;
        double r23805651 = 1.5;
        double r23805652 = c;
        double r23805653 = a;
        double r23805654 = r23805652 * r23805653;
        double r23805655 = r23805654 / r23805647;
        double r23805656 = r23805651 * r23805655;
        double r23805657 = r23805650 / r23805656;
        double r23805658 = -3.0;
        double r23805659 = r23805658 * r23805653;
        double r23805660 = 0.3333333333333333;
        double r23805661 = r23805660 / r23805653;
        double r23805662 = r23805659 * r23805661;
        double r23805663 = r23805652 * r23805662;
        double r23805664 = r23805657 * r23805663;
        double r23805665 = -5.994286173036276e-289;
        bool r23805666 = r23805647 <= r23805665;
        double r23805667 = r23805647 * r23805647;
        double r23805668 = fma(r23805652, r23805659, r23805667);
        double r23805669 = sqrt(r23805668);
        double r23805670 = r23805669 - r23805647;
        double r23805671 = 3.0;
        double r23805672 = r23805671 * r23805653;
        double r23805673 = r23805670 / r23805672;
        double r23805674 = r23805650 / r23805673;
        double r23805675 = r23805650 / r23805674;
        double r23805676 = 5.599629231681757e+121;
        bool r23805677 = r23805647 <= r23805676;
        double r23805678 = -1.0;
        double r23805679 = fma(r23805659, r23805652, r23805667);
        double r23805680 = sqrt(r23805679);
        double r23805681 = r23805647 + r23805680;
        double r23805682 = r23805678 / r23805681;
        double r23805683 = r23805652 * r23805682;
        double r23805684 = r23805647 / r23805652;
        double r23805685 = -2.0;
        double r23805686 = r23805684 * r23805685;
        double r23805687 = r23805650 / r23805686;
        double r23805688 = r23805677 ? r23805683 : r23805687;
        double r23805689 = r23805666 ? r23805675 : r23805688;
        double r23805690 = r23805649 ? r23805664 : r23805689;
        return r23805690;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 4 regimes
  2. if b < -1.3284761160093318e+154

    1. Initial program 61.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified60.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-identity60.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-identity60.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--60.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*60.9

      \[\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 flip--62.3

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

      \[\leadsto \frac{1}{\color{blue}{\frac{3 \cdot a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b \cdot b} \cdot \left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} + b\right)}}\]
    11. Applied add-cube-cbrt62.3

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

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

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

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

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

    if -1.3284761160093318e+154 < b < -5.994286173036276e-289

    1. Initial program 8.8

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

      \[\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-identity8.8

      \[\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-identity8.8

      \[\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--8.8

      \[\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*8.9

      \[\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 clear-num8.9

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

    if -5.994286173036276e-289 < b < 5.599629231681757e+121

    1. Initial program 32.2

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

      \[\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-identity32.2

      \[\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-identity32.2

      \[\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--32.2

      \[\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*32.2

      \[\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 flip--32.3

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

      \[\leadsto \frac{1}{\color{blue}{\frac{3 \cdot a}{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b \cdot b} \cdot \left(\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} + b\right)}}\]
    11. Applied add-cube-cbrt32.4

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

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

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

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

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

    if 5.599629231681757e+121 < b

    1. Initial program 59.2

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

      \[\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-identity59.3

      \[\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-identity59.3

      \[\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--59.3

      \[\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*59.3

      \[\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 3.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.3284761160093318 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{\frac{3}{2} \cdot \frac{c \cdot a}{b}} \cdot \left(c \cdot \left(\left(-3 \cdot a\right) \cdot \frac{\frac{1}{3}}{a}\right)\right)\\ \mathbf{elif}\;b \le -5.994286173036276 \cdot 10^{-289}:\\ \;\;\;\;\frac{1}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-3 \cdot a\right), \left(b \cdot b\right)\right)} - b}{3 \cdot a}}}\\ \mathbf{elif}\;b \le 5.599629231681757 \cdot 10^{+121}:\\ \;\;\;\;c \cdot \frac{-1}{b + \sqrt{\mathsf{fma}\left(\left(-3 \cdot a\right), c, \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{b}{c} \cdot -2}\\ \end{array}\]

Reproduce

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