Average Error: 33.6 → 9.3
Time: 1.3m
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 -9.240807674268867 \cdot 10^{+23}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -6.7222348411288265 \cdot 10^{-49}:\\ \;\;\;\;\frac{c \cdot a}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}\\ \mathbf{elif}\;b_2 \le -1.853957975167164 \cdot 10^{-67}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 4.778966372232416 \cdot 10^{+96}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot 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 -9.240807674268867 \cdot 10^{+23}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r15368253 = b_2;
        double r15368254 = -r15368253;
        double r15368255 = r15368253 * r15368253;
        double r15368256 = a;
        double r15368257 = c;
        double r15368258 = r15368256 * r15368257;
        double r15368259 = r15368255 - r15368258;
        double r15368260 = sqrt(r15368259);
        double r15368261 = r15368254 - r15368260;
        double r15368262 = r15368261 / r15368256;
        return r15368262;
}

double f(double a, double b_2, double c) {
        double r15368263 = b_2;
        double r15368264 = -9.240807674268867e+23;
        bool r15368265 = r15368263 <= r15368264;
        double r15368266 = -0.5;
        double r15368267 = c;
        double r15368268 = r15368267 / r15368263;
        double r15368269 = r15368266 * r15368268;
        double r15368270 = -6.7222348411288265e-49;
        bool r15368271 = r15368263 <= r15368270;
        double r15368272 = a;
        double r15368273 = r15368267 * r15368272;
        double r15368274 = -r15368263;
        double r15368275 = r15368263 * r15368263;
        double r15368276 = r15368275 - r15368273;
        double r15368277 = sqrt(r15368276);
        double r15368278 = r15368274 + r15368277;
        double r15368279 = r15368272 * r15368278;
        double r15368280 = r15368273 / r15368279;
        double r15368281 = -1.853957975167164e-67;
        bool r15368282 = r15368263 <= r15368281;
        double r15368283 = 4.778966372232416e+96;
        bool r15368284 = r15368263 <= r15368283;
        double r15368285 = 1.0;
        double r15368286 = r15368274 - r15368277;
        double r15368287 = r15368272 / r15368286;
        double r15368288 = r15368285 / r15368287;
        double r15368289 = r15368263 / r15368272;
        double r15368290 = -2.0;
        double r15368291 = r15368289 * r15368290;
        double r15368292 = r15368284 ? r15368288 : r15368291;
        double r15368293 = r15368282 ? r15368269 : r15368292;
        double r15368294 = r15368271 ? r15368280 : r15368293;
        double r15368295 = r15368265 ? r15368269 : r15368294;
        return r15368295;
}

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 < -9.240807674268867e+23 or -6.7222348411288265e-49 < b_2 < -1.853957975167164e-67

    1. Initial program 55.2

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

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

    if -9.240807674268867e+23 < b_2 < -6.7222348411288265e-49

    1. Initial program 44.1

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

      \[\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. Applied associate-/l/46.2

      \[\leadsto \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}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    5. Simplified18.4

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

    if -1.853957975167164e-67 < b_2 < 4.778966372232416e+96

    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 *-un-lft-identity12.6

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    4. Applied associate-/l*12.7

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

    if 4.778966372232416e+96 < b_2

    1. Initial program 43.5

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    4. Applied associate-/l*43.6

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

      \[\leadsto \frac{1}{\color{blue}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    7. Applied add-cube-cbrt43.6

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

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

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

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(-\left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)\right)}\]
    11. Taylor expanded around 0 4.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -9.240807674268867 \cdot 10^{+23}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -6.7222348411288265 \cdot 10^{-49}:\\ \;\;\;\;\frac{c \cdot a}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - c \cdot a}\right)}\\ \mathbf{elif}\;b_2 \le -1.853957975167164 \cdot 10^{-67}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 4.778966372232416 \cdot 10^{+96}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b_2}{a} \cdot -2\\ \end{array}\]

Reproduce

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