Average Error: 44.4 → 10.1
Time: 16.9s
Precision: 64
\[1.1102230246251565 \cdot 10^{-16} \lt a \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt b \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt c \lt 9007199254740992.0\]
\[\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 -0.08079221226609472:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}}}{3 \cdot a}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -0.0021130712332977203:\\ \;\;\;\;\frac{1}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{c} \cdot b\right)\right) \cdot -2}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.045888882004455 \cdot 10^{-07}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\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 -0.08079221226609472:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}}}{3 \cdot a}\\

\mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -0.0021130712332977203:\\
\;\;\;\;\frac{1}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{c} \cdot b\right)\right) \cdot -2}\\

\mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.045888882004455 \cdot 10^{-07}:\\
\;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1210615 = b;
        double r1210616 = -r1210615;
        double r1210617 = r1210615 * r1210615;
        double r1210618 = 3.0;
        double r1210619 = a;
        double r1210620 = r1210618 * r1210619;
        double r1210621 = c;
        double r1210622 = r1210620 * r1210621;
        double r1210623 = r1210617 - r1210622;
        double r1210624 = sqrt(r1210623);
        double r1210625 = r1210616 + r1210624;
        double r1210626 = r1210625 / r1210620;
        return r1210626;
}

double f(double a, double b, double c) {
        double r1210627 = b;
        double r1210628 = r1210627 * r1210627;
        double r1210629 = 3.0;
        double r1210630 = a;
        double r1210631 = r1210629 * r1210630;
        double r1210632 = c;
        double r1210633 = r1210631 * r1210632;
        double r1210634 = r1210628 - r1210633;
        double r1210635 = sqrt(r1210634);
        double r1210636 = -r1210627;
        double r1210637 = r1210635 + r1210636;
        double r1210638 = r1210637 / r1210631;
        double r1210639 = -0.08079221226609472;
        bool r1210640 = r1210638 <= r1210639;
        double r1210641 = r1210634 * r1210635;
        double r1210642 = r1210627 * r1210628;
        double r1210643 = r1210641 - r1210642;
        double r1210644 = -3.0;
        double r1210645 = r1210632 * r1210630;
        double r1210646 = r1210644 * r1210645;
        double r1210647 = fma(r1210627, r1210627, r1210646);
        double r1210648 = fma(r1210627, r1210627, r1210647);
        double r1210649 = sqrt(r1210647);
        double r1210650 = r1210627 * r1210649;
        double r1210651 = r1210648 + r1210650;
        double r1210652 = r1210643 / r1210651;
        double r1210653 = r1210652 / r1210631;
        double r1210654 = -0.0021130712332977203;
        bool r1210655 = r1210638 <= r1210654;
        double r1210656 = 1.0;
        double r1210657 = r1210656 / r1210632;
        double r1210658 = r1210657 * r1210627;
        double r1210659 = log1p(r1210658);
        double r1210660 = expm1(r1210659);
        double r1210661 = -2.0;
        double r1210662 = r1210660 * r1210661;
        double r1210663 = r1210656 / r1210662;
        double r1210664 = -1.045888882004455e-07;
        bool r1210665 = r1210638 <= r1210664;
        double r1210666 = r1210632 / r1210627;
        double r1210667 = -0.5;
        double r1210668 = r1210666 * r1210667;
        double r1210669 = r1210665 ? r1210653 : r1210668;
        double r1210670 = r1210655 ? r1210663 : r1210669;
        double r1210671 = r1210640 ? r1210653 : r1210670;
        return r1210671;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -0.08079221226609472 or -0.0021130712332977203 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -1.045888882004455e-07

    1. Initial program 22.4

      \[\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-+22.5

      \[\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. Simplified21.7

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

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

    if -0.08079221226609472 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -0.0021130712332977203

    1. Initial program 22.7

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

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied clear-num26.6

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}}\]
    5. Simplified26.6

      \[\leadsto \frac{1}{\color{blue}{-2 \cdot \frac{a}{\frac{a \cdot c}{b}}}}\]
    6. Using strategy rm
    7. Applied expm1-log1p-u26.6

      \[\leadsto \frac{1}{-2 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a}{\frac{a \cdot c}{b}}\right)\right)}}\]
    8. Simplified26.6

      \[\leadsto \frac{1}{-2 \cdot \mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(b \cdot \left(1 \cdot \frac{1}{c}\right)\right)}\right)}\]

    if -1.045888882004455e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 54.0

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

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied clear-num5.2

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}}\]
    5. Simplified5.1

      \[\leadsto \frac{1}{\color{blue}{-2 \cdot \frac{a}{\frac{a \cdot c}{b}}}}\]
    6. Taylor expanded around 0 4.7

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

    \[\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 -0.08079221226609472:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}}}{3 \cdot a}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -0.0021130712332977203:\\ \;\;\;\;\frac{1}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{c} \cdot b\right)\right) \cdot -2}\\ \mathbf{elif}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -1.045888882004455 \cdot 10^{-07}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019151 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))