Average Error: 32.6 → 9.7
Time: 34.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 -6.90131991727783 \cdot 10^{-39}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 4.012768074517757 \cdot 10^{+87}:\\ \;\;\;\;\frac{\frac{1}{a}}{\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{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 -6.90131991727783 \cdot 10^{-39}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r2512193 = b_2;
        double r2512194 = -r2512193;
        double r2512195 = r2512193 * r2512193;
        double r2512196 = a;
        double r2512197 = c;
        double r2512198 = r2512196 * r2512197;
        double r2512199 = r2512195 - r2512198;
        double r2512200 = sqrt(r2512199);
        double r2512201 = r2512194 - r2512200;
        double r2512202 = r2512201 / r2512196;
        return r2512202;
}

double f(double a, double b_2, double c) {
        double r2512203 = b_2;
        double r2512204 = -6.90131991727783e-39;
        bool r2512205 = r2512203 <= r2512204;
        double r2512206 = -0.5;
        double r2512207 = c;
        double r2512208 = r2512207 / r2512203;
        double r2512209 = r2512206 * r2512208;
        double r2512210 = 4.012768074517757e+87;
        bool r2512211 = r2512203 <= r2512210;
        double r2512212 = 1.0;
        double r2512213 = a;
        double r2512214 = r2512212 / r2512213;
        double r2512215 = -r2512203;
        double r2512216 = r2512203 * r2512203;
        double r2512217 = r2512207 * r2512213;
        double r2512218 = r2512216 - r2512217;
        double r2512219 = sqrt(r2512218);
        double r2512220 = r2512215 - r2512219;
        double r2512221 = r2512212 / r2512220;
        double r2512222 = r2512214 / r2512221;
        double r2512223 = -2.0;
        double r2512224 = r2512203 / r2512213;
        double r2512225 = r2512223 * r2512224;
        double r2512226 = r2512211 ? r2512222 : r2512225;
        double r2512227 = r2512205 ? r2512209 : r2512226;
        return r2512227;
}

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 3 regimes
  2. if b_2 < -6.90131991727783e-39

    1. Initial program 53.0

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

      \[\leadsto \color{blue}{\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}}\]
    4. Taylor expanded around -inf 7.9

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

    if -6.90131991727783e-39 < b_2 < 4.012768074517757e+87

    1. Initial program 13.2

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

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

      \[\leadsto \frac{\left(-\color{blue}{1 \cdot b_2}\right) - 1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    5. Applied distribute-rgt-neg-in13.2

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b_2\right)} - 1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    6. Applied distribute-lft-out--13.2

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    8. Using strategy rm
    9. Applied div-inv13.4

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

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

    if 4.012768074517757e+87 < b_2

    1. Initial program 41.3

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

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

      \[\leadsto \frac{\left(-\color{blue}{1 \cdot b_2}\right) - 1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    5. Applied distribute-rgt-neg-in41.3

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b_2\right)} - 1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    6. Applied distribute-lft-out--41.3

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    8. Using strategy rm
    9. Applied div-inv41.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -6.90131991727783 \cdot 10^{-39}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 4.012768074517757 \cdot 10^{+87}:\\ \;\;\;\;\frac{\frac{1}{a}}{\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

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