Average Error: 33.5 → 10.0
Time: 9.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.478406535480561669630649836752919254545 \cdot 10^{60}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 2.175674080408202904737521150531781836244 \cdot 10^{-169}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.705250296078930544323375298653357812472 \cdot 10^{-110} \lor \neg \left(b \le 29494967590524297216\right):\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(c \cdot 4\right) \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \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.478406535480561669630649836752919254545 \cdot 10^{60}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\mathbf{elif}\;b \le 3.705250296078930544323375298653357812472 \cdot 10^{-110} \lor \neg \left(b \le 29494967590524297216\right):\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(c \cdot 4\right) \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\

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

double f(double a, double b, double c) {
        double r45180 = b;
        double r45181 = -1.4784065354805617e+60;
        bool r45182 = r45180 <= r45181;
        double r45183 = 1.0;
        double r45184 = c;
        double r45185 = r45184 / r45180;
        double r45186 = a;
        double r45187 = r45180 / r45186;
        double r45188 = r45185 - r45187;
        double r45189 = r45183 * r45188;
        double r45190 = 2.175674080408203e-169;
        bool r45191 = r45180 <= r45190;
        double r45192 = -r45180;
        double r45193 = r45180 * r45180;
        double r45194 = 4.0;
        double r45195 = r45194 * r45186;
        double r45196 = r45195 * r45184;
        double r45197 = r45193 - r45196;
        double r45198 = sqrt(r45197);
        double r45199 = r45192 + r45198;
        double r45200 = 2.0;
        double r45201 = r45200 * r45186;
        double r45202 = r45199 / r45201;
        double r45203 = 3.7052502960789305e-110;
        bool r45204 = r45180 <= r45203;
        double r45205 = 2.9494967590524297e+19;
        bool r45206 = r45180 <= r45205;
        double r45207 = !r45206;
        bool r45208 = r45204 || r45207;
        double r45209 = -1.0;
        double r45210 = r45209 * r45185;
        double r45211 = r45184 * r45194;
        double r45212 = r45211 * r45186;
        double r45213 = r45192 - r45198;
        double r45214 = r45212 / r45213;
        double r45215 = r45214 / r45201;
        double r45216 = r45208 ? r45210 : r45215;
        double r45217 = r45191 ? r45202 : r45216;
        double r45218 = r45182 ? r45189 : r45217;
        return r45218;
}

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 < -1.4784065354805617e+60

    1. Initial program 39.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 *-un-lft-identity39.0

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

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

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

    if -1.4784065354805617e+60 < b < 2.175674080408203e-169

    1. Initial program 10.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity10.7

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

    if 2.175674080408203e-169 < b < 3.7052502960789305e-110 or 2.9494967590524297e+19 < b

    1. Initial program 52.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 *-un-lft-identity52.0

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

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

    if 3.7052502960789305e-110 < b < 2.9494967590524297e+19

    1. Initial program 37.3

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

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

      \[\leadsto 1 \cdot \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}\]
    6. Simplified16.3

      \[\leadsto 1 \cdot \frac{\frac{\color{blue}{0 + \left(c \cdot 4\right) \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification10.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.478406535480561669630649836752919254545 \cdot 10^{60}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 2.175674080408202904737521150531781836244 \cdot 10^{-169}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.705250296078930544323375298653357812472 \cdot 10^{-110} \lor \neg \left(b \le 29494967590524297216\right):\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(c \cdot 4\right) \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \end{array}\]

Reproduce

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