Average Error: 34.0 → 6.5
Time: 16.1s
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.077239628548905378565124203356585166888 \cdot 10^{154}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.657998399682531790024702628233707002655 \cdot 10^{-302}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 3.361636799726259566012474460441175928147 \cdot 10^{93}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \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.077239628548905378565124203356585166888 \cdot 10^{154}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 3.657998399682531790024702628233707002655 \cdot 10^{-302}:\\
\;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r26748 = b_2;
        double r26749 = -r26748;
        double r26750 = r26748 * r26748;
        double r26751 = a;
        double r26752 = c;
        double r26753 = r26751 * r26752;
        double r26754 = r26750 - r26753;
        double r26755 = sqrt(r26754);
        double r26756 = r26749 - r26755;
        double r26757 = r26756 / r26751;
        return r26757;
}

double f(double a, double b_2, double c) {
        double r26758 = b_2;
        double r26759 = -1.0772396285489054e+154;
        bool r26760 = r26758 <= r26759;
        double r26761 = -0.5;
        double r26762 = c;
        double r26763 = r26762 / r26758;
        double r26764 = r26761 * r26763;
        double r26765 = 3.657998399682532e-302;
        bool r26766 = r26758 <= r26765;
        double r26767 = a;
        double r26768 = r26762 * r26767;
        double r26769 = -r26768;
        double r26770 = fma(r26758, r26758, r26769);
        double r26771 = sqrt(r26770);
        double r26772 = r26771 - r26758;
        double r26773 = r26762 / r26772;
        double r26774 = 3.3616367997262596e+93;
        bool r26775 = r26758 <= r26774;
        double r26776 = 1.0;
        double r26777 = -r26758;
        double r26778 = r26758 * r26758;
        double r26779 = r26767 * r26762;
        double r26780 = r26778 - r26779;
        double r26781 = sqrt(r26780);
        double r26782 = r26777 - r26781;
        double r26783 = r26767 / r26782;
        double r26784 = r26776 / r26783;
        double r26785 = -2.0;
        double r26786 = r26758 / r26767;
        double r26787 = r26785 * r26786;
        double r26788 = r26775 ? r26784 : r26787;
        double r26789 = r26766 ? r26773 : r26788;
        double r26790 = r26760 ? r26764 : r26789;
        return r26790;
}

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 < -1.0772396285489054e+154

    1. Initial program 64.0

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

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

    if -1.0772396285489054e+154 < b_2 < 3.657998399682532e-302

    1. Initial program 34.6

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

      \[\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. Simplified15.9

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

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity15.9

      \[\leadsto \frac{\frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied *-un-lft-identity15.9

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2\right)}}}{1 \cdot a}\]
    9. Applied *-un-lft-identity15.9

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(0 + a \cdot c\right)}}{1 \cdot \left(\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2\right)}}{1 \cdot a}\]
    10. Applied times-frac15.9

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}{1 \cdot a}\]
    11. Applied times-frac15.9

      \[\leadsto \color{blue}{\frac{\frac{1}{1}}{1} \cdot \frac{\frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}{a}}\]
    12. Simplified15.9

      \[\leadsto \color{blue}{1} \cdot \frac{\frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}{a}\]
    13. Simplified8.1

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

    if 3.657998399682532e-302 < b_2 < 3.3616367997262596e+93

    1. Initial program 8.9

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

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

    if 3.3616367997262596e+93 < b_2

    1. Initial program 45.2

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

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

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

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity62.0

      \[\leadsto \frac{\frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied *-un-lft-identity62.0

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2\right)}}}{1 \cdot a}\]
    9. Applied *-un-lft-identity62.0

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(0 + a \cdot c\right)}}{1 \cdot \left(\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2\right)}}{1 \cdot a}\]
    10. Applied times-frac62.0

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}}{1 \cdot a}\]
    11. Applied times-frac62.0

      \[\leadsto \color{blue}{\frac{\frac{1}{1}}{1} \cdot \frac{\frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}{a}}\]
    12. Simplified62.0

      \[\leadsto \color{blue}{1} \cdot \frac{\frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}{a}\]
    13. Simplified61.8

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2} \cdot 1\right)}\]
    14. Taylor expanded around 0 3.5

      \[\leadsto 1 \cdot \left(\color{blue}{\left(-2 \cdot \frac{b_2}{a}\right)} \cdot 1\right)\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.077239628548905378565124203356585166888 \cdot 10^{154}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.657998399682531790024702628233707002655 \cdot 10^{-302}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 3.361636799726259566012474460441175928147 \cdot 10^{93}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

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