sage: plot3d(x + y + i, (x, 0, 1), (y, 0, 1))
Traceback (click to the left for traceback)
...
TypeError: float() argument must be a string or a number
sage: from sage.ext.fast_eval import fast_float
sage: fast_float(x + i, 'x')
Traceback (click to the left for traceback)
...
TypeError: float() argument must be a string or a number
It would make sense for the low-level representation used by
fast_float not to include a concept of imaginary numbers. Have you had
success plotting any other functions that use imaginary numbers? There
should be a mechanism to fall back to using the unmodified function in
the event that fast_float fails to convert the function.
The code leaves a lot to be desired. For example, now that we have
fast_callable, with CDF support, we should be using that. Actually,
we're using the helper function setup_for_eval_on_grid (to normalize
the boundaries) and then ignoring the returned function, so this
check is completely useless.
As for being a function of one or two variables, it's unclear what
the best approach is to take here. Clearly we want to allow plotting
complex functions of a complex variable, but the alternative is
useful too. For functions, the number (and names) of the arguments
they take is explicit, but for expressions like sin(z) or x+y+i it's
not as obvious. Does the x in plot3d(x+1, ...) stand for the real
part of the complex argument, or the entire thing? Or perhaps the
bounds should be complex numbers defining the rectangle, like
sage: plot3d(exp(z), (z, -1-i, 1+i))
though I'm not sure I like this notation either.
- Robert
sage: plot3d(exp(z), (z, -1-i, 1+i))
though I'm not sure I like this notation either.
- Robert
sage: plot3d(lambda x, y: abs(e^(pi*i*x)+e^(pi*i*y)), (0,1), (0,1))
Should work. (Although I'm getting the error "plot variables should be
distinct", which I think is a bug; workaround is to change one of the
lower bounds to 0.1 instead of 0.)