Average Error: 34.2 → 8.1
Time: 5.9s
Precision: 64
\[\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 -8.55528137777049654 \cdot 10^{140}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 9.52089004516141949 \cdot 10^{-271}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 26039420339585284:\\ \;\;\;\;\frac{\frac{1}{\frac{\frac{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{4}}{a}}{c}}}{2 \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 -8.55528137777049654 \cdot 10^{140}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

\mathbf{elif}\;b \le 9.52089004516141949 \cdot 10^{-271}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

\mathbf{elif}\;b \le 26039420339585284:\\
\;\;\;\;\frac{\frac{1}{\frac{\frac{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{4}}{a}}{c}}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r56108 = b;
        double r56109 = -r56108;
        double r56110 = r56108 * r56108;
        double r56111 = 4.0;
        double r56112 = a;
        double r56113 = r56111 * r56112;
        double r56114 = c;
        double r56115 = r56113 * r56114;
        double r56116 = r56110 - r56115;
        double r56117 = sqrt(r56116);
        double r56118 = r56109 + r56117;
        double r56119 = 2.0;
        double r56120 = r56119 * r56112;
        double r56121 = r56118 / r56120;
        return r56121;
}

double f(double a, double b, double c) {
        double r56122 = b;
        double r56123 = -8.555281377770497e+140;
        bool r56124 = r56122 <= r56123;
        double r56125 = 1.0;
        double r56126 = c;
        double r56127 = r56126 / r56122;
        double r56128 = a;
        double r56129 = r56122 / r56128;
        double r56130 = r56127 - r56129;
        double r56131 = r56125 * r56130;
        double r56132 = 9.52089004516142e-271;
        bool r56133 = r56122 <= r56132;
        double r56134 = -r56122;
        double r56135 = r56122 * r56122;
        double r56136 = 4.0;
        double r56137 = r56136 * r56128;
        double r56138 = r56137 * r56126;
        double r56139 = r56135 - r56138;
        double r56140 = sqrt(r56139);
        double r56141 = r56134 + r56140;
        double r56142 = 2.0;
        double r56143 = r56142 * r56128;
        double r56144 = r56141 / r56143;
        double r56145 = 26039420339585284.0;
        bool r56146 = r56122 <= r56145;
        double r56147 = 1.0;
        double r56148 = r56134 - r56140;
        double r56149 = r56148 / r56136;
        double r56150 = r56149 / r56128;
        double r56151 = r56150 / r56126;
        double r56152 = r56147 / r56151;
        double r56153 = r56152 / r56143;
        double r56154 = -1.0;
        double r56155 = r56154 * r56127;
        double r56156 = r56146 ? r56153 : r56155;
        double r56157 = r56133 ? r56144 : r56156;
        double r56158 = r56124 ? r56131 : r56157;
        return r56158;
}

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 4 regimes
  2. if b < -8.555281377770497e+140

    1. Initial program 58.5

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

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

      \[\leadsto \frac{\frac{\color{blue}{0 + 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num62.7

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{0 + 4 \cdot \left(a \cdot c\right)}}}}{2 \cdot a}\]
    7. Simplified62.7

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

      \[\leadsto \color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\]
    9. Simplified2.4

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

    if -8.555281377770497e+140 < b < 9.52089004516142e-271

    1. Initial program 9.7

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

    if 9.52089004516142e-271 < b < 26039420339585284.0

    1. Initial program 27.1

      \[\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-+27.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. Simplified17.0

      \[\leadsto \frac{\frac{\color{blue}{0 + 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num17.1

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{0 + 4 \cdot \left(a \cdot c\right)}}}}{2 \cdot a}\]
    7. Simplified17.1

      \[\leadsto \frac{\frac{1}{\color{blue}{\frac{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{4}}{a \cdot c}}}}{2 \cdot a}\]
    8. Using strategy rm
    9. Applied associate-/r*14.2

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

    if 26039420339585284.0 < b

    1. Initial program 56.0

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

      \[\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. Simplified26.6

      \[\leadsto \frac{\frac{\color{blue}{0 + 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num26.8

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{0 + 4 \cdot \left(a \cdot c\right)}}}}{2 \cdot a}\]
    7. Simplified26.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -8.55528137777049654 \cdot 10^{140}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 9.52089004516141949 \cdot 10^{-271}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 26039420339585284:\\ \;\;\;\;\frac{\frac{1}{\frac{\frac{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{4}}{a}}{c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2020046 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))