sympy/sympy — pull request #1944 by placasse (2013-03-28 00:09:23+00:00)
Title: Piecewise._eval_subs should not call solve.

There is actually two problems with this call to solve.

Piecewise( (0, Eq(sin(x)+y, 0)), (1, True)).subs(y,0)
was giving Piecewise((0, x == 0), (1, True))
For some equations, solve doesn't return all solutions.
A simple exemple is solve(sin(x)) which gives [0].
It would be very usefull to implement some easy way to know if solve did give all solutions.
I suggest an option like
'findall=True (default is False)'
solve fails (with exception) if it cannot be sure to return all solutions.

The second issue with solve is that it can be slow.
Piecewise( (0, Eq(sqrt(Abs(-5*x*(0.19*x*y + 0.05*y)/(x**2 + 25) + (1 - 25/(x**2 + 25))*(-x**2/10 - 0.01*x*y - 0.05*y))**2 + Abs(-5*x*(-x**2/10 - 0.01*x*y - 0.05*y)/(x**2 + 25) + (0.19*x*y + 0.05*y)*(-x**2/(x**2 + 25) + 1))**2), 0)), (1,True)).subs({x:s, y:0})
seems to never end.
subs should not be slow.

Maybe the call to solve could be made with the option

'minimal=True (default is False)'
a very fast, minimal testing.

unfortunately, the doc of solve contains an other options with the same name (?)

'minimal=True (default is False)'
instructs solve to try to find a particular solution to a linear
system with as many zeros as possible; this is very expensive

and still we must be sure that it returns every solutions.

Maybe we could put all non trivial stuff into Piecewise._eval_simplify
so that it is possible to simplify only if needed.