Average Error: 34.2 → 8.9
Time: 10.5s
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.3462145268323472 \cdot 10^{21}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 6.63494137338838141 \cdot 10^{-295}:\\ \;\;\;\;\frac{\frac{a}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{c}}}{a}\\ \mathbf{elif}\;b_2 \le 2445759453.4737968:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{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 -9.3462145268323472 \cdot 10^{21}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r113167 = b_2;
        double r113168 = -r113167;
        double r113169 = r113167 * r113167;
        double r113170 = a;
        double r113171 = c;
        double r113172 = r113170 * r113171;
        double r113173 = r113169 - r113172;
        double r113174 = sqrt(r113173);
        double r113175 = r113168 - r113174;
        double r113176 = r113175 / r113170;
        return r113176;
}

double f(double a, double b_2, double c) {
        double r113177 = b_2;
        double r113178 = -9.346214526832347e+21;
        bool r113179 = r113177 <= r113178;
        double r113180 = -0.5;
        double r113181 = c;
        double r113182 = r113181 / r113177;
        double r113183 = r113180 * r113182;
        double r113184 = 6.634941373388381e-295;
        bool r113185 = r113177 <= r113184;
        double r113186 = a;
        double r113187 = r113177 * r113177;
        double r113188 = r113186 * r113181;
        double r113189 = r113187 - r113188;
        double r113190 = sqrt(r113189);
        double r113191 = r113190 - r113177;
        double r113192 = r113191 / r113181;
        double r113193 = r113186 / r113192;
        double r113194 = r113193 / r113186;
        double r113195 = 2445759453.473797;
        bool r113196 = r113177 <= r113195;
        double r113197 = -r113177;
        double r113198 = r113197 - r113190;
        double r113199 = 1.0;
        double r113200 = r113199 / r113186;
        double r113201 = r113198 * r113200;
        double r113202 = -2.0;
        double r113203 = r113202 * r113177;
        double r113204 = r113203 / r113186;
        double r113205 = r113196 ? r113201 : r113204;
        double r113206 = r113185 ? r113194 : r113205;
        double r113207 = r113179 ? r113183 : r113206;
        return r113207;
}

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.346214526832347e+21

    1. Initial program 56.7

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

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

    if -9.346214526832347e+21 < b_2 < 6.634941373388381e-295

    1. Initial program 27.7

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

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

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

      \[\leadsto \frac{\frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied associate-/r*17.6

      \[\leadsto \color{blue}{\frac{\frac{\frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{1}}{a}}\]
    9. Simplified15.0

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

    if 6.634941373388381e-295 < b_2 < 2445759453.473797

    1. Initial program 10.0

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

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

    if 2445759453.473797 < b_2

    1. Initial program 33.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -9.3462145268323472 \cdot 10^{21}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 6.63494137338838141 \cdot 10^{-295}:\\ \;\;\;\;\frac{\frac{a}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{c}}}{a}\\ \mathbf{elif}\;b_2 \le 2445759453.4737968:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b_2}{a}\\ \end{array}\]

Reproduce

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