Average Error: 44.0 → 2.8
Time: 11.0s
Precision: binary64
Cost: 34432
\[1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992 \land 1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992 \land 1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - \frac{c}{b}\right) + -5 \cdot \frac{\left(a \cdot a\right) \cdot \left(a \cdot {c}^{4}\right)}{{b}^{7}}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - \frac{c}{b}\right) + -5 \cdot \frac{\left(a \cdot a\right) \cdot \left(a \cdot {c}^{4}\right)}{{b}^{7}}
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (+
  (-
   (-
    (* -2.0 (/ (* (* a a) (pow c 3.0)) (pow b 5.0)))
    (/ (* a (* c c)) (pow b 3.0)))
   (/ c b))
  (* -5.0 (/ (* (* a a) (* a (pow c 4.0))) (pow b 7.0)))))
double code(double a, double b, double c) {
	return (-b + sqrt((b * b) - ((4.0 * a) * c))) / (2.0 * a);
}
double code(double a, double b, double c) {
	return (((-2.0 * (((a * a) * pow(c, 3.0)) / pow(b, 5.0))) - ((a * (c * c)) / pow(b, 3.0))) - (c / b)) + (-5.0 * (((a * a) * (a * pow(c, 4.0))) / pow(b, 7.0)));
}

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

Alternatives

Alternative 1
Error4.6
Cost21057
\[\begin{array}{l} \mathbf{if}\;b \leq 0.0026305871342749447:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(a \cdot 4\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - \frac{c}{b}\\ \end{array}\]
Alternative 2
Error6.1
Cost8577
\[\begin{array}{l} \mathbf{if}\;b \leq 0.004456882830972271:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - c \cdot \left(a \cdot 4\right)\right) - b \cdot b}{b + \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(-\frac{c}{b}\right) - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\\ \end{array}\]
Alternative 3
Error6.2
Cost7681
\[\begin{array}{l} \mathbf{if}\;b \leq 0.0026305871342749447:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(-\frac{c}{b}\right) - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\\ \end{array}\]
Alternative 4
Error6.2
Cost7681
\[\begin{array}{l} \mathbf{if}\;b \leq 0.0030183319545777423:\\ \;\;\;\;\left(\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b\right) \cdot \frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(-\frac{c}{b}\right) - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\\ \end{array}\]
Alternative 5
Error5.8
Cost7232
\[\left(-\frac{c}{b}\right) - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\]
Alternative 6
Error11.9
Cost256
\[-\frac{c}{b}\]
Alternative 7
Error56.6
Cost64
\[-1\]
Alternative 8
Error62.0
Cost64
\[0\]
Alternative 9
Error63.0
Cost64
\[1\]

Error

Derivation

  1. Initial program 44.0

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

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

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

    \[\leadsto \color{blue}{\left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - \frac{c}{b}\right) + \frac{{a}^{3} \cdot {c}^{4}}{{b}^{7}} \cdot -5}\]
  5. Using strategy rm
  6. Applied unpow3_binary64_4852.8

    \[\leadsto \left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - \frac{c}{b}\right) + \frac{\color{blue}{\left(\left(a \cdot a\right) \cdot a\right)} \cdot {c}^{4}}{{b}^{7}} \cdot -5\]
  7. Applied associate-*l*_binary64_3602.8

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

    \[\leadsto \color{blue}{\left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - \frac{c}{b}\right) + -5 \cdot \frac{\left(a \cdot a\right) \cdot \left(a \cdot {c}^{4}\right)}{{b}^{7}}}\]
  9. Final simplification2.8

    \[\leadsto \left(\left(-2 \cdot \frac{\left(a \cdot a\right) \cdot {c}^{3}}{{b}^{5}} - \frac{a \cdot \left(c \cdot c\right)}{{b}^{3}}\right) - \frac{c}{b}\right) + -5 \cdot \frac{\left(a \cdot a\right) \cdot \left(a \cdot {c}^{4}\right)}{{b}^{7}}\]

Reproduce

herbie shell --seed 2021044 
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :precision binary64
  :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.0 a) c)))) (* 2.0 a)))