Average Error: 33.5 → 10.0
Time: 23.5s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.7279872839456578 \cdot 10^{+63}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 2.5928684081554055 \cdot 10^{-64}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2}}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -1.7279872839456578 \cdot 10^{+63}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

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

\end{array}
double f(double b, double a, double c) {
        double r3322086 = b;
        double r3322087 = -r3322086;
        double r3322088 = 2.0;
        double r3322089 = pow(r3322086, r3322088);
        double r3322090 = 4.0;
        double r3322091 = a;
        double r3322092 = r3322090 * r3322091;
        double r3322093 = c;
        double r3322094 = r3322092 * r3322093;
        double r3322095 = r3322089 - r3322094;
        double r3322096 = sqrt(r3322095);
        double r3322097 = r3322087 + r3322096;
        double r3322098 = r3322088 * r3322091;
        double r3322099 = r3322097 / r3322098;
        return r3322099;
}

double f(double b, double a, double c) {
        double r3322100 = b;
        double r3322101 = -1.7279872839456578e+63;
        bool r3322102 = r3322100 <= r3322101;
        double r3322103 = c;
        double r3322104 = r3322103 / r3322100;
        double r3322105 = a;
        double r3322106 = r3322100 / r3322105;
        double r3322107 = r3322104 - r3322106;
        double r3322108 = 2.5928684081554055e-64;
        bool r3322109 = r3322100 <= r3322108;
        double r3322110 = 1.0;
        double r3322111 = r3322100 * r3322100;
        double r3322112 = 4.0;
        double r3322113 = r3322112 * r3322105;
        double r3322114 = r3322103 * r3322113;
        double r3322115 = r3322111 - r3322114;
        double r3322116 = sqrt(r3322115);
        double r3322117 = r3322116 - r3322100;
        double r3322118 = 2.0;
        double r3322119 = r3322117 / r3322118;
        double r3322120 = r3322105 / r3322119;
        double r3322121 = r3322110 / r3322120;
        double r3322122 = -r3322104;
        double r3322123 = r3322109 ? r3322121 : r3322122;
        double r3322124 = r3322102 ? r3322107 : r3322123;
        return r3322124;
}

Error

Bits error versus b

Bits error versus a

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.7279872839456578e+63

    1. Initial program 38.4

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

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

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]

    if -1.7279872839456578e+63 < b < 2.5928684081554055e-64

    1. Initial program 13.2

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

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

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

      \[\leadsto \frac{\frac{\sqrt{\color{blue}{b \cdot b - c \cdot \left(a \cdot 4\right)}} - b}{2}}{a}\]
    5. Using strategy rm
    6. Applied clear-num13.3

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

    if 2.5928684081554055e-64 < b

    1. Initial program 53.0

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.7279872839456578 \cdot 10^{+63}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 2.5928684081554055 \cdot 10^{-64}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2}}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (b a c)
  :name "(-b+sqrt(b^2-4*a*c))/(2*a)"
  (/ (+ (- b) (sqrt (- (pow b 2) (* (* 4 a) c)))) (* 2 a)))