Average Error: 33.9 → 7.5
Time: 18.0s
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 -4.91962817906715367126033645969528543778 \cdot 10^{153}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -1.835959749839008164057240193717116825713 \cdot 10^{-262}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \le 929319867835151.5:\\ \;\;\;\;\left(c \cdot 3\right) \cdot \frac{\frac{\frac{a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3}}{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 -4.91962817906715367126033645969528543778 \cdot 10^{153}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le -1.835959749839008164057240193717116825713 \cdot 10^{-262}:\\
\;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r97640 = b;
        double r97641 = -r97640;
        double r97642 = r97640 * r97640;
        double r97643 = 3.0;
        double r97644 = a;
        double r97645 = r97643 * r97644;
        double r97646 = c;
        double r97647 = r97645 * r97646;
        double r97648 = r97642 - r97647;
        double r97649 = sqrt(r97648);
        double r97650 = r97641 + r97649;
        double r97651 = r97650 / r97645;
        return r97651;
}

double f(double a, double b, double c) {
        double r97652 = b;
        double r97653 = -4.919628179067154e+153;
        bool r97654 = r97652 <= r97653;
        double r97655 = 0.5;
        double r97656 = c;
        double r97657 = r97656 / r97652;
        double r97658 = r97655 * r97657;
        double r97659 = 0.6666666666666666;
        double r97660 = a;
        double r97661 = r97652 / r97660;
        double r97662 = r97659 * r97661;
        double r97663 = r97658 - r97662;
        double r97664 = -1.8359597498390082e-262;
        bool r97665 = r97652 <= r97664;
        double r97666 = r97652 * r97652;
        double r97667 = 3.0;
        double r97668 = r97667 * r97660;
        double r97669 = r97668 * r97656;
        double r97670 = r97666 - r97669;
        double r97671 = sqrt(r97670);
        double r97672 = r97671 - r97652;
        double r97673 = r97672 / r97667;
        double r97674 = r97673 / r97660;
        double r97675 = 929319867835151.5;
        bool r97676 = r97652 <= r97675;
        double r97677 = r97656 * r97667;
        double r97678 = -r97652;
        double r97679 = r97678 - r97671;
        double r97680 = r97660 / r97679;
        double r97681 = r97680 / r97667;
        double r97682 = r97681 / r97660;
        double r97683 = r97677 * r97682;
        double r97684 = -0.5;
        double r97685 = r97684 * r97657;
        double r97686 = r97676 ? r97683 : r97685;
        double r97687 = r97665 ? r97674 : r97686;
        double r97688 = r97654 ? r97663 : r97687;
        return r97688;
}

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 4 regimes
  2. if b < -4.919628179067154e+153

    1. Initial program 63.8

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

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

    if -4.919628179067154e+153 < b < -1.8359597498390082e-262

    1. Initial program 8.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*8.7

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

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

    if -1.8359597498390082e-262 < b < 929319867835151.5

    1. Initial program 26.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 flip-+26.5

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    4. Simplified17.7

      \[\leadsto \frac{\frac{\color{blue}{0 + \left(c \cdot 3\right) \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied associate-/r*17.7

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{\left(c \cdot 3\right) \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3}}}{a}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity17.7

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

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

      \[\leadsto \frac{\frac{\frac{\left(c \cdot 3\right) \cdot a}{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{1 \cdot 3}}{1 \cdot a}\]
    12. Applied times-frac14.7

      \[\leadsto \frac{\frac{\color{blue}{\frac{c \cdot 3}{1} \cdot \frac{a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{1 \cdot 3}}{1 \cdot a}\]
    13. Applied times-frac14.7

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

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

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

    if 929319867835151.5 < b

    1. Initial program 56.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.91962817906715367126033645969528543778 \cdot 10^{153}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -1.835959749839008164057240193717116825713 \cdot 10^{-262}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \le 929319867835151.5:\\ \;\;\;\;\left(c \cdot 3\right) \cdot \frac{\frac{\frac{a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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