Average Error: 28.6 → 15.0
Time: 17.9s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -2.250778424183938 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)} \cdot \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right) - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}, \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)} + b, b \cdot b\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -2.250778424183938 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)} \cdot \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right) - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}, \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)} + b, b \cdot b\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1175527 = b;
        double r1175528 = -r1175527;
        double r1175529 = r1175527 * r1175527;
        double r1175530 = 3.0;
        double r1175531 = a;
        double r1175532 = r1175530 * r1175531;
        double r1175533 = c;
        double r1175534 = r1175532 * r1175533;
        double r1175535 = r1175529 - r1175534;
        double r1175536 = sqrt(r1175535);
        double r1175537 = r1175528 + r1175536;
        double r1175538 = r1175537 / r1175532;
        return r1175538;
}

double f(double a, double b, double c) {
        double r1175539 = b;
        double r1175540 = r1175539 * r1175539;
        double r1175541 = 3.0;
        double r1175542 = a;
        double r1175543 = r1175541 * r1175542;
        double r1175544 = c;
        double r1175545 = r1175543 * r1175544;
        double r1175546 = r1175540 - r1175545;
        double r1175547 = sqrt(r1175546);
        double r1175548 = -r1175539;
        double r1175549 = r1175547 + r1175548;
        double r1175550 = r1175549 / r1175543;
        double r1175551 = -2.250778424183938e-05;
        bool r1175552 = r1175550 <= r1175551;
        double r1175553 = -3.0;
        double r1175554 = r1175544 * r1175542;
        double r1175555 = r1175553 * r1175554;
        double r1175556 = fma(r1175539, r1175539, r1175555);
        double r1175557 = sqrt(r1175556);
        double r1175558 = r1175557 * r1175556;
        double r1175559 = r1175539 * r1175540;
        double r1175560 = r1175558 - r1175559;
        double r1175561 = r1175557 + r1175539;
        double r1175562 = fma(r1175557, r1175561, r1175540);
        double r1175563 = r1175560 / r1175562;
        double r1175564 = r1175563 / r1175543;
        double r1175565 = r1175544 / r1175539;
        double r1175566 = -0.5;
        double r1175567 = r1175565 * r1175566;
        double r1175568 = r1175552 ? r1175564 : r1175567;
        return r1175568;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -2.250778424183938e-05

    1. Initial program 16.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 flip3-+16.9

      \[\leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^{3} + {\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}^{3}}{\left(-b\right) \cdot \left(-b\right) + \left(\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) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    4. Simplified16.3

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} \cdot \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) - \left(b \cdot b\right) \cdot b}}{\left(-b\right) \cdot \left(-b\right) + \left(\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) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}\]
    5. Simplified16.3

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

    if -2.250778424183938e-05 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 39.2

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

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

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

Reproduce

herbie shell --seed 2019155 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))