Average Error: 34.1 → 8.9
Time: 19.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{-1}{2} \cdot \frac{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{-1}{2} \cdot \frac{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}, \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 -2.122942397323538653087473965252285768999 \cdot 10^{137}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{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{-1}{2} \cdot \frac{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}, \frac{b_2}{a} \cdot -2\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r3394789 = b_2;
        double r3394790 = -r3394789;
        double r3394791 = r3394789 * r3394789;
        double r3394792 = a;
        double r3394793 = c;
        double r3394794 = r3394792 * r3394793;
        double r3394795 = r3394791 - r3394794;
        double r3394796 = sqrt(r3394795);
        double r3394797 = r3394790 - r3394796;
        double r3394798 = r3394797 / r3394792;
        return r3394798;
}

double f(double a, double b_2, double c) {
        double r3394799 = b_2;
        double r3394800 = -2.1229423973235387e+137;
        bool r3394801 = r3394799 <= r3394800;
        double r3394802 = -0.5;
        double r3394803 = c;
        double r3394804 = r3394803 / r3394799;
        double r3394805 = r3394802 * r3394804;
        double r3394806 = -3.4083546428522886e-45;
        bool r3394807 = r3394799 <= r3394806;
        double r3394808 = a;
        double r3394809 = r3394808 * r3394803;
        double r3394810 = r3394799 * r3394799;
        double r3394811 = r3394810 - r3394810;
        double r3394812 = r3394809 + r3394811;
        double r3394813 = r3394812 / r3394808;
        double r3394814 = r3394810 - r3394809;
        double r3394815 = sqrt(r3394814);
        double r3394816 = -r3394799;
        double r3394817 = r3394815 + r3394816;
        double r3394818 = r3394813 / r3394817;
        double r3394819 = -5.546621280225112e-56;
        bool r3394820 = r3394799 <= r3394819;
        double r3394821 = 2.8233354537966034e+131;
        bool r3394822 = r3394799 <= r3394821;
        double r3394823 = r3394815 + r3394799;
        double r3394824 = r3394823 / r3394808;
        double r3394825 = -r3394824;
        double r3394826 = 0.5;
        double r3394827 = r3394799 / r3394808;
        double r3394828 = -2.0;
        double r3394829 = r3394827 * r3394828;
        double r3394830 = fma(r3394804, r3394826, r3394829);
        double r3394831 = r3394822 ? r3394825 : r3394830;
        double r3394832 = r3394820 ? r3394805 : r3394831;
        double r3394833 = r3394807 ? r3394818 : r3394832;
        double r3394834 = r3394801 ? r3394805 : r3394833;
        return r3394834;
}

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}}\]

    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 associate-*r/12.5

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

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

    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 associate-*r/56.4

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, -2 \cdot \frac{b_2}{a}\right)}\]
  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{-1}{2} \cdot \frac{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{-1}{2} \cdot \frac{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}, \frac{b_2}{a} \cdot -2\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))