Average Error: 34.3 → 6.5
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.569310777886352095486911207889814773134 \cdot 10^{111}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -3.140090619310571426623098231932222517595 \cdot 10^{-291}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.608284405260305560018146283533738265178 \cdot 10^{78}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\ \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.569310777886352095486911207889814773134 \cdot 10^{111}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r22155 = b_2;
        double r22156 = -r22155;
        double r22157 = r22155 * r22155;
        double r22158 = a;
        double r22159 = c;
        double r22160 = r22158 * r22159;
        double r22161 = r22157 - r22160;
        double r22162 = sqrt(r22161);
        double r22163 = r22156 + r22162;
        double r22164 = r22163 / r22158;
        return r22164;
}

double f(double a, double b_2, double c) {
        double r22165 = b_2;
        double r22166 = -1.569310777886352e+111;
        bool r22167 = r22165 <= r22166;
        double r22168 = 0.5;
        double r22169 = c;
        double r22170 = r22169 / r22165;
        double r22171 = r22168 * r22170;
        double r22172 = 2.0;
        double r22173 = a;
        double r22174 = r22165 / r22173;
        double r22175 = r22172 * r22174;
        double r22176 = r22171 - r22175;
        double r22177 = -3.1400906193105714e-291;
        bool r22178 = r22165 <= r22177;
        double r22179 = r22165 * r22165;
        double r22180 = r22173 * r22169;
        double r22181 = r22179 - r22180;
        double r22182 = sqrt(r22181);
        double r22183 = r22182 - r22165;
        double r22184 = r22183 / r22173;
        double r22185 = 1.6082844052603056e+78;
        bool r22186 = r22165 <= r22185;
        double r22187 = -r22169;
        double r22188 = r22182 + r22165;
        double r22189 = r22187 / r22188;
        double r22190 = -0.5;
        double r22191 = r22190 * r22170;
        double r22192 = r22186 ? r22189 : r22191;
        double r22193 = r22178 ? r22184 : r22192;
        double r22194 = r22167 ? r22176 : r22193;
        return r22194;
}

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.569310777886352e+111

    1. Initial program 50.4

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

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

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

    if -1.569310777886352e+111 < b_2 < -3.1400906193105714e-291

    1. Initial program 8.4

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

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

    if -3.1400906193105714e-291 < b_2 < 1.6082844052603056e+78

    1. Initial program 30.6

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

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

      \[\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 flip--30.7

      \[\leadsto \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}} \cdot \frac{1}{a}\]
    7. Applied associate-*l/30.8

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

      \[\leadsto \frac{\color{blue}{\frac{0 - c \cdot a}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    9. Using strategy rm
    10. Applied div-sub15.7

      \[\leadsto \frac{\color{blue}{\frac{0}{a} - \frac{c \cdot a}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    11. Simplified15.7

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

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

    if 1.6082844052603056e+78 < b_2

    1. Initial program 58.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.569310777886352095486911207889814773134 \cdot 10^{111}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -3.140090619310571426623098231932222517595 \cdot 10^{-291}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.608284405260305560018146283533738265178 \cdot 10^{78}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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