Average Error: 28.7 → 16.6
Time: 13.5s
Precision: 64
\[1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt a \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt b \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt c \lt 94906265.62425155937671661376953125\]
\[\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 176.1804748497357593350898241624236106873:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1.5 \cdot \left(a \cdot \frac{c}{b}\right)}{3}}{a}\\ \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 176.1804748497357593350898241624236106873:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1.5 \cdot \left(a \cdot \frac{c}{b}\right)}{3}}{a}\\

\end{array}
double f(double a, double b, double c) {
        double r62766 = b;
        double r62767 = -r62766;
        double r62768 = r62766 * r62766;
        double r62769 = 3.0;
        double r62770 = a;
        double r62771 = r62769 * r62770;
        double r62772 = c;
        double r62773 = r62771 * r62772;
        double r62774 = r62768 - r62773;
        double r62775 = sqrt(r62774);
        double r62776 = r62767 + r62775;
        double r62777 = r62776 / r62771;
        return r62777;
}

double f(double a, double b, double c) {
        double r62778 = b;
        double r62779 = 176.18047484973576;
        bool r62780 = r62778 <= r62779;
        double r62781 = r62778 * r62778;
        double r62782 = 3.0;
        double r62783 = a;
        double r62784 = r62782 * r62783;
        double r62785 = c;
        double r62786 = r62784 * r62785;
        double r62787 = fma(r62778, r62778, r62786);
        double r62788 = r62781 - r62787;
        double r62789 = r62783 * r62785;
        double r62790 = r62782 * r62789;
        double r62791 = r62781 - r62790;
        double r62792 = sqrt(r62791);
        double r62793 = r62778 + r62792;
        double r62794 = r62788 / r62793;
        double r62795 = r62794 / r62784;
        double r62796 = -1.5;
        double r62797 = r62785 / r62778;
        double r62798 = r62783 * r62797;
        double r62799 = r62796 * r62798;
        double r62800 = r62799 / r62782;
        double r62801 = r62800 / r62783;
        double r62802 = r62780 ? r62795 : r62801;
        return r62802;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 176.18047484973576

    1. Initial program 15.7

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

      \[\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 flip--15.7

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

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

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

    if 176.18047484973576 < b

    1. Initial program 34.9

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

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
    4. Using strategy rm
    5. Applied associate-/r*17.4

      \[\leadsto \color{blue}{\frac{\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3}}{a}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity17.4

      \[\leadsto \frac{\frac{-1.5 \cdot \frac{a \cdot c}{\color{blue}{1 \cdot b}}}{3}}{a}\]
    8. Applied times-frac17.4

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

      \[\leadsto \frac{\frac{-1.5 \cdot \left(\color{blue}{a} \cdot \frac{c}{b}\right)}{3}}{a}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification16.6

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

Reproduce

herbie shell --seed 2019303 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (< 1.05367121277235087e-8 a 94906265.6242515594) (< 1.05367121277235087e-8 b 94906265.6242515594) (< 1.05367121277235087e-8 c 94906265.6242515594))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))