Average Error: 34.5 → 6.7
Time: 10.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 -2.61268387266151013 \cdot 10^{141}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.5402182456312607 \cdot 10^{-243}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 2.8568501197790958 \cdot 10^{109}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{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 -2.61268387266151013 \cdot 10^{141}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r20083 = b_2;
        double r20084 = -r20083;
        double r20085 = r20083 * r20083;
        double r20086 = a;
        double r20087 = c;
        double r20088 = r20086 * r20087;
        double r20089 = r20085 - r20088;
        double r20090 = sqrt(r20089);
        double r20091 = r20084 - r20090;
        double r20092 = r20091 / r20086;
        return r20092;
}

double f(double a, double b_2, double c) {
        double r20093 = b_2;
        double r20094 = -2.61268387266151e+141;
        bool r20095 = r20093 <= r20094;
        double r20096 = -0.5;
        double r20097 = c;
        double r20098 = r20097 / r20093;
        double r20099 = r20096 * r20098;
        double r20100 = 2.5402182456312607e-243;
        bool r20101 = r20093 <= r20100;
        double r20102 = r20093 * r20093;
        double r20103 = a;
        double r20104 = r20103 * r20097;
        double r20105 = r20102 - r20104;
        double r20106 = sqrt(r20105);
        double r20107 = r20106 - r20093;
        double r20108 = r20097 / r20107;
        double r20109 = 2.8568501197790958e+109;
        bool r20110 = r20093 <= r20109;
        double r20111 = -r20093;
        double r20112 = r20111 - r20106;
        double r20113 = 1.0;
        double r20114 = r20113 / r20103;
        double r20115 = r20112 * r20114;
        double r20116 = -2.0;
        double r20117 = r20093 / r20103;
        double r20118 = r20116 * r20117;
        double r20119 = r20110 ? r20115 : r20118;
        double r20120 = r20101 ? r20108 : r20119;
        double r20121 = r20095 ? r20099 : r20120;
        return r20121;
}

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 < -2.61268387266151e+141

    1. Initial program 62.7

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

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

    if -2.61268387266151e+141 < b_2 < 2.5402182456312607e-243

    1. Initial program 32.8

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

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

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

      \[\leadsto \frac{\frac{a \cdot c + b_2 \cdot \left(b_2 - b_2\right)}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied div-inv15.9

      \[\leadsto \color{blue}{\frac{a \cdot c + b_2 \cdot \left(b_2 - b_2\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2} \cdot \frac{1}{a}}\]
    8. Using strategy rm
    9. Applied associate-*l/14.6

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

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

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

    if 2.5402182456312607e-243 < b_2 < 2.8568501197790958e+109

    1. Initial program 8.7

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

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

    if 2.8568501197790958e+109 < b_2

    1. Initial program 49.0

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.61268387266151013 \cdot 10^{141}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.5402182456312607 \cdot 10^{-243}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 2.8568501197790958 \cdot 10^{109}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))