You have defined the "e1" etc. as series, so it's e1[0] when you want the last element of the array. e2[0] = w1*e1[0] + w2*e2[1];, etc.