Average Error: 33.9 → 6.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 -5.674469085146396739103610609439188639717 \cdot 10^{110}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 7.061692521831335565675525372535211636164 \cdot 10^{-266}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 1.715181108188238274259588142060201574853 \cdot 10^{78}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot 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 -5.674469085146396739103610609439188639717 \cdot 10^{110}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r28175 = b_2;
        double r28176 = -r28175;
        double r28177 = r28175 * r28175;
        double r28178 = a;
        double r28179 = c;
        double r28180 = r28178 * r28179;
        double r28181 = r28177 - r28180;
        double r28182 = sqrt(r28181);
        double r28183 = r28176 - r28182;
        double r28184 = r28183 / r28178;
        return r28184;
}

double f(double a, double b_2, double c) {
        double r28185 = b_2;
        double r28186 = -5.674469085146397e+110;
        bool r28187 = r28185 <= r28186;
        double r28188 = -0.5;
        double r28189 = c;
        double r28190 = r28189 / r28185;
        double r28191 = r28188 * r28190;
        double r28192 = 7.061692521831336e-266;
        bool r28193 = r28185 <= r28192;
        double r28194 = a;
        double r28195 = r28189 * r28194;
        double r28196 = -r28195;
        double r28197 = fma(r28185, r28185, r28196);
        double r28198 = sqrt(r28197);
        double r28199 = r28198 - r28185;
        double r28200 = r28189 / r28199;
        double r28201 = 1.7151811081882383e+78;
        bool r28202 = r28185 <= r28201;
        double r28203 = -r28185;
        double r28204 = r28203 / r28194;
        double r28205 = r28185 * r28185;
        double r28206 = r28194 * r28189;
        double r28207 = r28205 - r28206;
        double r28208 = sqrt(r28207);
        double r28209 = r28208 / r28194;
        double r28210 = r28204 - r28209;
        double r28211 = -2.0;
        double r28212 = r28211 * r28185;
        double r28213 = r28212 / r28194;
        double r28214 = r28202 ? r28210 : r28213;
        double r28215 = r28193 ? r28200 : r28214;
        double r28216 = r28187 ? r28191 : r28215;
        return r28216;
}

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 < -5.674469085146397e+110

    1. Initial program 59.7

      \[\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 -5.674469085146397e+110 < b_2 < 7.061692521831336e-266

    1. Initial program 31.8

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

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

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

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

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

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

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

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

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

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

      \[\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 7.061692521831336e-266 < b_2 < 1.7151811081882383e+78

    1. Initial program 8.5

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

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

    if 1.7151811081882383e+78 < b_2

    1. Initial program 43.0

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

      \[\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. Simplified61.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. Simplified61.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. Taylor expanded around 0 4.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.674469085146396739103610609439188639717 \cdot 10^{110}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 7.061692521831335565675525372535211636164 \cdot 10^{-266}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 1.715181108188238274259588142060201574853 \cdot 10^{78}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b_2}{a}\\ \end{array}\]

Reproduce

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