Skip to main content
7 events
when toggle format what by license comment
Aug 9, 2017 at 11:17 history edited Floris CC BY-SA 3.0
added 265 characters in body
Aug 9, 2017 at 11:12 comment added Floris The correct size of the time step depends on the algorithm. With a simple algorithm like yours, your step needs to be small enough that curvature in the function is small over the step size. When you use "higher order" algorithms (for example 4th order Runge-Kutta, look it up) then you can take larger steps because you worry about the size step where the fourth derivative changes significantly. Incidentally the period is given by $2\pi\sqrt{\frac{m}{k}}$ - when m=k=1 (as in my example) period is about 6.2 seconds and 100 steps per period is plenty small.
Aug 9, 2017 at 4:35 comment added Stephen Jacob You are right @Floris, I should have paid more attention to the clarity of the algorithm. I apologize for that. I thought it had more to do with my understanding of Physics, than the value of time-step. I would still like to pose the same question that I posed to Kyle, which is if their is a way to determine an appropriate time-step? And additionally, you mentioned dt being much smaller than the period, how would i go about determining that?
Aug 9, 2017 at 2:54 comment added Floris Note that the original code had t, not dt. That changes everything.
Aug 9, 2017 at 1:39 comment added Stephen Jacob I used the same algorithm as I used earlier and plotted it for shorter timesteps from 1 to 0.005 (from @KyleKano's answer) and it appears to behave as expected. So may I conclude that it depends on the selection of the timestep? (Please see updated question)
Aug 9, 2017 at 1:11 vote accept Stephen Jacob
Aug 8, 2017 at 20:26 history answered Floris CC BY-SA 3.0