On Sun, Apr 6, 2008 at 1:35 AM, Eugene <[EMAIL PROTECTED]> wrote: > > Hi all! > > Help please, I can not understand what is wrong with this: > > f(x)=x; > def g(x): > if (x>=0): > return f(x) > else: > return f(-x); > > show(plot(g(x),(x,-1,1))) #form1 > show(plot(g,-1,1)) #form2 > > same thing: > https://www.sagenb.org/home/pub/1770/ > > the two graphics must be same, because it is the same functions. > so, why form 2 gives wrong result?
In form 1 g(x) evaluates the function g *exactly* once. It decides the x>=0 is false (since it isn't *always* true), so it returns f(-x) since and for all. That is, g(x) evaluates to something completely different than g. Does that make sense? > > P.S. I do not want to plot abs(x) function, that is only for example. > > > > -- 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 -~----------~----~----~----~------~----~------~--~---
