Average Error: 33.8 → 9.1
Time: 25.5s
Precision: 64
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -1.970010565552108757188050455448622102575 \cdot 10^{58}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.341090161490938310878248498686683235407 \cdot 10^{-308}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 3.628799960716311990444092539387346352569 \cdot 10^{50}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}{-a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \le -1.970010565552108757188050455448622102575 \cdot 10^{58}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -1.341090161490938310878248498686683235407 \cdot 10^{-308}:\\
\;\;\;\;\frac{\frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{a}\\

\mathbf{elif}\;b_2 \le 3.628799960716311990444092539387346352569 \cdot 10^{50}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}{-a}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\

\end{array}
double f(double a, double b_2, double c) {
        double r876289 = b_2;
        double r876290 = -r876289;
        double r876291 = r876289 * r876289;
        double r876292 = a;
        double r876293 = c;
        double r876294 = r876292 * r876293;
        double r876295 = r876291 - r876294;
        double r876296 = sqrt(r876295);
        double r876297 = r876290 - r876296;
        double r876298 = r876297 / r876292;
        return r876298;
}

double f(double a, double b_2, double c) {
        double r876299 = b_2;
        double r876300 = -1.9700105655521088e+58;
        bool r876301 = r876299 <= r876300;
        double r876302 = -0.5;
        double r876303 = c;
        double r876304 = r876303 / r876299;
        double r876305 = r876302 * r876304;
        double r876306 = -1.3410901614909383e-308;
        bool r876307 = r876299 <= r876306;
        double r876308 = a;
        double r876309 = r876303 * r876308;
        double r876310 = r876299 * r876299;
        double r876311 = r876310 - r876309;
        double r876312 = sqrt(r876311);
        double r876313 = r876312 - r876299;
        double r876314 = r876309 / r876313;
        double r876315 = r876314 / r876308;
        double r876316 = 3.628799960716312e+50;
        bool r876317 = r876299 <= r876316;
        double r876318 = r876312 + r876299;
        double r876319 = -r876308;
        double r876320 = r876318 / r876319;
        double r876321 = -2.0;
        double r876322 = r876299 / r876308;
        double r876323 = r876321 * r876322;
        double r876324 = r876317 ? r876320 : r876323;
        double r876325 = r876307 ? r876315 : r876324;
        double r876326 = r876301 ? r876305 : r876325;
        return r876326;
}

Error

Bits error versus a

Bits error versus b_2

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_2 < -1.9700105655521088e+58

    1. Initial program 57.5

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

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

    if -1.9700105655521088e+58 < b_2 < -1.3410901614909383e-308

    1. Initial program 29.4

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--29.4

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Simplified16.7

      \[\leadsto \frac{\frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Simplified16.7

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]

    if -1.3410901614909383e-308 < b_2 < 3.628799960716312e+50

    1. Initial program 9.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied frac-2neg9.7

      \[\leadsto \color{blue}{\frac{-\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{-a}}\]
    4. Simplified9.7

      \[\leadsto \frac{\color{blue}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{-a}\]

    if 3.628799960716312e+50 < b_2

    1. Initial program 38.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied clear-num38.2

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

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.970010565552108757188050455448622102575 \cdot 10^{58}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.341090161490938310878248498686683235407 \cdot 10^{-308}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 3.628799960716311990444092539387346352569 \cdot 10^{50}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}{-a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))