Average Error: 33.9 → 6.7
Time: 6.1s
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 -7.78489609812549271 \cdot 10^{150}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.06653630715331101 \cdot 10^{-284}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\frac{1}{c}}\\ \mathbf{elif}\;b_2 \le 2.3041961191710096 \cdot 10^{50}:\\ \;\;\;\;\frac{\left(-b_2\right) - \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 -7.78489609812549271 \cdot 10^{150}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 1.06653630715331101 \cdot 10^{-284}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\frac{1}{c}}\\

\mathbf{elif}\;b_2 \le 2.3041961191710096 \cdot 10^{50}:\\
\;\;\;\;\frac{\left(-b_2\right) - \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 r93166 = b_2;
        double r93167 = -r93166;
        double r93168 = r93166 * r93166;
        double r93169 = a;
        double r93170 = c;
        double r93171 = r93169 * r93170;
        double r93172 = r93168 - r93171;
        double r93173 = sqrt(r93172);
        double r93174 = r93167 - r93173;
        double r93175 = r93174 / r93169;
        return r93175;
}

double f(double a, double b_2, double c) {
        double r93176 = b_2;
        double r93177 = -7.784896098125493e+150;
        bool r93178 = r93176 <= r93177;
        double r93179 = -0.5;
        double r93180 = c;
        double r93181 = r93180 / r93176;
        double r93182 = r93179 * r93181;
        double r93183 = 1.066536307153311e-284;
        bool r93184 = r93176 <= r93183;
        double r93185 = 1.0;
        double r93186 = r93176 * r93176;
        double r93187 = a;
        double r93188 = r93187 * r93180;
        double r93189 = r93186 - r93188;
        double r93190 = sqrt(r93189);
        double r93191 = r93190 - r93176;
        double r93192 = r93185 / r93191;
        double r93193 = r93185 / r93180;
        double r93194 = r93192 / r93193;
        double r93195 = 2.3041961191710096e+50;
        bool r93196 = r93176 <= r93195;
        double r93197 = -r93176;
        double r93198 = r93197 - r93190;
        double r93199 = r93198 / r93187;
        double r93200 = -2.0;
        double r93201 = r93200 * r93176;
        double r93202 = r93201 / r93187;
        double r93203 = r93196 ? r93199 : r93202;
        double r93204 = r93184 ? r93194 : r93203;
        double r93205 = r93178 ? r93182 : r93204;
        return r93205;
}

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 < -7.784896098125493e+150

    1. Initial program 63.8

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

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

    if -7.784896098125493e+150 < b_2 < 1.066536307153311e-284

    1. Initial program 33.7

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

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

      \[\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*15.7

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

      \[\leadsto \frac{\color{blue}{\frac{a}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{c}}}}{a}\]
    10. Using strategy rm
    11. Applied div-inv13.8

      \[\leadsto \frac{\frac{a}{\color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{c}}}}{a}\]
    12. Applied *-un-lft-identity13.8

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

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

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

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

    if 1.066536307153311e-284 < b_2 < 2.3041961191710096e+50

    1. Initial program 9.0

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

    if 2.3041961191710096e+50 < b_2

    1. Initial program 37.9

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

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

      \[\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*60.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -7.78489609812549271 \cdot 10^{150}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.06653630715331101 \cdot 10^{-284}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\frac{1}{c}}\\ \mathbf{elif}\;b_2 \le 2.3041961191710096 \cdot 10^{50}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b_2}{a}\\ \end{array}\]

Reproduce

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