Dave Angel wrote:

> from math import cos
> 
> JME = 0.4
> L0A = [2.3, 4.65]
> L0B = [1.8, 2.2]
> L0C = [12.1, 4]
> limit = len(L0A)
> 
> L0 = sum(L0A[i]*cos(L0B[i]+L0C[i]*JME) for i in range(limit))

OP, if you are planning to do this "maths on lists" a lot you should have a 
look at numpy. With numpy Dave's snippet can be written as

from numpy import array, cos, sum

j = 0.4
a = array([2.3, 4.65])
b = array([1.8, 2.2])
c = array([12.1, 4])

print sum(a*cos(b+c*j))

Peter

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to