On Thu, Jul 26, 2012 at 7:50 AM, Anthony Wickstead
<[email protected]> wrote:
> Earlier post sent prematurely by acciident, sorry!
>
>
> On Thursday, July 26, 2012 3:47:34 PM UTC+1, Anthony Wickstead wrote:
>>
>> I don't think I am doing anything stupid, but I am fairly new to Sage.
>>
>> I am using Sage 5.0 (Ubuntu 12.04 64 bit, running under Virtualbox) but
>> the same behaviour occurs with Sage 4.7 running under Debian (not sure of
>> version). I am trying to plot the graph of h(a,x) fo a range of values of a.
>>
>> def h(a,x):
>>     if x<=a:
>>          return 2-sqrt(1-(1-x/a)^4)
>>      else:
>>          return sqrt(1-((x-a)/(2-a))^6)
>> plot(sqrt(x),(x,0,1))                            #Works fine
>> [h(.5,x) for x in [0..2,step=.1]]            #Returns plausible looking
>> list
>> plot(h(.5,x),(x,0,2))                            #shows a horizontal
>> straight line graph (approximately zero)
>
> plot(sqrt(x),(x,0,1)                                #another straight line,
> approximately sqrt(2)

You're assigning x to several values in your list comprehension.

sage: type(x)
<type 'sage.symbolic.expression.Expression'>
sage: plot(sqrt(x),(x,0,1))                            #Works fine
sage: [sqrt(x) for x in [0..2,step=.1]]
[0.000000000000000 ... 1.41421356237310]
sage: x
2.00000000000000
sage: type(x)
<type 'sage.rings.real_mpfr.RealNumber'>
sage: sqrt(x)
1.41421356237310
sage: plot(sqrt(x),(x,0,1)  # plotting sqrt(2)
sage: x = var('x')
sage: plot(sqrt(x),(x,0,1))                            #Works fine

- Robert

-- 
-- 
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org



Reply via email to