Santosh_Manicka:

time_step = 0.002
for i in range(10000):
x = x + x*time_step


Isn’t this equivalent to:
x = x * (1 + timestep) ** 10000

? That would probably solve the memory issue because the computation graph being built would not be so large.