Average Error: 34.1 → 10.0
Time: 18.2s
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 -1.11981154530853106611761327467786604265 \cdot 10^{143}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 4.718890261991468628346768591871377778707 \cdot 10^{-106}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{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 -1.11981154530853106611761327467786604265 \cdot 10^{143}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r45163 = b;
        double r45164 = -r45163;
        double r45165 = r45163 * r45163;
        double r45166 = 4.0;
        double r45167 = a;
        double r45168 = r45166 * r45167;
        double r45169 = c;
        double r45170 = r45168 * r45169;
        double r45171 = r45165 - r45170;
        double r45172 = sqrt(r45171);
        double r45173 = r45164 + r45172;
        double r45174 = 2.0;
        double r45175 = r45174 * r45167;
        double r45176 = r45173 / r45175;
        return r45176;
}

double f(double a, double b, double c) {
        double r45177 = b;
        double r45178 = -1.119811545308531e+143;
        bool r45179 = r45177 <= r45178;
        double r45180 = 1.0;
        double r45181 = c;
        double r45182 = r45181 / r45177;
        double r45183 = a;
        double r45184 = r45177 / r45183;
        double r45185 = r45182 - r45184;
        double r45186 = r45180 * r45185;
        double r45187 = 4.718890261991469e-106;
        bool r45188 = r45177 <= r45187;
        double r45189 = r45177 * r45177;
        double r45190 = 4.0;
        double r45191 = r45190 * r45183;
        double r45192 = r45191 * r45181;
        double r45193 = r45189 - r45192;
        double r45194 = sqrt(r45193);
        double r45195 = r45194 - r45177;
        double r45196 = 2.0;
        double r45197 = r45196 * r45183;
        double r45198 = r45195 / r45197;
        double r45199 = -1.0;
        double r45200 = r45199 * r45182;
        double r45201 = r45188 ? r45198 : r45200;
        double r45202 = r45179 ? r45186 : r45201;
        return r45202;
}

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 3 regimes
  2. if b < -1.119811545308531e+143

    1. Initial program 59.0

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

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

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

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

    if -1.119811545308531e+143 < b < 4.718890261991469e-106

    1. Initial program 11.1

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

      \[\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 div-inv11.2

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

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

      \[\leadsto \color{blue}{{\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right)}^{1}} \cdot {\left(\frac{1}{2 \cdot a}\right)}^{1}\]
    8. Applied pow-prod-down11.2

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

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

    if 4.718890261991469e-106 < b

    1. Initial program 52.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.11981154530853106611761327467786604265 \cdot 10^{143}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 4.718890261991468628346768591871377778707 \cdot 10^{-106}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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