Average Error: 33.8 → 9.7
Time: 15.2s
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.4758305599808076 \cdot 10^{+144}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 1.739098950628615 \cdot 10^{-79}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\ \mathbf{elif}\;b_2 \le 1.8656332031849816 \cdot 10^{-25}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 5.297236684235463 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{\left(b_2 \cdot b_2 - c \cdot a\right) - b_2 \cdot b_2}{\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.4758305599808076 \cdot 10^{+144}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 1.739098950628615 \cdot 10^{-79}:\\
\;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\

\mathbf{elif}\;b_2 \le 1.8656332031849816 \cdot 10^{-25}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 5.297236684235463 \cdot 10^{-16}:\\
\;\;\;\;\frac{\frac{\left(b_2 \cdot b_2 - c \cdot a\right) - b_2 \cdot b_2}{\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 r367170 = b_2;
        double r367171 = -r367170;
        double r367172 = r367170 * r367170;
        double r367173 = a;
        double r367174 = c;
        double r367175 = r367173 * r367174;
        double r367176 = r367172 - r367175;
        double r367177 = sqrt(r367176);
        double r367178 = r367171 + r367177;
        double r367179 = r367178 / r367173;
        return r367179;
}

double f(double a, double b_2, double c) {
        double r367180 = b_2;
        double r367181 = -1.4758305599808076e+144;
        bool r367182 = r367180 <= r367181;
        double r367183 = 0.5;
        double r367184 = c;
        double r367185 = r367184 / r367180;
        double r367186 = r367183 * r367185;
        double r367187 = a;
        double r367188 = r367180 / r367187;
        double r367189 = 2.0;
        double r367190 = r367188 * r367189;
        double r367191 = r367186 - r367190;
        double r367192 = 1.739098950628615e-79;
        bool r367193 = r367180 <= r367192;
        double r367194 = 1.0;
        double r367195 = r367180 * r367180;
        double r367196 = r367184 * r367187;
        double r367197 = r367195 - r367196;
        double r367198 = sqrt(r367197);
        double r367199 = r367198 - r367180;
        double r367200 = r367187 / r367199;
        double r367201 = r367194 / r367200;
        double r367202 = 1.8656332031849816e-25;
        bool r367203 = r367180 <= r367202;
        double r367204 = -0.5;
        double r367205 = r367204 * r367185;
        double r367206 = 5.297236684235463e-16;
        bool r367207 = r367180 <= r367206;
        double r367208 = r367197 - r367195;
        double r367209 = r367198 + r367180;
        double r367210 = r367208 / r367209;
        double r367211 = r367210 / r367187;
        double r367212 = r367207 ? r367211 : r367205;
        double r367213 = r367203 ? r367205 : r367212;
        double r367214 = r367193 ? r367201 : r367213;
        double r367215 = r367182 ? r367191 : r367214;
        return r367215;
}

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.4758305599808076e+144

    1. Initial program 58.0

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

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

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

    if -1.4758305599808076e+144 < b_2 < 1.739098950628615e-79

    1. Initial program 11.8

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

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

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

    if 1.739098950628615e-79 < b_2 < 1.8656332031849816e-25 or 5.297236684235463e-16 < b_2

    1. Initial program 53.1

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

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

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

    if 1.8656332031849816e-25 < b_2 < 5.297236684235463e-16

    1. Initial program 42.7

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right) - b_2 \cdot b_2}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.4758305599808076 \cdot 10^{+144}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 1.739098950628615 \cdot 10^{-79}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\ \mathbf{elif}\;b_2 \le 1.8656332031849816 \cdot 10^{-25}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 5.297236684235463 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{\left(b_2 \cdot b_2 - c \cdot a\right) - b_2 \cdot b_2}{\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 2019156 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))