Average Error: 43.8 → 10.4
Time: 16.3s
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(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -1.7506913033883893 \cdot 10^{-08}:\\ \;\;\;\;\frac{b \cdot b - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\\ \mathbf{else}:\\ \;\;\;\;\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}\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a} \le -1.7506913033883893 \cdot 10^{-08}:\\
\;\;\;\;\frac{b \cdot b - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1767082 = b;
        double r1767083 = -r1767082;
        double r1767084 = r1767082 * r1767082;
        double r1767085 = 4.0;
        double r1767086 = a;
        double r1767087 = r1767085 * r1767086;
        double r1767088 = c;
        double r1767089 = r1767087 * r1767088;
        double r1767090 = r1767084 - r1767089;
        double r1767091 = sqrt(r1767090);
        double r1767092 = r1767083 + r1767091;
        double r1767093 = 2.0;
        double r1767094 = r1767093 * r1767086;
        double r1767095 = r1767092 / r1767094;
        return r1767095;
}

double f(double a, double b, double c) {
        double r1767096 = b;
        double r1767097 = r1767096 * r1767096;
        double r1767098 = 4.0;
        double r1767099 = a;
        double r1767100 = r1767098 * r1767099;
        double r1767101 = c;
        double r1767102 = r1767100 * r1767101;
        double r1767103 = r1767097 - r1767102;
        double r1767104 = sqrt(r1767103);
        double r1767105 = -r1767096;
        double r1767106 = r1767104 + r1767105;
        double r1767107 = 2.0;
        double r1767108 = r1767107 * r1767099;
        double r1767109 = r1767106 / r1767108;
        double r1767110 = -1.7506913033883893e-08;
        bool r1767111 = r1767109 <= r1767110;
        double r1767112 = r1767104 * r1767104;
        double r1767113 = r1767097 - r1767112;
        double r1767114 = r1767105 - r1767104;
        double r1767115 = r1767108 * r1767114;
        double r1767116 = r1767113 / r1767115;
        double r1767117 = -r1767101;
        double r1767118 = r1767117 / r1767096;
        double r1767119 = r1767111 ? r1767116 : r1767118;
        return r1767119;
}

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) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) < -1.7506913033883893e-08

    1. Initial program 22.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+22.2

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \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\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
    4. Applied associate-/l/22.2

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

    if -1.7506913033883893e-08 < (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))

    1. Initial program 54.5

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

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

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

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

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(FPCore (a b c)
  :name "Quadratic roots, 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) (* (* 4 a) c)))) (* 2 a)))