Average Error: 34.0 → 11.0
Time: 5.5s
Precision: 64
\[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -524848456042.22467:\\ \;\;\;\;{\left(-1 \cdot \frac{c}{b}\right)}^{1}\\ \mathbf{elif}\;b \le -2.374474662067348 \cdot 10^{-33}:\\ \;\;\;\;{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}^{1}\\ \mathbf{elif}\;b \le -8.63724924767252634 \cdot 10^{-116}:\\ \;\;\;\;{\left(-1 \cdot \frac{c}{b}\right)}^{1}\\ \mathbf{elif}\;b \le 5.57925007375450966 \cdot 10^{51}:\\ \;\;\;\;{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(-1 \cdot \frac{b}{a}\right)}^{1}\\ \end{array}\]
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -524848456042.22467:\\
\;\;\;\;{\left(-1 \cdot \frac{c}{b}\right)}^{1}\\

\mathbf{elif}\;b \le -2.374474662067348 \cdot 10^{-33}:\\
\;\;\;\;{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}^{1}\\

\mathbf{elif}\;b \le -8.63724924767252634 \cdot 10^{-116}:\\
\;\;\;\;{\left(-1 \cdot \frac{c}{b}\right)}^{1}\\

\mathbf{elif}\;b \le 5.57925007375450966 \cdot 10^{51}:\\
\;\;\;\;{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}^{1}\\

\mathbf{else}:\\
\;\;\;\;{\left(-1 \cdot \frac{b}{a}\right)}^{1}\\

\end{array}
double f(double a, double b, double c) {
        double r56737 = b;
        double r56738 = -r56737;
        double r56739 = r56737 * r56737;
        double r56740 = 4.0;
        double r56741 = a;
        double r56742 = c;
        double r56743 = r56741 * r56742;
        double r56744 = r56740 * r56743;
        double r56745 = r56739 - r56744;
        double r56746 = sqrt(r56745);
        double r56747 = r56738 - r56746;
        double r56748 = 2.0;
        double r56749 = r56748 * r56741;
        double r56750 = r56747 / r56749;
        return r56750;
}

double f(double a, double b, double c) {
        double r56751 = b;
        double r56752 = -524848456042.2247;
        bool r56753 = r56751 <= r56752;
        double r56754 = -1.0;
        double r56755 = c;
        double r56756 = r56755 / r56751;
        double r56757 = r56754 * r56756;
        double r56758 = 1.0;
        double r56759 = pow(r56757, r56758);
        double r56760 = -2.374474662067348e-33;
        bool r56761 = r56751 <= r56760;
        double r56762 = -r56751;
        double r56763 = r56751 * r56751;
        double r56764 = 4.0;
        double r56765 = a;
        double r56766 = r56765 * r56755;
        double r56767 = r56764 * r56766;
        double r56768 = r56763 - r56767;
        double r56769 = sqrt(r56768);
        double r56770 = r56762 - r56769;
        double r56771 = 2.0;
        double r56772 = r56771 * r56765;
        double r56773 = r56770 / r56772;
        double r56774 = pow(r56773, r56758);
        double r56775 = -8.637249247672526e-116;
        bool r56776 = r56751 <= r56775;
        double r56777 = 5.5792500737545097e+51;
        bool r56778 = r56751 <= r56777;
        double r56779 = r56751 / r56765;
        double r56780 = r56754 * r56779;
        double r56781 = pow(r56780, r56758);
        double r56782 = r56778 ? r56774 : r56781;
        double r56783 = r56776 ? r56759 : r56782;
        double r56784 = r56761 ? r56774 : r56783;
        double r56785 = r56753 ? r56759 : r56784;
        return r56785;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original34.0
Target21.3
Herbie11.0
\[\begin{array}{l} \mathbf{if}\;b \lt 0.0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if b < -524848456042.2247 or -2.374474662067348e-33 < b < -8.637249247672526e-116

    1. Initial program 52.5

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv52.5

      \[\leadsto \color{blue}{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}}\]
    4. Using strategy rm
    5. Applied pow152.5

      \[\leadsto \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \color{blue}{{\left(\frac{1}{2 \cdot a}\right)}^{1}}\]
    6. Applied pow152.5

      \[\leadsto \color{blue}{{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}^{1}} \cdot {\left(\frac{1}{2 \cdot a}\right)}^{1}\]
    7. Applied pow-prod-down52.5

      \[\leadsto \color{blue}{{\left(\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}\right)}^{1}}\]
    8. Simplified52.5

      \[\leadsto {\color{blue}{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}}^{1}\]
    9. Taylor expanded around -inf 9.7

      \[\leadsto {\color{blue}{\left(-1 \cdot \frac{c}{b}\right)}}^{1}\]

    if -524848456042.2247 < b < -2.374474662067348e-33 or -8.637249247672526e-116 < b < 5.5792500737545097e+51

    1. Initial program 14.8

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv14.9

      \[\leadsto \color{blue}{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}}\]
    4. Using strategy rm
    5. Applied pow114.9

      \[\leadsto \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \color{blue}{{\left(\frac{1}{2 \cdot a}\right)}^{1}}\]
    6. Applied pow114.9

      \[\leadsto \color{blue}{{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}^{1}} \cdot {\left(\frac{1}{2 \cdot a}\right)}^{1}\]
    7. Applied pow-prod-down14.9

      \[\leadsto \color{blue}{{\left(\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}\right)}^{1}}\]
    8. Simplified14.8

      \[\leadsto {\color{blue}{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}}^{1}\]

    if 5.5792500737545097e+51 < b

    1. Initial program 38.1

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv38.2

      \[\leadsto \color{blue}{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}}\]
    4. Using strategy rm
    5. Applied pow138.2

      \[\leadsto \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \color{blue}{{\left(\frac{1}{2 \cdot a}\right)}^{1}}\]
    6. Applied pow138.2

      \[\leadsto \color{blue}{{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}^{1}} \cdot {\left(\frac{1}{2 \cdot a}\right)}^{1}\]
    7. Applied pow-prod-down38.2

      \[\leadsto \color{blue}{{\left(\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{2 \cdot a}\right)}^{1}}\]
    8. Simplified38.1

      \[\leadsto {\color{blue}{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}}^{1}\]
    9. Using strategy rm
    10. Applied clear-num38.2

      \[\leadsto {\color{blue}{\left(\frac{1}{\frac{2 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}\right)}}^{1}\]
    11. Taylor expanded around 0 5.8

      \[\leadsto {\color{blue}{\left(-1 \cdot \frac{b}{a}\right)}}^{1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification11.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -524848456042.22467:\\ \;\;\;\;{\left(-1 \cdot \frac{c}{b}\right)}^{1}\\ \mathbf{elif}\;b \le -2.374474662067348 \cdot 10^{-33}:\\ \;\;\;\;{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}^{1}\\ \mathbf{elif}\;b \le -8.63724924767252634 \cdot 10^{-116}:\\ \;\;\;\;{\left(-1 \cdot \frac{c}{b}\right)}^{1}\\ \mathbf{elif}\;b \le 5.57925007375450966 \cdot 10^{51}:\\ \;\;\;\;{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(-1 \cdot \frac{b}{a}\right)}^{1}\\ \end{array}\]

Reproduce

herbie shell --seed 2020018 +o rules:numerics
(FPCore (a b c)
  :name "quadm (p42, negative)"
  :precision binary64

  :herbie-target
  (if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))

  (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))