Average Error: 44.1 → 0.4
Time: 16.5s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\frac{\left(4 \cdot a\right) \cdot c}{\mathsf{fma}\left(-b, a \cdot 2, \left(-\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(a \cdot 2\right)\right)}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{\left(4 \cdot a\right) \cdot c}{\mathsf{fma}\left(-b, a \cdot 2, \left(-\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(a \cdot 2\right)\right)}
double f(double a, double b, double c) {
        double r43645 = b;
        double r43646 = -r43645;
        double r43647 = r43645 * r43645;
        double r43648 = 4.0;
        double r43649 = a;
        double r43650 = r43648 * r43649;
        double r43651 = c;
        double r43652 = r43650 * r43651;
        double r43653 = r43647 - r43652;
        double r43654 = sqrt(r43653);
        double r43655 = r43646 + r43654;
        double r43656 = 2.0;
        double r43657 = r43656 * r43649;
        double r43658 = r43655 / r43657;
        return r43658;
}

double f(double a, double b, double c) {
        double r43659 = 4.0;
        double r43660 = a;
        double r43661 = r43659 * r43660;
        double r43662 = c;
        double r43663 = r43661 * r43662;
        double r43664 = b;
        double r43665 = -r43664;
        double r43666 = 2.0;
        double r43667 = r43660 * r43666;
        double r43668 = r43664 * r43664;
        double r43669 = r43668 - r43663;
        double r43670 = sqrt(r43669);
        double r43671 = -r43670;
        double r43672 = r43671 * r43667;
        double r43673 = fma(r43665, r43667, r43672);
        double r43674 = r43663 / r43673;
        return r43674;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Initial program 44.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-+44.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. Simplified0.4

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

    \[\leadsto \frac{\color{blue}{\left(0 + c \cdot \left(4 \cdot a\right)\right) \cdot \frac{1}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
  7. Applied associate-/l*0.5

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

    \[\leadsto \frac{0 + c \cdot \left(4 \cdot a\right)}{\color{blue}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}\]
  9. Using strategy rm
  10. Applied sub-neg0.4

    \[\leadsto \frac{0 + c \cdot \left(4 \cdot a\right)}{\left(a \cdot 2\right) \cdot \color{blue}{\left(\left(-b\right) + \left(-\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)\right)}}\]
  11. Applied distribute-rgt-in0.4

    \[\leadsto \frac{0 + c \cdot \left(4 \cdot a\right)}{\color{blue}{\left(-b\right) \cdot \left(a \cdot 2\right) + \left(-\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(a \cdot 2\right)}}\]
  12. Using strategy rm
  13. Applied fma-def0.4

    \[\leadsto \frac{0 + c \cdot \left(4 \cdot a\right)}{\color{blue}{\mathsf{fma}\left(-b, a \cdot 2, \left(-\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(a \cdot 2\right)\right)}}\]
  14. Final simplification0.4

    \[\leadsto \frac{\left(4 \cdot a\right) \cdot c}{\mathsf{fma}\left(-b, a \cdot 2, \left(-\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(a \cdot 2\right)\right)}\]

Reproduce

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