Average Error: 33.4 → 8.7
Time: 30.1s
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.437749820440055 \cdot 10^{+147}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 6.777505233056137 \cdot 10^{-183}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.5984428400171422 \cdot 10^{-07}:\\ \;\;\;\;-\frac{\frac{c \cdot a}{a}}{\sqrt{b_2 \cdot b_2 - c \cdot a} + 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.437749820440055 \cdot 10^{+147}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r945882 = b_2;
        double r945883 = -r945882;
        double r945884 = r945882 * r945882;
        double r945885 = a;
        double r945886 = c;
        double r945887 = r945885 * r945886;
        double r945888 = r945884 - r945887;
        double r945889 = sqrt(r945888);
        double r945890 = r945883 + r945889;
        double r945891 = r945890 / r945885;
        return r945891;
}

double f(double a, double b_2, double c) {
        double r945892 = b_2;
        double r945893 = -1.437749820440055e+147;
        bool r945894 = r945892 <= r945893;
        double r945895 = 0.5;
        double r945896 = c;
        double r945897 = r945896 / r945892;
        double r945898 = r945895 * r945897;
        double r945899 = a;
        double r945900 = r945892 / r945899;
        double r945901 = 2.0;
        double r945902 = r945900 * r945901;
        double r945903 = r945898 - r945902;
        double r945904 = 6.777505233056137e-183;
        bool r945905 = r945892 <= r945904;
        double r945906 = r945892 * r945892;
        double r945907 = r945896 * r945899;
        double r945908 = r945906 - r945907;
        double r945909 = sqrt(r945908);
        double r945910 = r945909 - r945892;
        double r945911 = r945910 / r945899;
        double r945912 = 1.5984428400171422e-07;
        bool r945913 = r945892 <= r945912;
        double r945914 = r945907 / r945899;
        double r945915 = r945909 + r945892;
        double r945916 = r945914 / r945915;
        double r945917 = -r945916;
        double r945918 = -0.5;
        double r945919 = r945918 * r945897;
        double r945920 = r945913 ? r945917 : r945919;
        double r945921 = r945905 ? r945911 : r945920;
        double r945922 = r945894 ? r945903 : r945921;
        return r945922;
}

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.437749820440055e+147

    1. Initial program 58.1

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

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

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

    if -1.437749820440055e+147 < b_2 < 6.777505233056137e-183

    1. Initial program 10.1

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

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

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

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

    if 6.777505233056137e-183 < b_2 < 1.5984428400171422e-07

    1. Initial program 29.9

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

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{b_2 \cdot b_2 - a \cdot c}} - b_2}{a}\]
    5. Using strategy rm
    6. Applied div-inv29.9

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    7. Using strategy rm
    8. Applied flip--30.0

      \[\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}\]
    9. Applied associate-*l/30.0

      \[\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}}\]
    10. Simplified16.4

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

    if 1.5984428400171422e-07 < b_2

    1. Initial program 54.0

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.437749820440055 \cdot 10^{+147}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 6.777505233056137 \cdot 10^{-183}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.5984428400171422 \cdot 10^{-07}:\\ \;\;\;\;-\frac{\frac{c \cdot a}{a}}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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