Average Error: 33.4 → 9.7
Time: 33.0s
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 -2.852138444177435 \cdot 10^{-54}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 7.803671648955123 \cdot 10^{+137}:\\ \;\;\;\;-\left(\frac{b_2}{a} + \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\right)\\ \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 -2.852138444177435 \cdot 10^{-54}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r2134600 = b_2;
        double r2134601 = -r2134600;
        double r2134602 = r2134600 * r2134600;
        double r2134603 = a;
        double r2134604 = c;
        double r2134605 = r2134603 * r2134604;
        double r2134606 = r2134602 - r2134605;
        double r2134607 = sqrt(r2134606);
        double r2134608 = r2134601 - r2134607;
        double r2134609 = r2134608 / r2134603;
        return r2134609;
}

double f(double a, double b_2, double c) {
        double r2134610 = b_2;
        double r2134611 = -2.852138444177435e-54;
        bool r2134612 = r2134610 <= r2134611;
        double r2134613 = -0.5;
        double r2134614 = c;
        double r2134615 = r2134614 / r2134610;
        double r2134616 = r2134613 * r2134615;
        double r2134617 = 7.803671648955123e+137;
        bool r2134618 = r2134610 <= r2134617;
        double r2134619 = a;
        double r2134620 = r2134610 / r2134619;
        double r2134621 = r2134610 * r2134610;
        double r2134622 = r2134614 * r2134619;
        double r2134623 = r2134621 - r2134622;
        double r2134624 = sqrt(r2134623);
        double r2134625 = r2134624 / r2134619;
        double r2134626 = r2134620 + r2134625;
        double r2134627 = -r2134626;
        double r2134628 = -2.0;
        double r2134629 = r2134628 * r2134620;
        double r2134630 = r2134618 ? r2134627 : r2134629;
        double r2134631 = r2134612 ? r2134616 : r2134630;
        return r2134631;
}

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 < -2.852138444177435e-54

    1. Initial program 53.4

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity54.0

      \[\leadsto \frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{\color{blue}{1 \cdot a}}\]
    6. Applied add-sqr-sqrt55.1

      \[\leadsto \frac{-b_2}{a} - \frac{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}}{1 \cdot a}\]
    7. Applied times-frac55.5

      \[\leadsto \frac{-b_2}{a} - \color{blue}{\frac{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}{1} \cdot \frac{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}}\]
    8. Simplified55.5

      \[\leadsto \frac{-b_2}{a} - \color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    9. Taylor expanded around -inf 8.3

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

    if -2.852138444177435e-54 < b_2 < 7.803671648955123e+137

    1. Initial program 12.6

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity12.6

      \[\leadsto \frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{\color{blue}{1 \cdot a}}\]
    6. Applied add-sqr-sqrt12.8

      \[\leadsto \frac{-b_2}{a} - \frac{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}}{1 \cdot a}\]
    7. Applied times-frac12.8

      \[\leadsto \frac{-b_2}{a} - \color{blue}{\frac{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}{1} \cdot \frac{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}}\]
    8. Simplified12.8

      \[\leadsto \frac{-b_2}{a} - \color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    9. Using strategy rm
    10. Applied sub-neg12.8

      \[\leadsto \color{blue}{\frac{-b_2}{a} + \left(-\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \frac{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\right)}\]
    11. Simplified12.6

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

    if 7.803671648955123e+137 < b_2

    1. Initial program 53.1

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    4. Using strategy rm
    5. Applied div-inv53.2

      \[\leadsto \frac{-b_2}{a} - \color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \frac{1}{a}}\]
    6. Applied div-inv53.2

      \[\leadsto \color{blue}{\left(-b_2\right) \cdot \frac{1}{a}} - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \frac{1}{a}\]
    7. Applied distribute-rgt-out--53.2

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

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

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

Reproduce

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