Average Error: 34.4 → 6.9
Time: 10.6s
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.457738542065716919858398723449020930628 \cdot 10^{153}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.916322353859376996786555026507866613573 \cdot 10^{-297}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 1.191203142513164639216663918436976252985 \cdot 10^{117}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{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 -1.457738542065716919858398723449020930628 \cdot 10^{153}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r77207 = b_2;
        double r77208 = -r77207;
        double r77209 = r77207 * r77207;
        double r77210 = a;
        double r77211 = c;
        double r77212 = r77210 * r77211;
        double r77213 = r77209 - r77212;
        double r77214 = sqrt(r77213);
        double r77215 = r77208 - r77214;
        double r77216 = r77215 / r77210;
        return r77216;
}

double f(double a, double b_2, double c) {
        double r77217 = b_2;
        double r77218 = -1.457738542065717e+153;
        bool r77219 = r77217 <= r77218;
        double r77220 = -0.5;
        double r77221 = c;
        double r77222 = r77221 / r77217;
        double r77223 = r77220 * r77222;
        double r77224 = -1.916322353859377e-297;
        bool r77225 = r77217 <= r77224;
        double r77226 = r77217 * r77217;
        double r77227 = a;
        double r77228 = r77227 * r77221;
        double r77229 = r77226 - r77228;
        double r77230 = sqrt(r77229);
        double r77231 = r77230 - r77217;
        double r77232 = r77221 / r77231;
        double r77233 = 1.1912031425131646e+117;
        bool r77234 = r77217 <= r77233;
        double r77235 = -r77217;
        double r77236 = r77221 * r77227;
        double r77237 = r77226 - r77236;
        double r77238 = sqrt(r77237);
        double r77239 = r77235 - r77238;
        double r77240 = r77239 / r77227;
        double r77241 = -2.0;
        double r77242 = r77241 * r77217;
        double r77243 = r77242 / r77227;
        double r77244 = r77234 ? r77240 : r77243;
        double r77245 = r77225 ? r77232 : r77244;
        double r77246 = r77219 ? r77223 : r77245;
        return r77246;
}

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 4 regimes
  2. if b_2 < -1.457738542065717e+153

    1. Initial program 63.9

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

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

    if -1.457738542065717e+153 < b_2 < -1.916322353859377e-297

    1. Initial program 35.5

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{c}{1} \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    9. Applied associate-/l*11.6

      \[\leadsto \color{blue}{\frac{\frac{c}{1}}{\frac{a}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}}\]
    10. Simplified8.4

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

    if -1.916322353859377e-297 < b_2 < 1.1912031425131646e+117

    1. Initial program 9.6

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified9.6

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

    if 1.1912031425131646e+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}{c \cdot a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Simplified62.7

      \[\leadsto \frac{\frac{c \cdot a}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Taylor expanded around 0 4.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.457738542065716919858398723449020930628 \cdot 10^{153}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.916322353859376996786555026507866613573 \cdot 10^{-297}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 1.191203142513164639216663918436976252985 \cdot 10^{117}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019351 
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))