sympy/sympy — pull request #2723 by hargup (2014-01-02 08:25:57+00:00)
Title: Fixed imageset for Interval

`imageset` of sets module uses various `_eval_imageset` implemented in various set classes. But the `_eval_imageset` for Interval doesn't work well unless the given function is monotonic on both positive and negative reals. So, I have fixed it by finding the maxima and minima of the function by solving for the roots of the derivative of the function.

This method is known to fail when:
- The function is not continuous (eg, x + 1/x)
- The roots of the derivative of the function cannot be found out, (eg, polynomials with large degrees)
- The derivative of the function has infinitely many roots. (eg, sin(x) when the Interval is not a subset of [0, 2*pi] )
- The function is not differentiable (eg, Piecewise((x, x>0), (-x, x<0)) for Interval(-2, 2))