Average Error: 33.6 → 9.9
Time: 18.5s
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 -3.396811349079212 \cdot 10^{+61}:\\ \;\;\;\;\frac{\left(\frac{c}{\frac{b}{a}} - b\right) \cdot 2}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.3659668388152999 \cdot 10^{-67}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}\\ \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}\;b \le -3.396811349079212 \cdot 10^{+61}:\\
\;\;\;\;\frac{\left(\frac{c}{\frac{b}{a}} - b\right) \cdot 2}{2 \cdot a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r1656285 = b;
        double r1656286 = -r1656285;
        double r1656287 = r1656285 * r1656285;
        double r1656288 = 4.0;
        double r1656289 = a;
        double r1656290 = r1656288 * r1656289;
        double r1656291 = c;
        double r1656292 = r1656290 * r1656291;
        double r1656293 = r1656287 - r1656292;
        double r1656294 = sqrt(r1656293);
        double r1656295 = r1656286 + r1656294;
        double r1656296 = 2.0;
        double r1656297 = r1656296 * r1656289;
        double r1656298 = r1656295 / r1656297;
        return r1656298;
}

double f(double a, double b, double c) {
        double r1656299 = b;
        double r1656300 = -3.396811349079212e+61;
        bool r1656301 = r1656299 <= r1656300;
        double r1656302 = c;
        double r1656303 = a;
        double r1656304 = r1656299 / r1656303;
        double r1656305 = r1656302 / r1656304;
        double r1656306 = r1656305 - r1656299;
        double r1656307 = 2.0;
        double r1656308 = r1656306 * r1656307;
        double r1656309 = r1656307 * r1656303;
        double r1656310 = r1656308 / r1656309;
        double r1656311 = 1.3659668388152999e-67;
        bool r1656312 = r1656299 <= r1656311;
        double r1656313 = r1656299 * r1656299;
        double r1656314 = r1656302 * r1656303;
        double r1656315 = 4.0;
        double r1656316 = r1656314 * r1656315;
        double r1656317 = r1656313 - r1656316;
        double r1656318 = sqrt(r1656317);
        double r1656319 = r1656318 - r1656299;
        double r1656320 = r1656319 / r1656309;
        double r1656321 = -r1656302;
        double r1656322 = r1656321 / r1656299;
        double r1656323 = r1656312 ? r1656320 : r1656322;
        double r1656324 = r1656301 ? r1656310 : r1656323;
        return r1656324;
}

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 < -3.396811349079212e+61

    1. Initial program 37.6

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

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

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

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

    if -3.396811349079212e+61 < b < 1.3659668388152999e-67

    1. Initial program 13.9

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

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

    if 1.3659668388152999e-67 < b

    1. Initial program 53.0

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

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

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

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

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

Reproduce

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