On Monday, December 31, 2012 4:52:37 PM UTC+1, LFS wrote: > > Thanks indeed Juan, it did help immensely! I couldn't get array to work > and your example finally clicked for me. > In the end, I used: w=numpy.array([cos(x0+j*h) for j in range(n+1)], > float) > THANKS. Linda
Hi, you line will work, that's fine, but it has a few flaws. e.g. it creates the whole list as a python array, you don't need to do this. Second, this "x0 + j * h" is evaluated "in the world of Python" which is doomed to be slow. It would be much better, if you use numpy's "arange" if you know the start point and the step width, and "linspace" if you know start and end point and the number of steps method. import numpy as np In [9]: np.arange(1.1, 4.1, step = 0.33) Out[9]: array([ 1.1 , 1.43, 1.76, 2.09, 2.42, 2.75, 3.08, 3.41, 3.74 , 4.07]) In [13]: np.linspace(1.1, 4.1, num = 5) Out[13]: array([ 1.1 , 1.85, 2.6 , 3.35, 4.1 ]) Harald -- 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.