Average Error: 33.1 → 10.3
Time: 17.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.7729369216517423 \cdot 10^{+64}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 9.831724396970673 \cdot 10^{-110}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{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.7729369216517423 \cdot 10^{+64}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r458137 = b_2;
        double r458138 = -r458137;
        double r458139 = r458137 * r458137;
        double r458140 = a;
        double r458141 = c;
        double r458142 = r458140 * r458141;
        double r458143 = r458139 - r458142;
        double r458144 = sqrt(r458143);
        double r458145 = r458138 + r458144;
        double r458146 = r458145 / r458140;
        return r458146;
}

double f(double a, double b_2, double c) {
        double r458147 = b_2;
        double r458148 = -1.7729369216517423e+64;
        bool r458149 = r458147 <= r458148;
        double r458150 = 0.5;
        double r458151 = c;
        double r458152 = r458151 / r458147;
        double r458153 = r458150 * r458152;
        double r458154 = a;
        double r458155 = r458147 / r458154;
        double r458156 = 2.0;
        double r458157 = r458155 * r458156;
        double r458158 = r458153 - r458157;
        double r458159 = 9.831724396970673e-110;
        bool r458160 = r458147 <= r458159;
        double r458161 = r458147 * r458147;
        double r458162 = r458151 * r458154;
        double r458163 = r458161 - r458162;
        double r458164 = sqrt(r458163);
        double r458165 = r458164 - r458147;
        double r458166 = r458165 / r458154;
        double r458167 = -0.5;
        double r458168 = r458152 * r458167;
        double r458169 = r458160 ? r458166 : r458168;
        double r458170 = r458149 ? r458158 : r458169;
        return r458170;
}

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.7729369216517423e+64

    1. Initial program 37.7

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Simplified37.7

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

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

    if -1.7729369216517423e+64 < b_2 < 9.831724396970673e-110

    1. Initial program 12.0

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Simplified12.0

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

    if 9.831724396970673e-110 < b_2

    1. Initial program 50.9

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Simplified50.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.7729369216517423 \cdot 10^{+64}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 9.831724396970673 \cdot 10^{-110}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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