Average Error: 34.7 → 10.2
Time: 32.7s
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.270528699455007486596308100489334356636 \cdot 10^{152}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\ \mathbf{elif}\;b \le 1.744031351412432972171902712116585209201 \cdot 10^{-142}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -1\\ \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.270528699455007486596308100489334356636 \cdot 10^{152}:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r2203800 = b;
        double r2203801 = -r2203800;
        double r2203802 = r2203800 * r2203800;
        double r2203803 = 4.0;
        double r2203804 = a;
        double r2203805 = r2203803 * r2203804;
        double r2203806 = c;
        double r2203807 = r2203805 * r2203806;
        double r2203808 = r2203802 - r2203807;
        double r2203809 = sqrt(r2203808);
        double r2203810 = r2203801 + r2203809;
        double r2203811 = 2.0;
        double r2203812 = r2203811 * r2203804;
        double r2203813 = r2203810 / r2203812;
        return r2203813;
}

double f(double a, double b, double c) {
        double r2203814 = b;
        double r2203815 = -1.2705286994550075e+152;
        bool r2203816 = r2203814 <= r2203815;
        double r2203817 = c;
        double r2203818 = r2203817 / r2203814;
        double r2203819 = a;
        double r2203820 = r2203814 / r2203819;
        double r2203821 = r2203818 - r2203820;
        double r2203822 = 1.0;
        double r2203823 = r2203821 * r2203822;
        double r2203824 = 1.744031351412433e-142;
        bool r2203825 = r2203814 <= r2203824;
        double r2203826 = r2203814 * r2203814;
        double r2203827 = 4.0;
        double r2203828 = r2203817 * r2203827;
        double r2203829 = r2203828 * r2203819;
        double r2203830 = r2203826 - r2203829;
        double r2203831 = sqrt(r2203830);
        double r2203832 = r2203831 - r2203814;
        double r2203833 = 2.0;
        double r2203834 = r2203819 * r2203833;
        double r2203835 = r2203832 / r2203834;
        double r2203836 = -1.0;
        double r2203837 = r2203818 * r2203836;
        double r2203838 = r2203825 ? r2203835 : r2203837;
        double r2203839 = r2203816 ? r2203823 : r2203838;
        return r2203839;
}

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.2705286994550075e+152

    1. Initial program 62.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv62.9

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

      \[\leadsto \color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\]
    5. Simplified1.7

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

    if -1.2705286994550075e+152 < b < 1.744031351412433e-142

    1. Initial program 10.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv10.5

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

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

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

    if 1.744031351412433e-142 < b

    1. Initial program 50.7

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

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

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

Reproduce

herbie shell --seed 2019168 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))