Average Error: 32.9 → 10.3
Time: 14.9s
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 -9.088000531423294 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 9.354082991670835 \cdot 10^{-125}:\\ \;\;\;\;\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 -9.088000531423294 \cdot 10^{+152}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 9.354082991670835 \cdot 10^{-125}:\\
\;\;\;\;\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 r273086 = b_2;
        double r273087 = -r273086;
        double r273088 = r273086 * r273086;
        double r273089 = a;
        double r273090 = c;
        double r273091 = r273089 * r273090;
        double r273092 = r273088 - r273091;
        double r273093 = sqrt(r273092);
        double r273094 = r273087 + r273093;
        double r273095 = r273094 / r273089;
        return r273095;
}

double f(double a, double b_2, double c) {
        double r273096 = b_2;
        double r273097 = -9.088000531423294e+152;
        bool r273098 = r273096 <= r273097;
        double r273099 = 0.5;
        double r273100 = c;
        double r273101 = r273100 / r273096;
        double r273102 = r273099 * r273101;
        double r273103 = a;
        double r273104 = r273096 / r273103;
        double r273105 = 2.0;
        double r273106 = r273104 * r273105;
        double r273107 = r273102 - r273106;
        double r273108 = 9.354082991670835e-125;
        bool r273109 = r273096 <= r273108;
        double r273110 = r273096 * r273096;
        double r273111 = r273100 * r273103;
        double r273112 = r273110 - r273111;
        double r273113 = sqrt(r273112);
        double r273114 = r273113 - r273096;
        double r273115 = r273114 / r273103;
        double r273116 = -0.5;
        double r273117 = r273101 * r273116;
        double r273118 = r273109 ? r273115 : r273117;
        double r273119 = r273098 ? r273107 : r273118;
        return r273119;
}

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 < -9.088000531423294e+152

    1. Initial program 60.5

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

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

      \[\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.5

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

    if -9.088000531423294e+152 < b_2 < 9.354082991670835e-125

    1. Initial program 10.9

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

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

      \[\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.9

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

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

    if 9.354082991670835e-125 < b_2

    1. Initial program 49.8

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

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

      \[\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 11.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 -9.088000531423294 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 9.354082991670835 \cdot 10^{-125}:\\ \;\;\;\;\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 2019153 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))