I'm trying to solve differential equations using the Vertel algorithm, but I'm not able to rid myself of this error. Any suggestions?
def Vertel(dt, x0, v0, t, tstop, pravastrana, M=1):
i = 0
x = x0
v = v0
k = 1 # Spring constant
m = 1
while t <= tstop:
a = -(k/m)* x[i]
if i == 0:
v_next = v[i] + a* dt
x_next = x[i] + v_next* dt
else:
x_next = 2* x[i] - x[i-1] + a* dt** dt
x.append(x_next)
t.append(t[i] + dt)
i = i + 1
t = t + dt
return(x, t)
print(*Vertel(0.1 ,1 ,1 , 0, 10, pravastrana_1, ))
On the line, where I define a
I get the error message:
> 'int' object is not subscriptable
Any help is appreciated, thank you