Average Error: 33.5 → 11.9
Time: 20.7s
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.3725796156555912 \cdot 10^{+127}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 3.207624111695675 \cdot 10^{-187}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 4.664677641347216 \cdot 10^{-111}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.922674299151799 \cdot 10^{-16}:\\ \;\;\;\;\frac{1}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2} \cdot \frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 + c \cdot a\right)}{a}\\ \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.3725796156555912 \cdot 10^{+127}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

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

\mathbf{elif}\;b_2 \le 4.664677641347216 \cdot 10^{-111}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 1.922674299151799 \cdot 10^{-16}:\\
\;\;\;\;\frac{1}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2} \cdot \frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 + c \cdot a\right)}{a}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r566695 = b_2;
        double r566696 = -r566695;
        double r566697 = r566695 * r566695;
        double r566698 = a;
        double r566699 = c;
        double r566700 = r566698 * r566699;
        double r566701 = r566697 - r566700;
        double r566702 = sqrt(r566701);
        double r566703 = r566696 + r566702;
        double r566704 = r566703 / r566698;
        return r566704;
}

double f(double a, double b_2, double c) {
        double r566705 = b_2;
        double r566706 = -1.3725796156555912e+127;
        bool r566707 = r566705 <= r566706;
        double r566708 = 0.5;
        double r566709 = c;
        double r566710 = r566709 / r566705;
        double r566711 = r566708 * r566710;
        double r566712 = a;
        double r566713 = r566705 / r566712;
        double r566714 = 2.0;
        double r566715 = r566713 * r566714;
        double r566716 = r566711 - r566715;
        double r566717 = 3.207624111695675e-187;
        bool r566718 = r566705 <= r566717;
        double r566719 = r566705 * r566705;
        double r566720 = r566709 * r566712;
        double r566721 = r566719 - r566720;
        double r566722 = sqrt(r566721);
        double r566723 = r566722 - r566705;
        double r566724 = r566723 / r566712;
        double r566725 = 4.664677641347216e-111;
        bool r566726 = r566705 <= r566725;
        double r566727 = -0.5;
        double r566728 = r566727 * r566710;
        double r566729 = 1.922674299151799e-16;
        bool r566730 = r566705 <= r566729;
        double r566731 = 1.0;
        double r566732 = r566722 + r566705;
        double r566733 = r566731 / r566732;
        double r566734 = r566719 + r566720;
        double r566735 = r566719 - r566734;
        double r566736 = r566735 / r566712;
        double r566737 = r566733 * r566736;
        double r566738 = r566730 ? r566737 : r566728;
        double r566739 = r566726 ? r566728 : r566738;
        double r566740 = r566718 ? r566724 : r566739;
        double r566741 = r566707 ? r566716 : r566740;
        return r566741;
}

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.3725796156555912e+127

    1. Initial program 51.4

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

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

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

    if -1.3725796156555912e+127 < b_2 < 3.207624111695675e-187

    1. Initial program 10.4

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity10.5

      \[\leadsto \frac{1}{\color{blue}{1 \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    7. Applied add-sqr-sqrt10.5

      \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{1 \cdot \frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\]
    8. Applied times-frac10.5

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{1} \cdot \frac{\sqrt{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    9. Simplified10.5

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

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

    if 3.207624111695675e-187 < b_2 < 4.664677641347216e-111 or 1.922674299151799e-16 < b_2

    1. Initial program 50.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified50.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 \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]

    if 4.664677641347216e-111 < b_2 < 1.922674299151799e-16

    1. Initial program 36.4

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied flip--36.5

      \[\leadsto \frac{1}{\frac{a}{\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}}}}\]
    7. Applied associate-/r/36.5

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2} \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    8. Applied *-un-lft-identity36.5

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2} \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}\]
    9. Applied times-frac36.5

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

      \[\leadsto \color{blue}{\frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 + a \cdot c\right)}{a}} \cdot \frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification11.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.3725796156555912 \cdot 10^{+127}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 3.207624111695675 \cdot 10^{-187}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 4.664677641347216 \cdot 10^{-111}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.922674299151799 \cdot 10^{-16}:\\ \;\;\;\;\frac{1}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2} \cdot \frac{b_2 \cdot b_2 - \left(b_2 \cdot b_2 + c \cdot a\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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