id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,merged,author,reviewer,upstream,work_issues,branch,commit,dependencies,stopgaps
13355,doctest proper handling of domain in evalf functions,tkluck,burcin,"Previous description of ticket:
------------------------------------
Plotting currently fails when plotting a symbolic function that evaluates to complex values:
{{{
sage: def evalf_func(self,x,parent=None):
....: return parent(I*x) if parent!=None else I*x
....:
sage: f = function('f', evalf_func=evalf_func)
sage: plot(abs(f(x)),0,5)
verbose 0 (2392: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 199 points.
verbose 0 (2392: plot.py, generate_plot_points) Last error message: 'unable to simplify to float approximation'
}}}
This is because `plot` uses `fast_float`, and `fast_float` cannot deal with the intermediate complex value.
The attached patch first changes these things:
* it adds a method to `class Function` that allows one to see what output range is to be expected for a given input range. By default, it will return a complex field.
* it overrides this method for builtin functions, which return floats for float input
* this is then used by `fast_float` to throw an exception if complex values are to be expected
This exception will cause `plot` to fall back to `fast_callable` instead of `fast_float`. However, `fast_callable` needs patching too:
* it now uses the `_evalf_` method when available instead of just `__call__`. Otherwise, `plot` will try to coerce the result to `float`, which also cannot deal with complex intermediate values.
An alternative to this step would be to fix `float` coercion, which I haven't looked into.",defect,closed,major,sage-6.3,symbolics,fixed,"evalf, fast_callable",kcrisman eviatarbach,,Timo Kluck,Ralf Stephan,N/A,,65675e8384d489cd8c906cfa56be0c356334320f,65675e8384d489cd8c906cfa56be0c356334320f,,