Average Error: 34.3 → 10.7
Time: 5.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 -8.55528137777049654 \cdot 10^{140}:\\ \;\;\;\;1 \cdot \left(0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 11181767625882.1309:\\ \;\;\;\;1 \cdot \frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}}{3}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(-0.5 \cdot \frac{c}{b}\right)\\ \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 -8.55528137777049654 \cdot 10^{140}:\\
\;\;\;\;1 \cdot \left(0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\right)\\

\mathbf{elif}\;b \le 11181767625882.1309:\\
\;\;\;\;1 \cdot \frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}}{3}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot \left(-0.5 \cdot \frac{c}{b}\right)\\

\end{array}
double f(double a, double b, double c) {
        double r101004 = b;
        double r101005 = -r101004;
        double r101006 = r101004 * r101004;
        double r101007 = 3.0;
        double r101008 = a;
        double r101009 = r101007 * r101008;
        double r101010 = c;
        double r101011 = r101009 * r101010;
        double r101012 = r101006 - r101011;
        double r101013 = sqrt(r101012);
        double r101014 = r101005 + r101013;
        double r101015 = r101014 / r101009;
        return r101015;
}

double f(double a, double b, double c) {
        double r101016 = b;
        double r101017 = -8.555281377770497e+140;
        bool r101018 = r101016 <= r101017;
        double r101019 = 1.0;
        double r101020 = 0.5;
        double r101021 = c;
        double r101022 = r101021 / r101016;
        double r101023 = r101020 * r101022;
        double r101024 = 0.6666666666666666;
        double r101025 = a;
        double r101026 = r101016 / r101025;
        double r101027 = r101024 * r101026;
        double r101028 = r101023 - r101027;
        double r101029 = r101019 * r101028;
        double r101030 = 11181767625882.13;
        bool r101031 = r101016 <= r101030;
        double r101032 = -r101016;
        double r101033 = r101016 * r101016;
        double r101034 = 3.0;
        double r101035 = r101034 * r101025;
        double r101036 = r101035 * r101021;
        double r101037 = r101033 - r101036;
        double r101038 = sqrt(r101037);
        double r101039 = r101032 + r101038;
        double r101040 = r101039 / r101025;
        double r101041 = r101040 / r101034;
        double r101042 = r101019 * r101041;
        double r101043 = -0.5;
        double r101044 = r101043 * r101022;
        double r101045 = r101019 * r101044;
        double r101046 = r101031 ? r101042 : r101045;
        double r101047 = r101018 ? r101029 : r101046;
        return r101047;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -8.555281377770497e+140

    1. Initial program 58.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity58.5

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity58.6

      \[\leadsto \frac{1}{\color{blue}{1 \cdot 3}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}\]
    7. Applied *-un-lft-identity58.6

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

      \[\leadsto \color{blue}{\left(\frac{1}{1} \cdot \frac{1}{3}\right)} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}\]
    9. Applied associate-*l*58.6

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

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

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

    if -8.555281377770497e+140 < b < 11181767625882.13

    1. Initial program 15.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 *-un-lft-identity15.8

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity16.0

      \[\leadsto \frac{1}{\color{blue}{1 \cdot 3}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}\]
    7. Applied *-un-lft-identity16.0

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

      \[\leadsto \color{blue}{\left(\frac{1}{1} \cdot \frac{1}{3}\right)} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}\]
    9. Applied associate-*l*16.0

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

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

    if 11181767625882.13 < b

    1. Initial program 56.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 *-un-lft-identity56.0

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity56.0

      \[\leadsto \frac{1}{\color{blue}{1 \cdot 3}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}\]
    7. Applied *-un-lft-identity56.0

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

      \[\leadsto \color{blue}{\left(\frac{1}{1} \cdot \frac{1}{3}\right)} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}\]
    9. Applied associate-*l*56.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -8.55528137777049654 \cdot 10^{140}:\\ \;\;\;\;1 \cdot \left(0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 11181767625882.1309:\\ \;\;\;\;1 \cdot \frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}}{3}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(-0.5 \cdot \frac{c}{b}\right)\\ \end{array}\]

Reproduce

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