Average Error: 34.4 → 9.6
Time: 24.0s
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 -2726755826697749371122441483452416:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.220863356651405551526191855483353869404 \cdot 10^{-93}:\\ \;\;\;\;\left(c \cdot a\right) \cdot \frac{1}{a \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)}\\ \mathbf{elif}\;b_2 \le 5.878879592304488221733339437168429062361 \cdot 10^{101}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{c}{b_2} \cdot \frac{1}{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 -2726755826697749371122441483452416:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r939786 = b_2;
        double r939787 = -r939786;
        double r939788 = r939786 * r939786;
        double r939789 = a;
        double r939790 = c;
        double r939791 = r939789 * r939790;
        double r939792 = r939788 - r939791;
        double r939793 = sqrt(r939792);
        double r939794 = r939787 - r939793;
        double r939795 = r939794 / r939789;
        return r939795;
}

double f(double a, double b_2, double c) {
        double r939796 = b_2;
        double r939797 = -2.7267558266977494e+33;
        bool r939798 = r939796 <= r939797;
        double r939799 = -0.5;
        double r939800 = c;
        double r939801 = r939800 / r939796;
        double r939802 = r939799 * r939801;
        double r939803 = -1.2208633566514056e-93;
        bool r939804 = r939796 <= r939803;
        double r939805 = a;
        double r939806 = r939800 * r939805;
        double r939807 = 1.0;
        double r939808 = r939796 * r939796;
        double r939809 = r939808 - r939806;
        double r939810 = sqrt(r939809);
        double r939811 = r939810 - r939796;
        double r939812 = r939805 * r939811;
        double r939813 = r939807 / r939812;
        double r939814 = r939806 * r939813;
        double r939815 = 5.878879592304488e+101;
        bool r939816 = r939796 <= r939815;
        double r939817 = -r939796;
        double r939818 = r939817 - r939810;
        double r939819 = r939818 / r939805;
        double r939820 = -2.0;
        double r939821 = r939796 / r939805;
        double r939822 = 0.5;
        double r939823 = r939801 * r939822;
        double r939824 = fma(r939820, r939821, r939823);
        double r939825 = r939816 ? r939819 : r939824;
        double r939826 = r939804 ? r939814 : r939825;
        double r939827 = r939798 ? r939802 : r939826;
        return r939827;
}

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.7267558266977494e+33

    1. Initial program 56.5

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

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

    if -2.7267558266977494e+33 < b_2 < -1.2208633566514056e-93

    1. Initial program 41.1

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

      \[\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. Simplified16.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. Simplified16.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-identity16.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 div-inv16.8

      \[\leadsto \frac{\color{blue}{\left(0 + a \cdot c\right) \cdot \frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{1 \cdot a}\]
    9. Applied times-frac20.3

      \[\leadsto \color{blue}{\frac{0 + a \cdot c}{1} \cdot \frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}}\]
    10. Simplified20.3

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

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

    if -1.2208633566514056e-93 < b_2 < 5.878879592304488e+101

    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.6

      \[\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 un-div-inv12.5

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

    if 5.878879592304488e+101 < b_2

    1. Initial program 46.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2726755826697749371122441483452416:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.220863356651405551526191855483353869404 \cdot 10^{-93}:\\ \;\;\;\;\left(c \cdot a\right) \cdot \frac{1}{a \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)}\\ \mathbf{elif}\;b_2 \le 5.878879592304488221733339437168429062361 \cdot 10^{101}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{c}{b_2} \cdot \frac{1}{2}\right)\\ \end{array}\]

Reproduce

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