fsolve: check if evalf() return value is actually a number.
Fixes the segfault triggered by
fsolve((1/(sqrt(2*Pi)))*integral(t,0,x,exp(-1/2*t^2))==0.5,x,0,100)
In general, ex_to is unsafe, and should be used only after proper checks.
evalf() may return non-numeric expression for various reasons (bad
convergence, floating point over- or underflow, out of memory, etc).
So let's add missing checks.
Thanks to Ernst Moritz Hahn for a bug report.
(cherry picked from commit
9993a7aac97abf383624fc5dae4beecb29531fbd)