Average Error: 33.9 → 9.9
Time: 9.9s
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.93152454634661985 \cdot 10^{153}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 1.961082134151116 \cdot 10^{-106}:\\ \;\;\;\;\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b\right) \cdot \frac{\frac{1}{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 -7.93152454634661985 \cdot 10^{153}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r97796 = b;
        double r97797 = -r97796;
        double r97798 = r97796 * r97796;
        double r97799 = 3.0;
        double r97800 = a;
        double r97801 = r97799 * r97800;
        double r97802 = c;
        double r97803 = r97801 * r97802;
        double r97804 = r97798 - r97803;
        double r97805 = sqrt(r97804);
        double r97806 = r97797 + r97805;
        double r97807 = r97806 / r97801;
        return r97807;
}

double f(double a, double b, double c) {
        double r97808 = b;
        double r97809 = -7.93152454634662e+153;
        bool r97810 = r97808 <= r97809;
        double r97811 = 0.5;
        double r97812 = c;
        double r97813 = r97812 / r97808;
        double r97814 = r97811 * r97813;
        double r97815 = 0.6666666666666666;
        double r97816 = a;
        double r97817 = r97808 / r97816;
        double r97818 = r97815 * r97817;
        double r97819 = r97814 - r97818;
        double r97820 = 1.961082134151116e-106;
        bool r97821 = r97808 <= r97820;
        double r97822 = r97808 * r97808;
        double r97823 = 3.0;
        double r97824 = r97823 * r97816;
        double r97825 = r97824 * r97812;
        double r97826 = r97822 - r97825;
        double r97827 = sqrt(r97826);
        double r97828 = r97827 - r97808;
        double r97829 = 1.0;
        double r97830 = r97829 / r97823;
        double r97831 = r97830 / r97816;
        double r97832 = r97828 * r97831;
        double r97833 = -0.5;
        double r97834 = r97833 * r97813;
        double r97835 = r97821 ? r97832 : r97834;
        double r97836 = r97810 ? r97819 : r97835;
        return r97836;
}

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 < -7.93152454634662e+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. Simplified63.8

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

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

    if -7.93152454634662e+153 < b < 1.961082134151116e-106

    1. Initial program 11.3

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied div-inv11.4

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

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

    if 1.961082134151116e-106 < b

    1. Initial program 52.0

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

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

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

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

Reproduce

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