Average Error: 44.0 → 10.9
Time: 13.0s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le 2.75926987569438465265365262313324024035 \cdot 10^{-5}:\\ \;\;\;\;\frac{{\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}^{3} - {b}^{3}}{\left(\left(b \cdot \left(\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b\right) + b\right) - 4 \cdot \left(a \cdot c\right)\right) \cdot 2\right) \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le 2.75926987569438465265365262313324024035 \cdot 10^{-5}:\\
\;\;\;\;\frac{{\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}^{3} - {b}^{3}}{\left(\left(b \cdot \left(\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b\right) + b\right) - 4 \cdot \left(a \cdot c\right)\right) \cdot 2\right) \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r27115 = b;
        double r27116 = -r27115;
        double r27117 = r27115 * r27115;
        double r27118 = 4.0;
        double r27119 = a;
        double r27120 = r27118 * r27119;
        double r27121 = c;
        double r27122 = r27120 * r27121;
        double r27123 = r27117 - r27122;
        double r27124 = sqrt(r27123);
        double r27125 = r27116 + r27124;
        double r27126 = 2.0;
        double r27127 = r27126 * r27119;
        double r27128 = r27125 / r27127;
        return r27128;
}

double f(double a, double b, double c) {
        double r27129 = b;
        double r27130 = 2.7592698756943847e-05;
        bool r27131 = r27129 <= r27130;
        double r27132 = r27129 * r27129;
        double r27133 = 4.0;
        double r27134 = a;
        double r27135 = r27133 * r27134;
        double r27136 = c;
        double r27137 = r27135 * r27136;
        double r27138 = r27132 - r27137;
        double r27139 = sqrt(r27138);
        double r27140 = 3.0;
        double r27141 = pow(r27139, r27140);
        double r27142 = pow(r27129, r27140);
        double r27143 = r27141 - r27142;
        double r27144 = r27139 + r27129;
        double r27145 = r27144 + r27129;
        double r27146 = r27129 * r27145;
        double r27147 = r27134 * r27136;
        double r27148 = r27133 * r27147;
        double r27149 = r27146 - r27148;
        double r27150 = 2.0;
        double r27151 = r27149 * r27150;
        double r27152 = r27151 * r27134;
        double r27153 = r27143 / r27152;
        double r27154 = -1.0;
        double r27155 = r27136 / r27129;
        double r27156 = r27154 * r27155;
        double r27157 = r27131 ? r27153 : r27156;
        return r27157;
}

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 2 regimes
  2. if b < 2.7592698756943847e-05

    1. Initial program 15.8

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip3--15.9

      \[\leadsto \frac{\color{blue}{\frac{{\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}^{3} - {b}^{3}}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(b \cdot b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot b\right)}}}{2 \cdot a}\]
    5. Applied associate-/l/15.9

      \[\leadsto \color{blue}{\frac{{\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}^{3} - {b}^{3}}{\left(2 \cdot a\right) \cdot \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(b \cdot b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot b\right)\right)}}\]
    6. Simplified15.9

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

    if 2.7592698756943847e-05 < b

    1. Initial program 45.7

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

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

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

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

Reproduce

herbie shell --seed 2019303 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e15) (< 1.11022e-16 b 9.0072e15) (< 1.11022e-16 c 9.0072e15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))