Average Error: 44.1 → 11.1
Time: 1.2m
Precision: 64
\[1.1102230246251565 \cdot 10^{-16} \lt a \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt b \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt c \lt 9007199254740992.0\]
\[\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.6209007775013438 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - \left(a \cdot c\right) \cdot 4\right) \cdot \sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b - \left(a \cdot c\right) \cdot 4\right) + \left(b \cdot \sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + b \cdot b\right)}}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{c}{b}}{2}\\ \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.6209007775013438 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b - \left(a \cdot c\right) \cdot 4\right) \cdot \sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b - \left(a \cdot c\right) \cdot 4\right) + \left(b \cdot \sqrt{b \cdot b - \left(a \cdot c\right) \cdot 4} + b \cdot b\right)}}{a}}{2}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4714664 = b;
        double r4714665 = -r4714664;
        double r4714666 = r4714664 * r4714664;
        double r4714667 = 4.0;
        double r4714668 = a;
        double r4714669 = r4714667 * r4714668;
        double r4714670 = c;
        double r4714671 = r4714669 * r4714670;
        double r4714672 = r4714666 - r4714671;
        double r4714673 = sqrt(r4714672);
        double r4714674 = r4714665 + r4714673;
        double r4714675 = 2.0;
        double r4714676 = r4714675 * r4714668;
        double r4714677 = r4714674 / r4714676;
        return r4714677;
}

double f(double a, double b, double c) {
        double r4714678 = b;
        double r4714679 = 1.6209007775013438e-05;
        bool r4714680 = r4714678 <= r4714679;
        double r4714681 = r4714678 * r4714678;
        double r4714682 = a;
        double r4714683 = c;
        double r4714684 = r4714682 * r4714683;
        double r4714685 = 4.0;
        double r4714686 = r4714684 * r4714685;
        double r4714687 = r4714681 - r4714686;
        double r4714688 = sqrt(r4714687);
        double r4714689 = r4714687 * r4714688;
        double r4714690 = r4714681 * r4714678;
        double r4714691 = r4714689 - r4714690;
        double r4714692 = r4714678 * r4714688;
        double r4714693 = r4714692 + r4714681;
        double r4714694 = r4714687 + r4714693;
        double r4714695 = r4714691 / r4714694;
        double r4714696 = r4714695 / r4714682;
        double r4714697 = 2.0;
        double r4714698 = r4714696 / r4714697;
        double r4714699 = -2.0;
        double r4714700 = r4714683 / r4714678;
        double r4714701 = r4714699 * r4714700;
        double r4714702 = r4714701 / r4714697;
        double r4714703 = r4714680 ? r4714698 : r4714702;
        return r4714703;
}

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 < 1.6209007775013438e-05

    1. Initial program 17.6

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

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

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

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

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

    if 1.6209007775013438e-05 < b

    1. Initial program 45.5

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

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

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

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

Reproduce

herbie shell --seed 2019158 
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))