Average Error: 34.4 → 6.8
Time: 6.0s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -4.30101840923646093 \cdot 10^{98}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -2.37577225186574925 \cdot 10^{-260}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{elif}\;b \le 6.66645678090455348 \cdot 10^{68}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -4.30101840923646093 \cdot 10^{98}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r55791 = b;
        double r55792 = -r55791;
        double r55793 = r55791 * r55791;
        double r55794 = 4.0;
        double r55795 = a;
        double r55796 = r55794 * r55795;
        double r55797 = c;
        double r55798 = r55796 * r55797;
        double r55799 = r55793 - r55798;
        double r55800 = sqrt(r55799);
        double r55801 = r55792 + r55800;
        double r55802 = 2.0;
        double r55803 = r55802 * r55795;
        double r55804 = r55801 / r55803;
        return r55804;
}

double f(double a, double b, double c) {
        double r55805 = b;
        double r55806 = -4.301018409236461e+98;
        bool r55807 = r55805 <= r55806;
        double r55808 = 1.0;
        double r55809 = c;
        double r55810 = r55809 / r55805;
        double r55811 = a;
        double r55812 = r55805 / r55811;
        double r55813 = r55810 - r55812;
        double r55814 = r55808 * r55813;
        double r55815 = -2.3757722518657493e-260;
        bool r55816 = r55805 <= r55815;
        double r55817 = -r55805;
        double r55818 = r55805 * r55805;
        double r55819 = 4.0;
        double r55820 = r55819 * r55811;
        double r55821 = r55820 * r55809;
        double r55822 = r55818 - r55821;
        double r55823 = sqrt(r55822);
        double r55824 = r55817 + r55823;
        double r55825 = 1.0;
        double r55826 = 2.0;
        double r55827 = r55826 * r55811;
        double r55828 = r55825 / r55827;
        double r55829 = r55824 * r55828;
        double r55830 = 6.6664567809045535e+68;
        bool r55831 = r55805 <= r55830;
        double r55832 = r55826 * r55809;
        double r55833 = r55817 - r55823;
        double r55834 = r55832 / r55833;
        double r55835 = -1.0;
        double r55836 = r55835 * r55810;
        double r55837 = r55831 ? r55834 : r55836;
        double r55838 = r55816 ? r55829 : r55837;
        double r55839 = r55807 ? r55814 : r55838;
        return r55839;
}

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

Derivation

  1. Split input into 4 regimes
  2. if b < -4.301018409236461e+98

    1. Initial program 47.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around -inf 3.9

      \[\leadsto \color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\]
    3. Simplified3.9

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

    if -4.301018409236461e+98 < b < -2.3757722518657493e-260

    1. Initial program 8.5

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

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

    if -2.3757722518657493e-260 < b < 6.6664567809045535e+68

    1. Initial program 29.1

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

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

      \[\leadsto \frac{\frac{\color{blue}{0 + 4 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
    5. Using strategy rm
    6. Applied clear-num16.4

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}}\]
    7. Simplified16.0

      \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot a}{4 \cdot \left(a \cdot c\right)} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
    8. Using strategy rm
    9. Applied associate-/r*15.8

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

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

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

    if 6.6664567809045535e+68 < b

    1. Initial program 58.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around inf 3.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.30101840923646093 \cdot 10^{98}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -2.37577225186574925 \cdot 10^{-260}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{elif}\;b \le 6.66645678090455348 \cdot 10^{68}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2020020 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))