Le mercredi 1 octobre 2014 22:06:50 UTC+2, NahsiN a écrit :
>
> Hello, I don't know where to post this so redirect me as needed. I believe 
> I have found a typo in the sage tutorial. Under Sage Tutorial v6.3 >> A 
> Guided Tour >> Some Common Issues with Functions we have the lines
> def h(x):
>       if x<2:
>          return 0  
>       else:
>           return x-2
>
> The issue: plot(h(x), 0, 4) plots the line y=x−2, not the multi-line 
> function defined by h. The reason? In the command plot(h(x),0, 4), first 
> h(x) is evaluated: this means plugging x into the function h, *which 
> means that **x<2** is evaluated*.                  
>
> I think the else clause is evaluated and not the if x<2 clause. 
> Thanks,
> Nishan
>

You can work around this as follows:

    plot(lambda x: h(x), 0, 4)
 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to