2009/9/1 Robert Bradshaw <[email protected]> > > On Sep 1, 2009, at 8:58 PM, William Cauchois wrote: > > > It seems to me that the error comes from feeding a function which uses > > i into fast_float (called by the plotting functions to compile the > > function to be plotted into an optimized form). I tried a simpler > > function using i and got the same error: > > > > 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 >
Trying to do plot(...) or plot3d(...) on a function that outputs complex numbers should result in a really useful error message, with instructions about how to plot real/imag/abs/arg parts, maybe? > > sage: plot3d(exp(z), (z, -1-i, 1+i)) > > though I'm not sure I like this notation either. > > - Robert > > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
