Average Error: 34.1 → 10.4
Time: 16.1s
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 -9.49737499068338874170202339475148683659 \cdot 10^{62}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le -9280942802423784669184:\\ \;\;\;\;\frac{\frac{\left(4 \cdot a\right) \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}{a \cdot 2}\\ \mathbf{elif}\;b \le -2.681359924170041582063143841454222537261 \cdot 10^{-50}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 2.012486287363746365734009384581404883243 \cdot 10^{45}:\\ \;\;\;\;\frac{\frac{1}{a \cdot 2}}{\frac{1}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \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 -9.49737499068338874170202339475148683659 \cdot 10^{62}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

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

\mathbf{elif}\;b \le -2.681359924170041582063143841454222537261 \cdot 10^{-50}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

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

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

\end{array}
double f(double b, double a, double c) {
        double r28346193 = b;
        double r28346194 = -r28346193;
        double r28346195 = r28346193 * r28346193;
        double r28346196 = 4.0;
        double r28346197 = a;
        double r28346198 = r28346196 * r28346197;
        double r28346199 = c;
        double r28346200 = r28346198 * r28346199;
        double r28346201 = r28346195 - r28346200;
        double r28346202 = sqrt(r28346201);
        double r28346203 = r28346194 - r28346202;
        double r28346204 = 2.0;
        double r28346205 = r28346204 * r28346197;
        double r28346206 = r28346203 / r28346205;
        return r28346206;
}

double f(double b, double a, double c) {
        double r28346207 = b;
        double r28346208 = -9.497374990683389e+62;
        bool r28346209 = r28346207 <= r28346208;
        double r28346210 = -1.0;
        double r28346211 = c;
        double r28346212 = r28346211 / r28346207;
        double r28346213 = r28346210 * r28346212;
        double r28346214 = -9.280942802423785e+21;
        bool r28346215 = r28346207 <= r28346214;
        double r28346216 = 4.0;
        double r28346217 = a;
        double r28346218 = r28346216 * r28346217;
        double r28346219 = r28346218 * r28346211;
        double r28346220 = r28346207 * r28346207;
        double r28346221 = r28346220 - r28346219;
        double r28346222 = sqrt(r28346221);
        double r28346223 = r28346222 - r28346207;
        double r28346224 = r28346219 / r28346223;
        double r28346225 = 2.0;
        double r28346226 = r28346217 * r28346225;
        double r28346227 = r28346224 / r28346226;
        double r28346228 = -2.6813599241700416e-50;
        bool r28346229 = r28346207 <= r28346228;
        double r28346230 = 2.0124862873637464e+45;
        bool r28346231 = r28346207 <= r28346230;
        double r28346232 = 1.0;
        double r28346233 = r28346232 / r28346226;
        double r28346234 = -r28346207;
        double r28346235 = r28346234 - r28346222;
        double r28346236 = r28346232 / r28346235;
        double r28346237 = r28346233 / r28346236;
        double r28346238 = r28346207 / r28346217;
        double r28346239 = r28346212 - r28346238;
        double r28346240 = 1.0;
        double r28346241 = r28346239 * r28346240;
        double r28346242 = r28346231 ? r28346237 : r28346241;
        double r28346243 = r28346229 ? r28346213 : r28346242;
        double r28346244 = r28346215 ? r28346227 : r28346243;
        double r28346245 = r28346209 ? r28346213 : r28346244;
        return r28346245;
}

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 4 regimes
  2. if b < -9.497374990683389e+62 or -9.280942802423785e+21 < b < -2.6813599241700416e-50

    1. Initial program 54.6

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

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

    if -9.497374990683389e+62 < b < -9.280942802423785e+21

    1. Initial program 47.0

      \[\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--47.0

      \[\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. Simplified14.0

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

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

    if -2.6813599241700416e-50 < b < 2.0124862873637464e+45

    1. Initial program 14.8

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

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\]
    4. Using strategy rm
    5. Applied div-inv15.0

      \[\leadsto \frac{1}{\color{blue}{\left(2 \cdot a\right) \cdot \frac{1}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\]
    6. Applied associate-/r*15.0

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

    if 2.0124862873637464e+45 < b

    1. Initial program 37.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -9.49737499068338874170202339475148683659 \cdot 10^{62}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le -9280942802423784669184:\\ \;\;\;\;\frac{\frac{\left(4 \cdot a\right) \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}{a \cdot 2}\\ \mathbf{elif}\;b \le -2.681359924170041582063143841454222537261 \cdot 10^{-50}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 2.012486287363746365734009384581404883243 \cdot 10^{45}:\\ \;\;\;\;\frac{\frac{1}{a \cdot 2}}{\frac{1}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (b a c)
  :name "(-b - sqrt(b*b-4*a*c))/(2*a)"
  (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))