Currently having issues with this. At first glance it seems ok, but the amplitude of the oscillation increases with time. This is not right. I am not sure why at the moment.
The set up uses Hooke's Law as the accelerating force on the mass. This acceleration is then used with the kinematics equation to produce the new position of the ball.
Update: figured out the problem. The time interval \(\Delta t\) is too long. If it is reduced from \(\Delta t=0.1 \rightarrow 0.01\) the problem almost goes away completely. This is, of course, the key to how calculus works! The accuracy is only achieved when the \(\Delta t\rightarrow 0\). However, the animation slows to a crawl as it is an online app that runs through the web.
Perhaps using low masses and low spring constants may be a happy medium? The other option is to change from the kinematics approach to that of the single harmonic oscillator and use \(a=-\omega^{2}x\) or \(x=A\cos\left ( \sqrt{\frac{k}{m}} t\right )\) instead. After all, calculus was used to derive the equations from Hooke's Law.
The set up uses Hooke's Law as the accelerating force on the mass. This acceleration is then used with the kinematics equation to produce the new position of the ball.
Update: figured out the problem. The time interval \(\Delta t\) is too long. If it is reduced from \(\Delta t=0.1 \rightarrow 0.01\) the problem almost goes away completely. This is, of course, the key to how calculus works! The accuracy is only achieved when the \(\Delta t\rightarrow 0\). However, the animation slows to a crawl as it is an online app that runs through the web.
Perhaps using low masses and low spring constants may be a happy medium? The other option is to change from the kinematics approach to that of the single harmonic oscillator and use \(a=-\omega^{2}x\) or \(x=A\cos\left ( \sqrt{\frac{k}{m}} t\right )\) instead. After all, calculus was used to derive the equations from Hooke's Law.
Python