Average Error: 34.0 → 10.3
Time: 17.5s
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.035809894237901445931970544225072398237 \cdot 10^{152}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 6.407662420749314643846659194387390530859 \cdot 10^{-35}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a}}{3}\\ \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 -8.035809894237901445931970544225072398237 \cdot 10^{152}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r4350537 = b;
        double r4350538 = -r4350537;
        double r4350539 = r4350537 * r4350537;
        double r4350540 = 3.0;
        double r4350541 = a;
        double r4350542 = r4350540 * r4350541;
        double r4350543 = c;
        double r4350544 = r4350542 * r4350543;
        double r4350545 = r4350539 - r4350544;
        double r4350546 = sqrt(r4350545);
        double r4350547 = r4350538 + r4350546;
        double r4350548 = r4350547 / r4350542;
        return r4350548;
}

double f(double a, double b, double c) {
        double r4350549 = b;
        double r4350550 = -8.035809894237901e+152;
        bool r4350551 = r4350549 <= r4350550;
        double r4350552 = 0.5;
        double r4350553 = c;
        double r4350554 = r4350553 / r4350549;
        double r4350555 = r4350552 * r4350554;
        double r4350556 = a;
        double r4350557 = r4350549 / r4350556;
        double r4350558 = 0.6666666666666666;
        double r4350559 = r4350557 * r4350558;
        double r4350560 = r4350555 - r4350559;
        double r4350561 = 6.407662420749315e-35;
        bool r4350562 = r4350549 <= r4350561;
        double r4350563 = r4350549 * r4350549;
        double r4350564 = 3.0;
        double r4350565 = r4350553 * r4350556;
        double r4350566 = r4350564 * r4350565;
        double r4350567 = r4350563 - r4350566;
        double r4350568 = sqrt(r4350567);
        double r4350569 = r4350568 - r4350549;
        double r4350570 = r4350569 / r4350556;
        double r4350571 = r4350570 / r4350564;
        double r4350572 = -0.5;
        double r4350573 = r4350572 * r4350554;
        double r4350574 = r4350562 ? r4350571 : r4350573;
        double r4350575 = r4350551 ? r4350560 : r4350574;
        return r4350575;
}

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.035809894237901e+152

    1. Initial program 63.6

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

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

    if -8.035809894237901e+152 < b < 6.407662420749315e-35

    1. Initial program 14.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-identity14.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-frac14.1

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

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

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

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

    if 6.407662420749315e-35 < b

    1. Initial program 54.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -8.035809894237901445931970544225072398237 \cdot 10^{152}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - \frac{b}{a} \cdot 0.6666666666666666296592325124947819858789\\ \mathbf{elif}\;b \le 6.407662420749314643846659194387390530859 \cdot 10^{-35}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} - b}{a}}{3}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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