Average Error: 33.2 → 9.7
Time: 53.4s
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 -4.232834657182634 \cdot 10^{+85}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.958298658834631 \cdot 10^{-149}:\\ \;\;\;\;\frac{c \cdot a}{\left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right) \cdot a}\\ \mathbf{elif}\;b_2 \le 3.8685970339297164 \cdot 10^{+90}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \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 -4.232834657182634 \cdot 10^{+85}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -2.958298658834631 \cdot 10^{-149}:\\
\;\;\;\;\frac{c \cdot a}{\left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right) \cdot a}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r2120729 = b_2;
        double r2120730 = -r2120729;
        double r2120731 = r2120729 * r2120729;
        double r2120732 = a;
        double r2120733 = c;
        double r2120734 = r2120732 * r2120733;
        double r2120735 = r2120731 - r2120734;
        double r2120736 = sqrt(r2120735);
        double r2120737 = r2120730 - r2120736;
        double r2120738 = r2120737 / r2120732;
        return r2120738;
}

double f(double a, double b_2, double c) {
        double r2120739 = b_2;
        double r2120740 = -4.232834657182634e+85;
        bool r2120741 = r2120739 <= r2120740;
        double r2120742 = -0.5;
        double r2120743 = c;
        double r2120744 = r2120743 / r2120739;
        double r2120745 = r2120742 * r2120744;
        double r2120746 = -2.958298658834631e-149;
        bool r2120747 = r2120739 <= r2120746;
        double r2120748 = a;
        double r2120749 = r2120743 * r2120748;
        double r2120750 = r2120739 * r2120739;
        double r2120751 = r2120750 - r2120749;
        double r2120752 = sqrt(r2120751);
        double r2120753 = r2120752 - r2120739;
        double r2120754 = r2120753 * r2120748;
        double r2120755 = r2120749 / r2120754;
        double r2120756 = 3.8685970339297164e+90;
        bool r2120757 = r2120739 <= r2120756;
        double r2120758 = -r2120739;
        double r2120759 = r2120758 - r2120752;
        double r2120760 = r2120759 / r2120748;
        double r2120761 = -2.0;
        double r2120762 = r2120739 / r2120748;
        double r2120763 = r2120761 * r2120762;
        double r2120764 = r2120757 ? r2120760 : r2120763;
        double r2120765 = r2120747 ? r2120755 : r2120764;
        double r2120766 = r2120741 ? r2120745 : r2120765;
        return r2120766;
}

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 < -4.232834657182634e+85

    1. Initial program 57.9

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

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    4. Taylor expanded around -inf 2.5

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

    if -4.232834657182634e+85 < b_2 < -2.958298658834631e-149

    1. Initial program 38.7

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

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

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

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

      \[\leadsto \frac{\color{blue}{a \cdot c}}{\left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot a}\]
    8. Simplified18.9

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

    if -2.958298658834631e-149 < b_2 < 3.8685970339297164e+90

    1. Initial program 11.9

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity11.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    4. Applied associate-/l*12.0

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity12.0

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}\]
    7. Applied *-un-lft-identity12.0

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot a}}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    8. Applied times-frac12.0

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    9. Applied add-sqr-sqrt12.0

      \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{1}{1} \cdot \frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    10. Applied times-frac12.0

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

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

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

    if 3.8685970339297164e+90 < b_2

    1. Initial program 42.2

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity42.2

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}{a}\]
    4. Applied associate-/l*42.3

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    5. Taylor expanded around 0 3.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.232834657182634 \cdot 10^{+85}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.958298658834631 \cdot 10^{-149}:\\ \;\;\;\;\frac{c \cdot a}{\left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right) \cdot a}\\ \mathbf{elif}\;b_2 \le 3.8685970339297164 \cdot 10^{+90}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019112 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))