Average Error: 16.7 → 0.3
Time: 15.1s
Precision: 64
\[b \lt 0.0 \land {b}^{2} - 4 \cdot ac \ge 0.0\]
\[\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac} \le 2.660619236662567072568073064176938680373 \cdot 10^{153}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{ac}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac} \le 2.660619236662567072568073064176938680373 \cdot 10^{153}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{{b}^{2} - 4 \cdot ac}}{2 \cdot a}\\

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

\end{array}
double f(double b, double ac, double a) {
        double r3548502 = b;
        double r3548503 = -r3548502;
        double r3548504 = 2.0;
        double r3548505 = pow(r3548502, r3548504);
        double r3548506 = 4.0;
        double r3548507 = ac;
        double r3548508 = r3548506 * r3548507;
        double r3548509 = r3548505 - r3548508;
        double r3548510 = sqrt(r3548509);
        double r3548511 = r3548503 + r3548510;
        double r3548512 = a;
        double r3548513 = r3548504 * r3548512;
        double r3548514 = r3548511 / r3548513;
        return r3548514;
}

double f(double b, double ac, double a) {
        double r3548515 = b;
        double r3548516 = -r3548515;
        double r3548517 = 2.0;
        double r3548518 = pow(r3548515, r3548517);
        double r3548519 = 4.0;
        double r3548520 = ac;
        double r3548521 = r3548519 * r3548520;
        double r3548522 = r3548518 - r3548521;
        double r3548523 = sqrt(r3548522);
        double r3548524 = r3548516 + r3548523;
        double r3548525 = 2.660619236662567e+153;
        bool r3548526 = r3548524 <= r3548525;
        double r3548527 = a;
        double r3548528 = r3548517 * r3548527;
        double r3548529 = r3548524 / r3548528;
        double r3548530 = r3548520 / r3548515;
        double r3548531 = r3548517 * r3548530;
        double r3548532 = 2.0;
        double r3548533 = r3548532 * r3548515;
        double r3548534 = r3548531 - r3548533;
        double r3548535 = r3548534 / r3548528;
        double r3548536 = r3548526 ? r3548529 : r3548535;
        return r3548536;
}

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 2 regimes
  2. if (+ (- b) (sqrt (- (pow b 2.0) (* 4.0 ac)))) < 2.660619236662567e+153

    1. Initial program 0.2

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

    if 2.660619236662567e+153 < (+ (- b) (sqrt (- (pow b 2.0) (* 4.0 ac))))

    1. Initial program 63.2

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

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

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

Reproduce

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