Average Error: 33.9 → 6.7
Time: 6.3s
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 -7.78489609812549271 \cdot 10^{150}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.06653630715331101 \cdot 10^{-284}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\frac{1}{c}}\\ \mathbf{elif}\;b_2 \le 2.3041961191710096 \cdot 10^{50}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot 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 -7.78489609812549271 \cdot 10^{150}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 1.06653630715331101 \cdot 10^{-284}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\frac{1}{c}}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r22662 = b_2;
        double r22663 = -r22662;
        double r22664 = r22662 * r22662;
        double r22665 = a;
        double r22666 = c;
        double r22667 = r22665 * r22666;
        double r22668 = r22664 - r22667;
        double r22669 = sqrt(r22668);
        double r22670 = r22663 - r22669;
        double r22671 = r22670 / r22665;
        return r22671;
}

double f(double a, double b_2, double c) {
        double r22672 = b_2;
        double r22673 = -7.784896098125493e+150;
        bool r22674 = r22672 <= r22673;
        double r22675 = -0.5;
        double r22676 = c;
        double r22677 = r22676 / r22672;
        double r22678 = r22675 * r22677;
        double r22679 = 1.066536307153311e-284;
        bool r22680 = r22672 <= r22679;
        double r22681 = 1.0;
        double r22682 = r22672 * r22672;
        double r22683 = a;
        double r22684 = r22683 * r22676;
        double r22685 = r22682 - r22684;
        double r22686 = sqrt(r22685);
        double r22687 = r22686 - r22672;
        double r22688 = r22681 / r22687;
        double r22689 = r22681 / r22676;
        double r22690 = r22688 / r22689;
        double r22691 = 2.3041961191710096e+50;
        bool r22692 = r22672 <= r22691;
        double r22693 = -r22672;
        double r22694 = r22693 - r22686;
        double r22695 = r22694 / r22683;
        double r22696 = -2.0;
        double r22697 = r22696 * r22672;
        double r22698 = r22697 / r22683;
        double r22699 = r22692 ? r22695 : r22698;
        double r22700 = r22680 ? r22690 : r22699;
        double r22701 = r22674 ? r22678 : r22700;
        return r22701;
}

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 < -7.784896098125493e+150

    1. Initial program 63.8

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around -inf 1.2

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

    if -7.784896098125493e+150 < b_2 < 1.066536307153311e-284

    1. Initial program 33.7

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

      \[\leadsto \frac{\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}}}}{a}\]
    4. Simplified15.7

      \[\leadsto \frac{\frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Simplified15.7

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

      \[\leadsto \frac{\frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied associate-/r*15.7

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

      \[\leadsto \frac{\color{blue}{\frac{a}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{c}}}}{a}\]
    10. Using strategy rm
    11. Applied div-inv13.8

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2} \cdot \frac{a}{\frac{1}{c}}}}{a}\]
    14. Applied associate-/l*14.2

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

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

    if 1.066536307153311e-284 < b_2 < 2.3041961191710096e+50

    1. Initial program 9.0

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

    if 2.3041961191710096e+50 < b_2

    1. Initial program 37.9

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

      \[\leadsto \frac{\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}}}}{a}\]
    4. Simplified60.7

      \[\leadsto \frac{\frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Simplified60.7

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

      \[\leadsto \frac{\frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied associate-/r*60.7

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

      \[\leadsto \frac{\color{blue}{\frac{a}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{c}}}}{a}\]
    10. Taylor expanded around 0 5.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -7.78489609812549271 \cdot 10^{150}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.06653630715331101 \cdot 10^{-284}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\frac{1}{c}}\\ \mathbf{elif}\;b_2 \le 2.3041961191710096 \cdot 10^{50}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b_2}{a}\\ \end{array}\]

Reproduce

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