Average Error: 28.1 → 5.2
Time: 16.8s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.364518563900793425394723216343856507154 \cdot 10^{154}:\\ \;\;\;\;\frac{2 \cdot \frac{ac}{b} - 2 \cdot b}{2 \cdot a}\\ \mathbf{elif}\;b \le 9.136850810026025682589965659842515760697 \cdot 10^{-73}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{ac}{b}}{2 \cdot a}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -1.364518563900793425394723216343856507154 \cdot 10^{154}:\\
\;\;\;\;\frac{2 \cdot \frac{ac}{b} - 2 \cdot b}{2 \cdot a}\\

\mathbf{elif}\;b \le 9.136850810026025682589965659842515760697 \cdot 10^{-73}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac}}{2 \cdot a}\\

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

\end{array}
double f(double b, double ac, double a) {
        double r3517908 = b;
        double r3517909 = -r3517908;
        double r3517910 = 2.0;
        double r3517911 = pow(r3517908, r3517910);
        double r3517912 = 4.0;
        double r3517913 = ac;
        double r3517914 = r3517912 * r3517913;
        double r3517915 = r3517911 - r3517914;
        double r3517916 = sqrt(r3517915);
        double r3517917 = r3517909 + r3517916;
        double r3517918 = a;
        double r3517919 = r3517910 * r3517918;
        double r3517920 = r3517917 / r3517919;
        return r3517920;
}

double f(double b, double ac, double a) {
        double r3517921 = b;
        double r3517922 = -1.3645185639007934e+154;
        bool r3517923 = r3517921 <= r3517922;
        double r3517924 = 2.0;
        double r3517925 = ac;
        double r3517926 = r3517925 / r3517921;
        double r3517927 = r3517924 * r3517926;
        double r3517928 = 2.0;
        double r3517929 = r3517928 * r3517921;
        double r3517930 = r3517927 - r3517929;
        double r3517931 = a;
        double r3517932 = r3517924 * r3517931;
        double r3517933 = r3517930 / r3517932;
        double r3517934 = 9.136850810026026e-73;
        bool r3517935 = r3517921 <= r3517934;
        double r3517936 = -r3517921;
        double r3517937 = pow(r3517921, r3517924);
        double r3517938 = 4.0;
        double r3517939 = r3517938 * r3517925;
        double r3517940 = r3517937 - r3517939;
        double r3517941 = sqrt(r3517940);
        double r3517942 = r3517936 + r3517941;
        double r3517943 = r3517942 / r3517932;
        double r3517944 = -2.0;
        double r3517945 = r3517944 * r3517926;
        double r3517946 = r3517945 / r3517932;
        double r3517947 = r3517935 ? r3517943 : r3517946;
        double r3517948 = r3517923 ? r3517933 : r3517947;
        return r3517948;
}

Error

Bits error versus b

Bits error versus ac

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -1.3645185639007934e+154

    1. Initial program 64.0

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

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{ac}{b} - 2 \cdot b}}{2 \cdot a}\]

    if -1.3645185639007934e+154 < b < 9.136850810026026e-73

    1. Initial program 1.2

      \[\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac}}{2 \cdot a}\]

    if 9.136850810026026e-73 < b

    1. Initial program 48.3

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

      \[\leadsto \frac{\color{blue}{-2 \cdot \frac{ac}{b}}}{2 \cdot a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification5.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.364518563900793425394723216343856507154 \cdot 10^{154}:\\ \;\;\;\;\frac{2 \cdot \frac{ac}{b} - 2 \cdot b}{2 \cdot a}\\ \mathbf{elif}\;b \le 9.136850810026025682589965659842515760697 \cdot 10^{-73}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{ac}{b}}{2 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (b ac a)
  :name "(-b+sqrt(b^2-4ac))/(2a)"
  :precision binary64
  (/ (+ (- b) (sqrt (- (pow b 2) (* 4 ac)))) (* 2 a)))