pong wrote:
> I defined a function which show the shaded area between the graphs of
> two functions over an interval (maybe such function already exist?).
> For example,
> 
> plot_shaded_area(sin(x), cos(x), 1,2)
> 
> show the shaded area between sine and cosine over [1,2]. Well, my
> script doesn't work if I change cos(x) to 0. The reason is 0 is an
> integer but not a function. I get around that by
> 
> plot_shaded_area(sin(x), lambda x:0, 1,2)
> 
> but I would like a more "natural" syntax as I don't want to scare my
> students off from using SAGE.
> Any help? Thanks.


This came up a while ago for plots as well.  One fix is to wrap the 
argument in "SR", creating a SymbolicRing 0 instead of an Integer 0.

plot_shaded_area(sin(x), SR(0))

or you can do the wrapping in the actual function.

This will mean that you can't pass in lambda functions or python 
functions, though.  You could try wrapping it in SR() and catch the 
error, though.

try:
     f = SR(f)
except:
     pass


Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to