You can create a numpy array from a list with

numpy.array([cos(x) for x in range(x0, xend, h)])

or if you want to avoid using python lists at al costs, you can do

numpy.cos(arrange(x0, xend, h))

"arange" is the numpy equivalent to range, creating an array instead of a 
list, 
and then you can use numpy "cos" function, which is vectorized.

Hope this helps!

Cheers,
J

On Monday, December 31, 2012 8:10:19 AM UTC, LFS wrote:
>
> P.S. Sorry there is an error in the above post. Of course the counter 
> should be integer.
> This is the best I could do. 
> x0=0.;xend=2.*pi;n=8.;h=(xend-x0)/n;
> y=numpy.ones(n+1)
> y=[y[j]*cos(x0+j*h) for j in [0..n]]
> y
> If anyone knows of an easier or more intuitive way OR how to this array to 
> print *only* decimals - many thanks!
> Linda
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to