Wilfried_Huss wrote: > > > On 19 Mrz., 18:49, Jason Grout <jason-s...@creativetrax.com> wrote: >> Jason Grout wrote: >>> Wilfried_Huss wrote: >>>> On 19 Mrz., 16:47, Jason Grout <jason-s...@creativetrax.com> wrote: >>>>> ma...@mendelu.cz wrote: >>>>>> Hello, this command produces one half of a cirle, not 1/4 as excepted. >>>>>> I think that this is a bug in sage 3.4 >>>>>> Robert >>>>>> region_plot([y>0,x>0,x^2+y^2<3], (-3, 3), (-3, >>>>>> 3),plot_points=100,incol='gray').show(aspect_ratio=1) >>>>> I get a quarter-circle on my sage 3.4 and on sagenb.org. Can you try on >>>>> sagenb.org? >>>> This works: >>>> sage: var('x,y') >>>> sage: region_plot([y>0,x>0,x^2+y^2<3], (x, -3, 3), (y, -3,3)) >>>> But if one leaves out the variables, one gets an half circle: >>>> sage: region_plot([y>0,x>0,x^2+y^2<3], (-3, 3), (-3,3)) >>>> I've written a patch which fixes this: >>>> http://trac.sagemath.org/sage_trac/ticket/5567 >>> Ah, yes, good catch. For those that want to know, Sage was interpreting >>> the first two constraints as functions of one variable, so when it >>> plugged in two numbers, Sage behaved as though you had typed x>0, x>0. >>> When I did my example, I explicitly put in the variable names (it's a >>> good habit to be explicit in plotting), so I got the right plot. >>> There should be a standard function that takes a tuple of functions and >>> returns a list of variables for all the functions. This is used all >>> over the plotting code, the fast_callable code, now this code, etc. >>> Basically, there should be a function that, treating a tuple of >>> functions as a vector-valued function, returns the variables used in the >>> vector-valued function. >>> Also, I wonder why fast_float is not used? It could drastically speed >>> up plots. You could just replace the lines like: >>> s = symbolic_expression(f.rhs() - f.lhs()).function(*variables) >>> with >>> s = fast_float(f.rhs() - f.lhs(), *vars) >>> and you'd probably see at least an order of magnitude speedup. (make >>> sure to do "from sage.ext.fast_eval import fast_float" first). >> Actually, I believe that the call to setup_eval_on_grid automatically >> does the call to fast_float, so it's probably already happening and we >> don't have to worry about anything. > > Yes > >> In fact, I think the root of the problem is in >> plot/plot3d/parametric_plot3d.py in the adapt_to_callable function (this >> is called by setup_for_eval_on_grid, which is in turn called by >> region_plot). Observe (and please pardon my debugging in public :) >> >> sage: from sage.plot.plot3d.parametric_plot3d import adapt_to_callable >> sage: var('x,y') >> (x, y) >> sage: funcs = [x,y] >> sage: adapt_to_callable(funcs,2) >> >> ((<sage.ext.interpreters.wrapper_rdf.Wrapper_rdf object at 0xa9b1d9c>, >> <sage.ext.interpreters.wrapper_rdf.Wrapper_rdf object at 0xa9d916c>), >> (y, x)) >> >> First of all, why in the world are the arguments y, then x? I thought >> the convention was alphabetical ordering if an ordering wasn't specified. >> >> Well, the problem is in this line of adapt_to_callable: >> >> tuple(sorted(set(sum( [z.variables() for z in f], ()) ))) >> >> Note: >> >> sage: sorted(set(sum([z.variables() for z in funcs],()))) >> [y, x] >> >> and even >> >> sage: sorted(list(set(sum([z.variables() for z in funcs],())))) >> [y, x] >> >> For some reason, sorting the list [y,x] doesn't make it [x,y]: >> >> sage: sorted([y,x]) >> [y, x] > > Well, that is not surprising since x < y is a symbolic equation. > We need to sort the variables by name. > > sage: sorted([y,x], cmp = lambda a,b: cmp(repr(a), repr(b)) ) > [x, y] > > But, fixing the variable order in adapt_to_callable does not > solve the problem in region_plot, because setup_for_eval_on_grid > calls adapt_to_callable in a loop for one function at a time. >
Ah, I see that; right.. So maybe the problem is in setup_for_eval_on_grid after all. Carl Witty and I have been discussing this on IRC too. Soon, we hope that adapt_to_callable (and part of setup_for_eval_on_grid) is made obsolete by fast_callable. Until that makes it into Sage, though, this probably ought to be fixed. Do you have time to fix setup_for_eval_on_grid? It would probably be a similar fix to the one you made in region_plot. Jason --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---