@slelievre I was just pointing out what I think is a typo.
@slelievre You are right, the clause after the statement clarifies the 
situation. "When a symbolic equation is evaluated, as in the definition of h, 
if it is not obviously true, then it returns False. Thus h(x) evaluates to 
x-2, and this is the function that gets plotted" But I still feel the whole 
thing can be worded slightly better and more concisely. The if clause is 
evaluated anyway when one calls h(x) so there is no point in saying "x<2 is 
evaluated".
On Thursday, 2 October 2014 13:42:25 UTC-4, slelievre wrote:
>
>
>
> 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