Average Error: 34.0 → 10.0
Time: 20.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 -1.2705286994550075 \cdot 10^{+152}:\\ \;\;\;\;\frac{c}{2 \cdot b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.744031351412433 \cdot 10^{-142}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \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.2705286994550075 \cdot 10^{+152}:\\
\;\;\;\;\frac{c}{2 \cdot b_2} - 2 \cdot \frac{b_2}{a}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r818844 = b_2;
        double r818845 = -r818844;
        double r818846 = r818844 * r818844;
        double r818847 = a;
        double r818848 = c;
        double r818849 = r818847 * r818848;
        double r818850 = r818846 - r818849;
        double r818851 = sqrt(r818850);
        double r818852 = r818845 + r818851;
        double r818853 = r818852 / r818847;
        return r818853;
}

double f(double a, double b_2, double c) {
        double r818854 = b_2;
        double r818855 = -1.2705286994550075e+152;
        bool r818856 = r818854 <= r818855;
        double r818857 = c;
        double r818858 = 2.0;
        double r818859 = r818858 * r818854;
        double r818860 = r818857 / r818859;
        double r818861 = a;
        double r818862 = r818854 / r818861;
        double r818863 = r818858 * r818862;
        double r818864 = r818860 - r818863;
        double r818865 = 1.744031351412433e-142;
        bool r818866 = r818854 <= r818865;
        double r818867 = r818854 * r818854;
        double r818868 = r818857 * r818861;
        double r818869 = r818867 - r818868;
        double r818870 = sqrt(r818869);
        double r818871 = r818870 - r818854;
        double r818872 = r818871 / r818861;
        double r818873 = -0.5;
        double r818874 = r818857 / r818854;
        double r818875 = r818873 * r818874;
        double r818876 = r818866 ? r818872 : r818875;
        double r818877 = r818856 ? r818864 : r818876;
        return r818877;
}

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 3 regimes
  2. if b_2 < -1.2705286994550075e+152

    1. Initial program 60.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified60.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv60.0

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Taylor expanded around -inf 1.6

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]
    6. Simplified1.6

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

    if -1.2705286994550075e+152 < b_2 < 1.744031351412433e-142

    1. Initial program 10.2

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv10.3

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied associate-*r/10.2

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

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

    if 1.744031351412433e-142 < b_2

    1. Initial program 50.1

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified50.1

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 12.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.2705286994550075 \cdot 10^{+152}:\\ \;\;\;\;\frac{c}{2 \cdot b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.744031351412433 \cdot 10^{-142}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019168 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))