try return factored expr more often from simplify
tree traversals take functional inputs

These functions define how to manipulate terms

new(op, *args) -> make a new term
children(term) -> list of args
op(term) -> type of term (e.g. Add, Mul)
leaf(term) -> boolean if the term is a leaf
Add Sphinx coverage testing to the coverage_doctest.py tool

This checks if the function is imported into Sphinx. This works by checking
the source from the Sphinx viewcode extension.

This fixes issue 2896.

I still need to add verbose output, and I also need to add some error checking
if the Sphinx docs haven't been built.
Change --no-color to --no-colors

--no-color will still work because OptionParser parses substrings.
Use brown instead of white, in case people have black on white terminals
Add a summary for sphinx

Our current scores are

TOTAL DOCTEST SCORE for sympy: 34% (1984 of 5682)
TOTAL SPHINX SCORE for sympy: 22% (1293 of 5682)

which are not very good.
Tweak colors for coverage_doctest

Sphinx is now printed in gray, so it stands out less.  If the coverage is less
than 50%, the percent is printed in a brighter red.
Fix computation of how many functions are imported into Sphinx

It was computing the inverse.  The actual total is

TOTAL SPHINX SCORE for sympy: 84% (4806 of 5682)

which is not too bad.
Fix coverage_doctest calculations again

The Sphinx percentages should hopefully now be correct.  Assuming they are,
then the actual Sphinx score is 39% (2241 of 5682).

Also start to factor out the colors, so they can more easily be added in
verbose mode.
COLORS!

For coverage_doctest.py -v. If the colors are disabled, print
underlines. Otherwise, they are just too much clutter, because the colors
already delineate the headings just fine.
Use argparse in coverage_doctest

This requires Python 2.7 or higher (or 2.6 if you install it yourself), but
that's OK because this is just a development tool.

Also warn if the Sphinx docs aren't built.
Skip mpmath in coverage_doctest
Add sys.exit to coverage_doctest based on whether full coverage was achieved
3691: Symbolic determinant implementation
3691: Symbolic determinant implementation
Some modifications
Some more modifications
Implement reductions for the product of a complex conjugate pairs (issue 2296):

    This is done for Mul.as_real_imag,  e.g. im(x*x.conjugate()) -> 0
mod tracks precision of Float

Float already implements the tracking so the calculation is
passed off to Float rather than being handled in Rational.

Checking a ratio seems to resolve Float(n*f)%Float(f) better than
the mod calculation (i.e. the ratio shows that the result is the
Float equivalent of n, hence no remainder).
1606: as_sum error if integral is not definite