stepthom/math-fun — pull request #51 by jgus (2013-12-04 21:13:08+00:00)
Title: Issue 50

Fixes #50

My Newton's method implementation was breaking down with rounding errors on the failing cases.

The fix was two-fold:
- Reduce the rounding error by taking advantage of a special property the failing cases all share: They were all divisible by x^n (n!=0), meaning that zero was a solution, and other solutions could be found by solving the simpler f(x)/(x^n)
- If we hit rounding error anyway, we can fall back to sub-dividing the search area and trying again.

While working on the above, I was blocked by an issue where `differentiate()` could return functions with a 0x^0 term, which was apparently intentional behavior to make pretty-printing work. To make function analysis easier, I changed the behavior so a function's terms are always represented in minimal form, and fixed up the code that was assuming 0x^0 terms.