Average Error: 33.9 → 6.8
Time: 18.4s
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 -3.359953003549156817553996908233908949771 \cdot 10^{103}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.094358742794727790656239317142702500789 \cdot 10^{-239}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{elif}\;b_2 \le 5.099089738165329086098741767888130630655 \cdot 10^{67}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2}{a} \cdot -2\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 -3.359953003549156817553996908233908949771 \cdot 10^{103}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r65788 = b_2;
        double r65789 = -r65788;
        double r65790 = r65788 * r65788;
        double r65791 = a;
        double r65792 = c;
        double r65793 = r65791 * r65792;
        double r65794 = r65790 - r65793;
        double r65795 = sqrt(r65794);
        double r65796 = r65789 - r65795;
        double r65797 = r65796 / r65791;
        return r65797;
}

double f(double a, double b_2, double c) {
        double r65798 = b_2;
        double r65799 = -3.359953003549157e+103;
        bool r65800 = r65798 <= r65799;
        double r65801 = -0.5;
        double r65802 = c;
        double r65803 = r65802 / r65798;
        double r65804 = r65801 * r65803;
        double r65805 = 2.094358742794728e-239;
        bool r65806 = r65798 <= r65805;
        double r65807 = -r65798;
        double r65808 = r65798 * r65798;
        double r65809 = a;
        double r65810 = r65809 * r65802;
        double r65811 = r65808 - r65810;
        double r65812 = sqrt(r65811);
        double r65813 = r65807 + r65812;
        double r65814 = r65802 / r65813;
        double r65815 = 5.099089738165329e+67;
        bool r65816 = r65798 <= r65815;
        double r65817 = r65807 - r65812;
        double r65818 = r65817 / r65809;
        double r65819 = 0.5;
        double r65820 = r65798 / r65809;
        double r65821 = -2.0;
        double r65822 = r65820 * r65821;
        double r65823 = fma(r65819, r65803, r65822);
        double r65824 = r65816 ? r65818 : r65823;
        double r65825 = r65806 ? r65814 : r65824;
        double r65826 = r65800 ? r65804 : r65825;
        return r65826;
}

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 < -3.359953003549157e+103

    1. Initial program 59.7

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

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

    if -3.359953003549157e+103 < b_2 < 2.094358742794728e-239

    1. Initial program 30.6

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

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

      \[\leadsto \frac{1}{\frac{a}{\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}}}}}\]
    6. Applied associate-/r/30.8

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\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}} \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    7. Applied associate-/r*30.8

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{a}{\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}}}\]
    8. Simplified15.4

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

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

    if 2.094358742794728e-239 < b_2 < 5.099089738165329e+67

    1. Initial program 8.0

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

    if 5.099089738165329e+67 < b_2

    1. Initial program 40.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.359953003549156817553996908233908949771 \cdot 10^{103}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.094358742794727790656239317142702500789 \cdot 10^{-239}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{elif}\;b_2 \le 5.099089738165329086098741767888130630655 \cdot 10^{67}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, \frac{b_2}{a} \cdot -2\right)\\ \end{array}\]

Reproduce

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