Average Error: 43.7 → 11.1
Time: 6.5s
Precision: 64
\[1.11022 \cdot 10^{-16} \lt a \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt b \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt c \lt 9.0072 \cdot 10^{15}\]
\[\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 1.7936624356974993 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{\frac{\left({b}^{2} - 4 \cdot \left(a \cdot c\right)\right) - {b}^{2}}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2}}{a}\\ \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 1.7936624356974993 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{\frac{\left({b}^{2} - 4 \cdot \left(a \cdot c\right)\right) - {b}^{2}}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{2}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r24681 = b;
        double r24682 = -r24681;
        double r24683 = r24681 * r24681;
        double r24684 = 4.0;
        double r24685 = a;
        double r24686 = r24684 * r24685;
        double r24687 = c;
        double r24688 = r24686 * r24687;
        double r24689 = r24683 - r24688;
        double r24690 = sqrt(r24689);
        double r24691 = r24682 + r24690;
        double r24692 = 2.0;
        double r24693 = r24692 * r24685;
        double r24694 = r24691 / r24693;
        return r24694;
}

double f(double a, double b, double c) {
        double r24695 = b;
        double r24696 = 0.00017936624356974993;
        bool r24697 = r24695 <= r24696;
        double r24698 = 2.0;
        double r24699 = pow(r24695, r24698);
        double r24700 = 4.0;
        double r24701 = a;
        double r24702 = c;
        double r24703 = r24701 * r24702;
        double r24704 = r24700 * r24703;
        double r24705 = r24699 - r24704;
        double r24706 = r24705 - r24699;
        double r24707 = r24695 * r24695;
        double r24708 = r24700 * r24701;
        double r24709 = r24708 * r24702;
        double r24710 = r24707 - r24709;
        double r24711 = sqrt(r24710);
        double r24712 = r24711 + r24695;
        double r24713 = r24706 / r24712;
        double r24714 = 2.0;
        double r24715 = r24713 / r24714;
        double r24716 = r24715 / r24701;
        double r24717 = -1.0;
        double r24718 = r24702 / r24695;
        double r24719 = r24717 * r24718;
        double r24720 = r24697 ? r24716 : r24719;
        return r24720;
}

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 2 regimes
  2. if b < 0.00017936624356974993

    1. Initial program 18.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified18.3

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

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

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

    if 0.00017936624356974993 < b

    1. Initial program 45.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified45.6

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}}\]
    3. Taylor expanded around inf 10.7

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

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

Reproduce

herbie shell --seed 2020047 
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))