Average Error: 52.4 → 6.2
Time: 14.3s
Precision: 64
\[4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt a \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt b \lt 20282409603651670423947251286016 \land 4.930380657631323783823303533017413935458 \cdot 10^{-32} \lt c \lt 20282409603651670423947251286016\]
\[\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 3.054798768406738353528696346741077845707 \cdot 10^{-17}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} + b}}{3 \cdot 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 3.054798768406738353528696346741077845707 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} + b}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r58795 = b;
        double r58796 = -r58795;
        double r58797 = r58795 * r58795;
        double r58798 = 3.0;
        double r58799 = a;
        double r58800 = r58798 * r58799;
        double r58801 = c;
        double r58802 = r58800 * r58801;
        double r58803 = r58797 - r58802;
        double r58804 = sqrt(r58803);
        double r58805 = r58796 + r58804;
        double r58806 = r58805 / r58800;
        return r58806;
}

double f(double a, double b, double c) {
        double r58807 = b;
        double r58808 = 3.0547987684067384e-17;
        bool r58809 = r58807 <= r58808;
        double r58810 = r58807 * r58807;
        double r58811 = 3.0;
        double r58812 = a;
        double r58813 = r58811 * r58812;
        double r58814 = c;
        double r58815 = r58813 * r58814;
        double r58816 = fma(r58807, r58807, r58815);
        double r58817 = r58810 - r58816;
        double r58818 = r58812 * r58814;
        double r58819 = r58811 * r58818;
        double r58820 = r58810 - r58819;
        double r58821 = sqrt(r58820);
        double r58822 = r58821 + r58807;
        double r58823 = r58817 / r58822;
        double r58824 = r58823 / r58813;
        double r58825 = -0.5;
        double r58826 = r58814 / r58807;
        double r58827 = r58825 * r58826;
        double r58828 = r58809 ? r58824 : r58827;
        return r58828;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 3.0547987684067384e-17

    1. Initial program 21.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified21.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--21.5

      \[\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. Simplified20.8

      \[\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. Simplified20.8

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

    if 3.0547987684067384e-17 < b

    1. Initial program 52.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified52.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 5.9

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

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

Reproduce

herbie shell --seed 2019306 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, wide range"
  :precision binary64
  :pre (and (< 4.93038e-32 a 2.02824e31) (< 4.93038e-32 b 2.02824e31) (< 4.93038e-32 c 2.02824e31))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))