Average Error: 33.8 → 6.8
Time: 7.6s
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.12428337420519208 \cdot 10^{57}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -2.6559623908913229 \cdot 10^{-256}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 4.1445535679869069 \cdot 10^{60}:\\ \;\;\;\;\frac{1}{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{0.5}{c}}\\ \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 -3.12428337420519208 \cdot 10^{57}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\mathbf{elif}\;b \le 4.1445535679869069 \cdot 10^{60}:\\
\;\;\;\;\frac{1}{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{0.5}{c}}\\

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

\end{array}
double f(double a, double b, double c) {
        double r23032 = b;
        double r23033 = -r23032;
        double r23034 = r23032 * r23032;
        double r23035 = 4.0;
        double r23036 = a;
        double r23037 = r23035 * r23036;
        double r23038 = c;
        double r23039 = r23037 * r23038;
        double r23040 = r23034 - r23039;
        double r23041 = sqrt(r23040);
        double r23042 = r23033 + r23041;
        double r23043 = 2.0;
        double r23044 = r23043 * r23036;
        double r23045 = r23042 / r23044;
        return r23045;
}

double f(double a, double b, double c) {
        double r23046 = b;
        double r23047 = -3.124283374205192e+57;
        bool r23048 = r23046 <= r23047;
        double r23049 = 1.0;
        double r23050 = c;
        double r23051 = r23050 / r23046;
        double r23052 = a;
        double r23053 = r23046 / r23052;
        double r23054 = r23051 - r23053;
        double r23055 = r23049 * r23054;
        double r23056 = -2.655962390891323e-256;
        bool r23057 = r23046 <= r23056;
        double r23058 = -r23046;
        double r23059 = r23046 * r23046;
        double r23060 = 4.0;
        double r23061 = r23060 * r23052;
        double r23062 = r23061 * r23050;
        double r23063 = r23059 - r23062;
        double r23064 = sqrt(r23063);
        double r23065 = r23058 + r23064;
        double r23066 = 2.0;
        double r23067 = r23066 * r23052;
        double r23068 = r23065 / r23067;
        double r23069 = 4.144553567986907e+60;
        bool r23070 = r23046 <= r23069;
        double r23071 = 1.0;
        double r23072 = r23052 * r23050;
        double r23073 = r23060 * r23072;
        double r23074 = r23059 - r23073;
        double r23075 = sqrt(r23074);
        double r23076 = r23058 - r23075;
        double r23077 = 0.5;
        double r23078 = r23077 / r23050;
        double r23079 = r23076 * r23078;
        double r23080 = r23071 / r23079;
        double r23081 = -1.0;
        double r23082 = r23081 * r23051;
        double r23083 = r23070 ? r23080 : r23082;
        double r23084 = r23057 ? r23068 : r23083;
        double r23085 = r23048 ? r23055 : r23084;
        return r23085;
}

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 < -3.124283374205192e+57

    1. Initial program 39.5

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

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

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

    if -3.124283374205192e+57 < b < -2.655962390891323e-256

    1. Initial program 8.1

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

    if -2.655962390891323e-256 < b < 4.144553567986907e+60

    1. Initial program 28.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-+28.5

      \[\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. Simplified16.8

      \[\leadsto \frac{\frac{\color{blue}{b \cdot \left(b - b\right) + 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 *-un-lft-identity16.8

      \[\leadsto \frac{\frac{b \cdot \left(b - b\right) + 4 \cdot \left(a \cdot c\right)}{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
    7. Applied *-un-lft-identity16.8

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

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{b \cdot \left(b - b\right) + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
    9. Applied associate-/l*16.9

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

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

      \[\leadsto \frac{\frac{1}{1}}{\left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \color{blue}{\frac{0.5}{c}}}\]
    12. Taylor expanded around 0 10.1

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

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

    if 4.144553567986907e+60 < b

    1. Initial program 58.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.12428337420519208 \cdot 10^{57}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -2.6559623908913229 \cdot 10^{-256}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 4.1445535679869069 \cdot 10^{60}:\\ \;\;\;\;\frac{1}{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{0.5}{c}}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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