Average Error: 19.6 → 6.9
Time: 17.5s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.333835582926585050250881012823307756098 \cdot 10^{154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 \cdot \left(\frac{a}{b} - \frac{b}{c}\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 4.620002785864606786875053449427149180535 \cdot 10^{67}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - b \cdot b}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

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

\end{array}
\begin{array}{l}
\mathbf{if}\;b \le -1.333835582926585050250881012823307756098 \cdot 10^{154}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\end{array}\\

\mathbf{elif}\;b \le 4.620002785864606786875053449427149180535 \cdot 10^{67}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\

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

\end{array}\\

\mathbf{elif}\;b \ge 0.0:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\end{array}
double f(double a, double b, double c) {
        double r51290 = b;
        double r51291 = 0.0;
        bool r51292 = r51290 >= r51291;
        double r51293 = -r51290;
        double r51294 = r51290 * r51290;
        double r51295 = 4.0;
        double r51296 = a;
        double r51297 = r51295 * r51296;
        double r51298 = c;
        double r51299 = r51297 * r51298;
        double r51300 = r51294 - r51299;
        double r51301 = sqrt(r51300);
        double r51302 = r51293 - r51301;
        double r51303 = 2.0;
        double r51304 = r51303 * r51296;
        double r51305 = r51302 / r51304;
        double r51306 = r51303 * r51298;
        double r51307 = r51293 + r51301;
        double r51308 = r51306 / r51307;
        double r51309 = r51292 ? r51305 : r51308;
        return r51309;
}

double f(double a, double b, double c) {
        double r51310 = b;
        double r51311 = -1.333835582926585e+154;
        bool r51312 = r51310 <= r51311;
        double r51313 = 0.0;
        bool r51314 = r51310 >= r51313;
        double r51315 = 1.0;
        double r51316 = c;
        double r51317 = r51316 / r51310;
        double r51318 = a;
        double r51319 = r51310 / r51318;
        double r51320 = r51317 - r51319;
        double r51321 = r51315 * r51320;
        double r51322 = 1.0;
        double r51323 = r51318 / r51310;
        double r51324 = r51310 / r51316;
        double r51325 = r51323 - r51324;
        double r51326 = r51315 * r51325;
        double r51327 = r51322 / r51326;
        double r51328 = r51314 ? r51321 : r51327;
        double r51329 = 4.620002785864607e+67;
        bool r51330 = r51310 <= r51329;
        double r51331 = -r51310;
        double r51332 = r51310 * r51310;
        double r51333 = 4.0;
        double r51334 = r51333 * r51318;
        double r51335 = r51334 * r51316;
        double r51336 = r51332 - r51335;
        double r51337 = sqrt(r51336);
        double r51338 = sqrt(r51337);
        double r51339 = r51338 * r51338;
        double r51340 = r51331 - r51339;
        double r51341 = 2.0;
        double r51342 = r51341 * r51318;
        double r51343 = r51340 / r51342;
        double r51344 = r51341 * r51316;
        double r51345 = r51337 - r51310;
        double r51346 = r51344 / r51345;
        double r51347 = r51314 ? r51343 : r51346;
        double r51348 = r51336 - r51332;
        double r51349 = r51337 + r51310;
        double r51350 = r51348 / r51349;
        double r51351 = r51344 / r51350;
        double r51352 = r51314 ? r51321 : r51351;
        double r51353 = r51330 ? r51347 : r51352;
        double r51354 = r51312 ? r51328 : r51353;
        return r51354;
}

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.333835582926585e+154

    1. Initial program 37.8

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified37.8

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Taylor expanded around inf 37.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
    4. Taylor expanded around 0 37.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
    5. Simplified37.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\color{blue}{1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
    6. Using strategy rm
    7. Applied clear-num37.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot c}}\\ \end{array}\]
    8. Taylor expanded around -inf 1.9

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\color{blue}{\frac{1}{1 \cdot \frac{a}{b} - 1 \cdot \frac{b}{c}}}\\ \end{array}\]
    9. Simplified1.9

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\color{blue}{\frac{1}{1 \cdot \left(\frac{a}{b} - \frac{b}{c}\right)}}\\ \end{array}\]

    if -1.333835582926585e+154 < b < 4.620002785864607e+67

    1. Initial program 8.6

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified8.6

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt8.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\color{blue}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
    5. Applied sqrt-prod8.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]

    if 4.620002785864607e+67 < b

    1. Initial program 40.5

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified40.5

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Taylor expanded around inf 10.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
    4. Taylor expanded around 0 5.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
    5. Simplified5.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\color{blue}{1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
    6. Using strategy rm
    7. Applied flip--5.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\color{blue}{\frac{2 \cdot c}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b \cdot b}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}}\\ \end{array}\]
    8. Simplified5.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\color{blue}{2 \cdot c}}{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - b \cdot b}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification6.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.333835582926585050250881012823307756098 \cdot 10^{154}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 \cdot \left(\frac{a}{b} - \frac{b}{c}\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 4.620002785864606786875053449427149180535 \cdot 10^{67}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\frac{\left(b \cdot b - \left(4 \cdot a\right) \cdot c\right) - b \cdot b}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019304 
(FPCore (a b c)
  :name "jeff quadratic root 1"
  :precision binary64
  (if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))))