Average Error: 34.1 → 8.9
Time: 17.9s
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.122942397323538653087473965252285768999 \cdot 10^{137}:\\ \;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \le -3.408354642852288642375909774932644593067 \cdot 10^{-45}:\\ \;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le -5.546621280225112292650318866994441138678 \cdot 10^{-56}:\\ \;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.823335453796603439248590818149160856749 \cdot 10^{131}:\\ \;\;\;\;-\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)\\ \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.122942397323538653087473965252285768999 \cdot 10^{137}:\\
\;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\

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

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

\mathbf{elif}\;b_2 \le 2.823335453796603439248590818149160856749 \cdot 10^{131}:\\
\;\;\;\;-\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r70103 = b_2;
        double r70104 = -r70103;
        double r70105 = r70103 * r70103;
        double r70106 = a;
        double r70107 = c;
        double r70108 = r70106 * r70107;
        double r70109 = r70105 - r70108;
        double r70110 = sqrt(r70109);
        double r70111 = r70104 - r70110;
        double r70112 = r70111 / r70106;
        return r70112;
}

double f(double a, double b_2, double c) {
        double r70113 = b_2;
        double r70114 = -2.1229423973235387e+137;
        bool r70115 = r70113 <= r70114;
        double r70116 = -0.5;
        double r70117 = c;
        double r70118 = r70116 * r70117;
        double r70119 = r70118 / r70113;
        double r70120 = -3.4083546428522886e-45;
        bool r70121 = r70113 <= r70120;
        double r70122 = a;
        double r70123 = r70122 * r70117;
        double r70124 = r70113 * r70113;
        double r70125 = r70124 - r70124;
        double r70126 = r70123 + r70125;
        double r70127 = r70126 / r70122;
        double r70128 = r70124 - r70123;
        double r70129 = sqrt(r70128);
        double r70130 = -r70113;
        double r70131 = r70129 + r70130;
        double r70132 = r70127 / r70131;
        double r70133 = -5.546621280225112e-56;
        bool r70134 = r70113 <= r70133;
        double r70135 = 2.8233354537966034e+131;
        bool r70136 = r70113 <= r70135;
        double r70137 = r70129 + r70113;
        double r70138 = r70137 / r70122;
        double r70139 = -r70138;
        double r70140 = r70117 / r70113;
        double r70141 = 0.5;
        double r70142 = -2.0;
        double r70143 = r70113 / r70122;
        double r70144 = r70142 * r70143;
        double r70145 = fma(r70140, r70141, r70144);
        double r70146 = r70136 ? r70139 : r70145;
        double r70147 = r70134 ? r70119 : r70146;
        double r70148 = r70121 ? r70132 : r70147;
        double r70149 = r70115 ? r70119 : r70148;
        return r70149;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -2.1229423973235387e+137 or -3.4083546428522886e-45 < b_2 < -5.546621280225112e-56

    1. Initial program 61.6

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

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

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

    if -2.1229423973235387e+137 < b_2 < -3.4083546428522886e-45

    1. Initial program 45.1

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

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

      \[\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}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{1}{a}\]
    6. Applied associate-*l/45.1

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Simplified11.6

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

    if -5.546621280225112e-56 < b_2 < 2.8233354537966034e+131

    1. Initial program 12.5

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

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

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

      \[\leadsto \color{blue}{{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}^{1}} \cdot {\left(\frac{1}{a}\right)}^{1}\]
    7. Applied pow-prod-down12.7

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

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

    if 2.8233354537966034e+131 < b_2

    1. Initial program 56.4

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

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

      \[\leadsto \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \color{blue}{{\left(\frac{1}{a}\right)}^{1}}\]
    6. Applied pow156.4

      \[\leadsto \color{blue}{{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}^{1}} \cdot {\left(\frac{1}{a}\right)}^{1}\]
    7. Applied pow-prod-down56.4

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

      \[\leadsto {\color{blue}{\left(\frac{-\left(b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{a}\right)}}^{1}\]
    9. Using strategy rm
    10. Applied add-exp-log57.1

      \[\leadsto {\left(\frac{-\color{blue}{e^{\log \left(b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}{a}\right)}^{1}\]
    11. Taylor expanded around inf 2.4

      \[\leadsto {\color{blue}{\left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)}}^{1}\]
    12. Simplified2.4

      \[\leadsto {\color{blue}{\left(\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)\right)}}^{1}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.122942397323538653087473965252285768999 \cdot 10^{137}:\\ \;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \le -3.408354642852288642375909774932644593067 \cdot 10^{-45}:\\ \;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le -5.546621280225112292650318866994441138678 \cdot 10^{-56}:\\ \;\;\;\;\frac{\frac{-1}{2} \cdot c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.823335453796603439248590818149160856749 \cdot 10^{131}:\\ \;\;\;\;-\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)\\ \end{array}\]

Reproduce

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