Average Error: 33.6 → 10.6
Time: 18.8s
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 -7.363255598823911 \cdot 10^{-15}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.823572975982288 \cdot 10^{-27}:\\ \;\;\;\;\frac{\frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 - c \cdot a\right)}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{elif}\;b_2 \le -2.3344326820285623 \cdot 10^{-123}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.6691257204922504 \cdot 10^{+85}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2}{a} \cdot -2\right)\\ \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 -7.363255598823911 \cdot 10^{-15}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \le -2.3344326820285623 \cdot 10^{-123}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2}{a} \cdot -2\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r2864571 = b_2;
        double r2864572 = -r2864571;
        double r2864573 = r2864571 * r2864571;
        double r2864574 = a;
        double r2864575 = c;
        double r2864576 = r2864574 * r2864575;
        double r2864577 = r2864573 - r2864576;
        double r2864578 = sqrt(r2864577);
        double r2864579 = r2864572 - r2864578;
        double r2864580 = r2864579 / r2864574;
        return r2864580;
}

double f(double a, double b_2, double c) {
        double r2864581 = b_2;
        double r2864582 = -7.363255598823911e-15;
        bool r2864583 = r2864581 <= r2864582;
        double r2864584 = -0.5;
        double r2864585 = c;
        double r2864586 = r2864585 / r2864581;
        double r2864587 = r2864584 * r2864586;
        double r2864588 = -1.823572975982288e-27;
        bool r2864589 = r2864581 <= r2864588;
        double r2864590 = r2864581 * r2864581;
        double r2864591 = a;
        double r2864592 = r2864585 * r2864591;
        double r2864593 = r2864590 - r2864592;
        double r2864594 = r2864590 - r2864593;
        double r2864595 = r2864594 / r2864591;
        double r2864596 = -r2864581;
        double r2864597 = sqrt(r2864593);
        double r2864598 = r2864596 + r2864597;
        double r2864599 = r2864595 / r2864598;
        double r2864600 = -2.3344326820285623e-123;
        bool r2864601 = r2864581 <= r2864600;
        double r2864602 = 1.6691257204922504e+85;
        bool r2864603 = r2864581 <= r2864602;
        double r2864604 = r2864596 - r2864597;
        double r2864605 = r2864604 / r2864591;
        double r2864606 = 0.5;
        double r2864607 = r2864581 / r2864591;
        double r2864608 = -2.0;
        double r2864609 = r2864607 * r2864608;
        double r2864610 = fma(r2864606, r2864586, r2864609);
        double r2864611 = r2864603 ? r2864605 : r2864610;
        double r2864612 = r2864601 ? r2864587 : r2864611;
        double r2864613 = r2864589 ? r2864599 : r2864612;
        double r2864614 = r2864583 ? r2864587 : r2864613;
        return r2864614;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -7.363255598823911e-15 or -1.823572975982288e-27 < b_2 < -2.3344326820285623e-123

    1. Initial program 50.8

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

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

    if -7.363255598823911e-15 < b_2 < -1.823572975982288e-27

    1. Initial program 36.1

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    4. Using strategy rm
    5. Applied flip--36.2

      \[\leadsto \frac{1}{\frac{a}{\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}}}}}\]
    6. Applied associate-/r/36.2

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\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}} \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    7. Applied associate-/r*36.2

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{a}{\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}}}\]
    8. Simplified36.1

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

    if -2.3344326820285623e-123 < b_2 < 1.6691257204922504e+85

    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-inv12.7

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

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

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

    if 1.6691257204922504e+85 < b_2

    1. Initial program 42.9

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

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

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

      \[\leadsto \frac{\color{blue}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}{a}\]
    7. Taylor expanded around inf 3.6

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]
    8. Simplified3.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -7.363255598823911 \cdot 10^{-15}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.823572975982288 \cdot 10^{-27}:\\ \;\;\;\;\frac{\frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 - c \cdot a\right)}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - c \cdot a}}\\ \mathbf{elif}\;b_2 \le -2.3344326820285623 \cdot 10^{-123}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.6691257204922504 \cdot 10^{+85}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2}{a} \cdot -2\right)\\ \end{array}\]

Reproduce

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