Here is my script def shaded_area_plot(f,g,c,d,a,b): step = 0.01 vf = [(x,f(x)) for x in srange(a, (b+step), step)] vg = [(x,g(x)) for x in srange(b, (a-step), -step)] sha = polygon(vf + vg, rgbcolor='grey') return(plot(f, (c,d)) + plot(g, (c,d), rgbcolor='red') + sha)
Most likely that's not well-written but I hope that's at least clear. for example, then shaded_area_plot(sin(x), lambda x:0, 0, pi, 1, 2) give me the shaded area between the sine curve and the x-axis over [0,pi] I hope there is a better solution to my problem. On Nov 12, 9:22 am, Jason Grout <[EMAIL PROTECTED]> wrote: > 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. > > Actually, could you post your script? There might an easier way to > handle this. > > 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 -~----------~----~----~----~------~----~------~--~---