Average Error: 33.8 → 9.1
Time: 18.5s
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 -1.970010565552108757188050455448622102575 \cdot 10^{58}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.341090161490938310878248498686683235407 \cdot 10^{-308}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 3.628799960716311990444092539387346352569 \cdot 10^{50}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}{-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 -1.970010565552108757188050455448622102575 \cdot 10^{58}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r2743780 = b_2;
        double r2743781 = -r2743780;
        double r2743782 = r2743780 * r2743780;
        double r2743783 = a;
        double r2743784 = c;
        double r2743785 = r2743783 * r2743784;
        double r2743786 = r2743782 - r2743785;
        double r2743787 = sqrt(r2743786);
        double r2743788 = r2743781 - r2743787;
        double r2743789 = r2743788 / r2743783;
        return r2743789;
}

double f(double a, double b_2, double c) {
        double r2743790 = b_2;
        double r2743791 = -1.9700105655521088e+58;
        bool r2743792 = r2743790 <= r2743791;
        double r2743793 = -0.5;
        double r2743794 = c;
        double r2743795 = r2743794 / r2743790;
        double r2743796 = r2743793 * r2743795;
        double r2743797 = -1.3410901614909383e-308;
        bool r2743798 = r2743790 <= r2743797;
        double r2743799 = a;
        double r2743800 = r2743794 * r2743799;
        double r2743801 = r2743790 * r2743790;
        double r2743802 = r2743801 - r2743800;
        double r2743803 = sqrt(r2743802);
        double r2743804 = r2743803 - r2743790;
        double r2743805 = r2743800 / r2743804;
        double r2743806 = r2743805 / r2743799;
        double r2743807 = 3.628799960716312e+50;
        bool r2743808 = r2743790 <= r2743807;
        double r2743809 = r2743803 + r2743790;
        double r2743810 = -r2743799;
        double r2743811 = r2743809 / r2743810;
        double r2743812 = -2.0;
        double r2743813 = r2743790 / r2743799;
        double r2743814 = r2743812 * r2743813;
        double r2743815 = r2743808 ? r2743811 : r2743814;
        double r2743816 = r2743798 ? r2743806 : r2743815;
        double r2743817 = r2743792 ? r2743796 : r2743816;
        return r2743817;
}

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 < -1.9700105655521088e+58

    1. Initial program 57.5

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

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

    if -1.9700105655521088e+58 < b_2 < -1.3410901614909383e-308

    1. Initial program 29.4

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

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

    if -1.3410901614909383e-308 < b_2 < 3.628799960716312e+50

    1. Initial program 9.7

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

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

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

    if 3.628799960716312e+50 < b_2

    1. Initial program 38.1

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

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

      \[\leadsto \frac{\color{blue}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{-a}\]
    5. Using strategy rm
    6. Applied clear-num38.2

      \[\leadsto \color{blue}{\frac{1}{\frac{-a}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    7. Taylor expanded around 0 6.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.970010565552108757188050455448622102575 \cdot 10^{58}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.341090161490938310878248498686683235407 \cdot 10^{-308}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 3.628799960716311990444092539387346352569 \cdot 10^{50}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}{-a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

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