 #1
TachyonLord
 54
 6
So I tried solving the differential equation for a spring  mass system using Euler's Algorithm in Python. The equation being
d^{2}x/dt^{2}= 4π^{2}x
(The equation was obtained by Dimensional Analysis)
here x and t are both dimensionless equivalents of position and time.
Formula used for Energy Equivalent : 0.5*v*v + 0.5*4.*np.pi*np.pi*x*x (by dimensional analysis)
So in the loop, where we successively keep adding to the position and velocity I had 2 cases :
As far as I understand, the order is just an indication of what changes first : velocity/displacement/acceleration. I just don't get it. Help ?
d^{2}x/dt^{2}= 4π^{2}x
(The equation was obtained by Dimensional Analysis)
here x and t are both dimensionless equivalents of position and time.
Formula used for Energy Equivalent : 0.5*v*v + 0.5*4.*np.pi*np.pi*x*x (by dimensional analysis)
So in the loop, where we successively keep adding to the position and velocity I had 2 cases :

x = x + v*h;
v = v + a*h
When this is executed, I get this :
Which is kinda fine, considering the fact that my end time is 10.0 and I have kept n = 10,000 (h = end_time/n)
 But when the order is changed, i.e.
v = v + a*h
x = x + v*h
When this is executed, I get this :
As we clearly see, the energy is clearly Oscillating here whereas in the first case, it was increasing (within the limits of Euler's Algorithm, Euler's is a poor algorithm but its fine for small stuff like this)
As far as I understand, the order is just an indication of what changes first : velocity/displacement/acceleration. I just don't get it. Help ?
Attachments
Last edited: