Average Error: 34.1 → 6.2
Time: 19.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 -1.008402374157600307221015587992064225208 \cdot 10^{154}:\\ \;\;\;\;-\left(2 \cdot \frac{b_2}{a} - \frac{1}{2} \cdot \frac{c}{b_2}\right)\\ \mathbf{elif}\;b_2 \le -7.907890444019499210313940612078623500813 \cdot 10^{-210}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 2.322251336454993272811310600310011909818 \cdot 10^{153}:\\ \;\;\;\;-\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.008402374157600307221015587992064225208 \cdot 10^{154}:\\
\;\;\;\;-\left(2 \cdot \frac{b_2}{a} - \frac{1}{2} \cdot \frac{c}{b_2}\right)\\

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

\mathbf{elif}\;b_2 \le 2.322251336454993272811310600310011909818 \cdot 10^{153}:\\
\;\;\;\;-\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 r25830 = b_2;
        double r25831 = -r25830;
        double r25832 = r25830 * r25830;
        double r25833 = a;
        double r25834 = c;
        double r25835 = r25833 * r25834;
        double r25836 = r25832 - r25835;
        double r25837 = sqrt(r25836);
        double r25838 = r25831 + r25837;
        double r25839 = r25838 / r25833;
        return r25839;
}

double f(double a, double b_2, double c) {
        double r25840 = b_2;
        double r25841 = -1.0084023741576003e+154;
        bool r25842 = r25840 <= r25841;
        double r25843 = 2.0;
        double r25844 = a;
        double r25845 = r25840 / r25844;
        double r25846 = r25843 * r25845;
        double r25847 = 0.5;
        double r25848 = c;
        double r25849 = r25848 / r25840;
        double r25850 = r25847 * r25849;
        double r25851 = r25846 - r25850;
        double r25852 = -r25851;
        double r25853 = -7.907890444019499e-210;
        bool r25854 = r25840 <= r25853;
        double r25855 = r25840 * r25840;
        double r25856 = r25844 * r25848;
        double r25857 = r25855 - r25856;
        double r25858 = sqrt(r25857);
        double r25859 = r25858 / r25844;
        double r25860 = r25859 - r25845;
        double r25861 = 2.3222513364549933e+153;
        bool r25862 = r25840 <= r25861;
        double r25863 = r25858 + r25840;
        double r25864 = r25848 / r25863;
        double r25865 = -r25864;
        double r25866 = -0.5;
        double r25867 = r25866 * r25849;
        double r25868 = r25862 ? r25865 : r25867;
        double r25869 = r25854 ? r25860 : r25868;
        double r25870 = r25842 ? r25852 : r25869;
        return r25870;
}

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.0084023741576003e+154

    1. Initial program 64.0

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{0}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2} - \frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    8. Applied div-sub62.7

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

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

      \[\leadsto 0 - \color{blue}{\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2} \cdot 1}\]
    11. Using strategy rm
    12. Applied clear-num62.5

      \[\leadsto 0 - \color{blue}{\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{c}}} \cdot 1\]
    13. Simplified62.5

      \[\leadsto 0 - \frac{1}{\color{blue}{\frac{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}} \cdot 1\]
    14. Taylor expanded around -inf 1.7

      \[\leadsto 0 - \color{blue}{\left(2 \cdot \frac{b_2}{a} - \frac{1}{2} \cdot \frac{c}{b_2}\right)} \cdot 1\]

    if -1.0084023741576003e+154 < b_2 < -7.907890444019499e-210

    1. Initial program 6.6

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

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

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

    if -7.907890444019499e-210 < b_2 < 2.3222513364549933e+153

    1. Initial program 32.0

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

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

      \[\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. Simplified16.2

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

      \[\leadsto \frac{\color{blue}{\frac{0}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2} - \frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    8. Applied div-sub16.2

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

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

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

    if 2.3222513364549933e+153 < b_2

    1. Initial program 64.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.008402374157600307221015587992064225208 \cdot 10^{154}:\\ \;\;\;\;-\left(2 \cdot \frac{b_2}{a} - \frac{1}{2} \cdot \frac{c}{b_2}\right)\\ \mathbf{elif}\;b_2 \le -7.907890444019499210313940612078623500813 \cdot 10^{-210}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 2.322251336454993272811310600310011909818 \cdot 10^{153}:\\ \;\;\;\;-\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 2019325 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))