Average Error: 34.4 → 7.1
Time: 11.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.30260065699914430088466347088364783298 \cdot 10^{85}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.616213321049155371026664508407530431682 \cdot 10^{-298}:\\ \;\;\;\;c \cdot \frac{1}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 1.140745036075281127251828675303402372066 \cdot 10^{117}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2}{a} \cdot -2\\ \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.30260065699914430088466347088364783298 \cdot 10^{85}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r20159 = b_2;
        double r20160 = -r20159;
        double r20161 = r20159 * r20159;
        double r20162 = a;
        double r20163 = c;
        double r20164 = r20162 * r20163;
        double r20165 = r20161 - r20164;
        double r20166 = sqrt(r20165);
        double r20167 = r20160 - r20166;
        double r20168 = r20167 / r20162;
        return r20168;
}

double f(double a, double b_2, double c) {
        double r20169 = b_2;
        double r20170 = -2.3026006569991443e+85;
        bool r20171 = r20169 <= r20170;
        double r20172 = -0.5;
        double r20173 = c;
        double r20174 = r20173 / r20169;
        double r20175 = r20172 * r20174;
        double r20176 = -1.6162133210491554e-298;
        bool r20177 = r20169 <= r20176;
        double r20178 = 1.0;
        double r20179 = a;
        double r20180 = r20173 * r20179;
        double r20181 = -r20180;
        double r20182 = fma(r20169, r20169, r20181);
        double r20183 = sqrt(r20182);
        double r20184 = r20183 - r20169;
        double r20185 = r20178 / r20184;
        double r20186 = r20173 * r20185;
        double r20187 = 1.1407450360752811e+117;
        bool r20188 = r20169 <= r20187;
        double r20189 = -r20169;
        double r20190 = r20189 / r20179;
        double r20191 = r20169 * r20169;
        double r20192 = r20179 * r20173;
        double r20193 = r20191 - r20192;
        double r20194 = sqrt(r20193);
        double r20195 = r20194 / r20179;
        double r20196 = r20190 - r20195;
        double r20197 = r20169 / r20179;
        double r20198 = -2.0;
        double r20199 = r20197 * r20198;
        double r20200 = r20188 ? r20196 : r20199;
        double r20201 = r20177 ? r20186 : r20200;
        double r20202 = r20171 ? r20175 : r20201;
        return r20202;
}

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 < -2.3026006569991443e+85

    1. Initial program 59.1

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

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

    if -2.3026006569991443e+85 < b_2 < -1.6162133210491554e-298

    1. Initial program 32.4

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--32.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. Simplified17.8

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

      \[\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-identity17.8

      \[\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-identity17.8

      \[\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-identity17.8

      \[\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-frac17.8

      \[\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-frac17.8

      \[\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. Simplified17.8

      \[\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. Simplified9.6

      \[\leadsto 1 \cdot \color{blue}{\left(1 \cdot \frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\right)}\]
    14. Using strategy rm
    15. Applied div-inv9.7

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

    if -1.6162133210491554e-298 < b_2 < 1.1407450360752811e+117

    1. Initial program 9.6

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

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

    if 1.1407450360752811e+117 < b_2

    1. Initial program 50.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--63.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. Simplified62.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. Simplified62.7

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.30260065699914430088466347088364783298 \cdot 10^{85}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.616213321049155371026664508407530431682 \cdot 10^{-298}:\\ \;\;\;\;c \cdot \frac{1}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 1.140745036075281127251828675303402372066 \cdot 10^{117}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2}{a} \cdot -2\\ \end{array}\]

Reproduce

herbie shell --seed 2019351 +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))