Ask Your Question

Revision history [back]

The question is not clear to me, why not simply do:

sage: Y = [1,2,4,3,7,2,1]
sage: h = 0.1
sage: [(Y[k+1]-Y[k-1])/h for k in  range(1,len(Y)-1)]
[30.0000000000000,
 10.0000000000000,
 30.0000000000000,
 -10.0000000000000,
 -60.0000000000000]