Average Error: 33.9 → 10.5
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.5961406266953245 \cdot 10^{-58}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.1115579814291686 \cdot 10^{+29}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot 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.5961406266953245 \cdot 10^{-58}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 3.1115579814291686 \cdot 10^{+29}:\\
\;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r2718601 = b_2;
        double r2718602 = -r2718601;
        double r2718603 = r2718601 * r2718601;
        double r2718604 = a;
        double r2718605 = c;
        double r2718606 = r2718604 * r2718605;
        double r2718607 = r2718603 - r2718606;
        double r2718608 = sqrt(r2718607);
        double r2718609 = r2718602 - r2718608;
        double r2718610 = r2718609 / r2718604;
        return r2718610;
}

double f(double a, double b_2, double c) {
        double r2718611 = b_2;
        double r2718612 = -1.5961406266953245e-58;
        bool r2718613 = r2718611 <= r2718612;
        double r2718614 = -0.5;
        double r2718615 = c;
        double r2718616 = r2718615 / r2718611;
        double r2718617 = r2718614 * r2718616;
        double r2718618 = 3.1115579814291686e+29;
        bool r2718619 = r2718611 <= r2718618;
        double r2718620 = 1.0;
        double r2718621 = a;
        double r2718622 = -r2718611;
        double r2718623 = r2718611 * r2718611;
        double r2718624 = r2718615 * r2718621;
        double r2718625 = r2718623 - r2718624;
        double r2718626 = sqrt(r2718625);
        double r2718627 = r2718622 - r2718626;
        double r2718628 = r2718621 / r2718627;
        double r2718629 = r2718620 / r2718628;
        double r2718630 = -2.0;
        double r2718631 = r2718611 / r2718621;
        double r2718632 = r2718630 * r2718631;
        double r2718633 = r2718619 ? r2718629 : r2718632;
        double r2718634 = r2718613 ? r2718617 : r2718633;
        return r2718634;
}

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 3 regimes
  2. if b_2 < -1.5961406266953245e-58

    1. Initial program 53.4

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

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

    if -1.5961406266953245e-58 < b_2 < 3.1115579814291686e+29

    1. Initial program 14.7

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified14.7

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity14.7

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    6. Applied associate-/l*14.8

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

    if 3.1115579814291686e+29 < b_2

    1. Initial program 34.4

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

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity34.4

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    6. Applied associate-/l*34.5

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    7. Using strategy rm
    8. Applied associate-/r/34.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.5961406266953245 \cdot 10^{-58}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.1115579814291686 \cdot 10^{+29}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019134 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))