Closed
Description
All of the following plots fail
x, y = SR.var('x y')
contour_plot(abs(x+i*y), (x,-1,1), (y,-1,1))
density_plot(abs(x+i*y), (x,-1,1), (y,-1,1))
plot3d(abs(x+i*y), (x,-1,1),(y,-1,1))
streamline_plot(abs(x+i*y), (x,-1,1),(y,-1,1))
with
TypeError: unable to coerce to a real number
The culprit is the call to setup_for_eval_on_grid
(from sage/plot/misc.py
) that tries to compile the symbolic expression with fast_float
. But since the expression involves an intermediate complex number the compilation fails. This can be tested with any of the two
fast_float(abs(x + i*y), x, y)
fast_callable(abs(x + i*y), vars=[x,y])
The function compilation succeeds if we ask for a complex function instead
fast_callable(abs(x + i*y), vars=[x,y], domain=complex)
See also this question on ask.sagemath.org.
CC: @orlitzky @egourgoulhon @JungMath
Component: graphics
Author: Michael Orlitzky
Branch: 6531609
Reviewer: Dima Pasechnik
Issue created by migration from https://trac.sagemath.org/ticket/8450