derivatives of Max() and Min() using Heaviside()

modified:   sympy/functions/elementary/miscellaneous.py
modified:   sympy/functions/elementary/tests/test_miscellaneous.py

* added fdiff for Min() and Max()
* added diff Min() and Max()
* implement simple tests of Max().diff and Min().diff
* use ArgumentIndexError for assertions in fdiff
Include SympifyError in __init__.py
Bidirectional facts between (non)negative, (non)positive, and (non)zero.

We already have, in sympy/core/assumptions.py:

real        == negative | zero | real
nonpositive == real & !positive
nonnegative == real & !negative
nonzero     == !zero

(Note that either nonnegative or nonpositive imply real.)

From these we can derive the following bidirectional facts between
negative, positive, zero and nonnegative, nonpositive, nonzero:

negative == nonpositive & nonzero
positive == nonnegative & nonzero
zero     == nonnegative & nonpositive

With the addition of the above bidirectional facts for negative, positive
and zero to sympy/core/assumptions.py we now correctly obtain the truth
value when setting some assumptions to False, for example:

>>> Symbol("x", positive=False, real=True).is_nonpositive
True
>>> Symbol("x", nonpositive=False, real=True).is_positive
True
Don't return None from inequalities.

Fixes issue 3564.
Implement is_bounded, is_finite, is_zero for Float().

Float always returns a Float, with the exception of Float('fnan')
which returns S.NaN. This is in contrast to e.g. Rational, which
returns instances of S.Zero, S.Infinity, and so on, given the args.
Thus we can have a zero float or a infinite float. This should be
reflected when we check the assumptions on these objects.

Fixes issue 2486.
More tests for inequalities.
Fix roots_rational

The algorithm was completely wrong.  Apparently, this is not actually used
anywhere.
Use primitive instead of clear_denoms in roots_rational
Add option to return only integer roots from roots_rational
Delete roots_rational

This function is a very inefficient way to find the rational roots of a
polynomial.  For example, if you have Poly(Mul(*[(x - i) for i in
range(100)])) (i.e., x*(x - 1)*(x - 2)* ... *(x - 99)), then there are
divisor_count(factorial(99)) == 35148882404966400 possible roots to check.  On
the other hand, solve() (which uses Poly.real_roots()) can find all 100 roots
in about a second.

The good news is that this function was not actually used anywhere.
Make RootOf.n() return the correct root

The way RootOf.n() works is the following: RootOf contains the interval (a, b)
where the (only) root is (as symbolically represented by RootOf). We then take
the center of the interval as an initial estimate for findroot() from mpmath.
However, sometimes findroot() finds a root that is not from the interval (a,
b), because the initial estimate was too far, and findroot() found a different
root (from some other interval) instead.

The solution is to check, that the findroot()'s result is from the interval
(a, b) and if it is not, just keep refining the interval. Eventually the
initial estimate will be close enough, so that findroot() converges to the
correct root.

Test (that previously failed and now works) added.
RootOf.eval_rational() implemented

Test added.
Add Gauss-Legendre and Gauss-Laguerre quadratures

Added gauss_legendre() and gauss_laguerre() functions and tests for calculating
the quadrature points and weights. The functions work for any order and any
precision.
Add Gaussian integrals into docs
Fix docstring formatting, added "Returns" section

Now it should follow SymPy's conventions. Also it should make clear that the
function returns numerical values (not symbolic).
Simplify condition to "a < root < b"
Use `` instead of '
Fix bisect's docstring
Fix RootOf.n() for complex roots

The problem was the same as for the real roots that was fixed in
5c58406b3be8fc6d75d0e258a67b6847d5274a4f. This commit provides the same fix for
complex roots by refining the complex interval.
Add a test for RootOf() for complex roots

These tests are correct, but currently fail because they have revealed a few
other bugs, which will be fixed in subsequent commits.  After the other bugs
are fixed, these tests will start passing on their own.