algorithm-archivists / algorithm-archive

A collaborative book on algorithms
https://www.algorithm-archive.org
MIT License
2.38k stars 356 forks source link

Error Term in Verlet Integration Page #994

Closed harshaxnim closed 2 years ago

harshaxnim commented 2 years ago

Hi team,

This is regarding the Verlet Integration page that's here: https://www.algorithm-archive.org/contents/verlet_integration/verlet_integration.html

Similar to how Equation 4 is sum of Eq. 2 and 3, we can see that Eq. 5 is a difference of 2 and 3. When we do that, the error term turns out to be O(del. t^3) and not O(del. t^2) as stated in the page. Did I get something wrong? Or should that page be corrected? Happy to provide more information if this post is not clear.

Best, Harsha

Amaras commented 2 years ago

Right, I was confused as well when reading your issue, and I would have agreed with you. However, I did the working out, and this is why it's an O(dt^2).

As you noticed, Equation 5 is the difference of equations 2 and 3. As such, the jerk term does not cancel out, because of their different signs. Thus (using dt instead of delta t): x(t + dt) - x(t-dt) = 2 v(t) dt + 1/3 b(t) dt^3 + O(dt^4). Solving for v(t), we get: v(t) = [x(t + dt) - x(t - dt)] / (2 dt) - 1/6 b(t) dt^2 + O(dt^3). However, since we don't use the jerk in the computation, it is lumped in a O(dt^3) at the start. As such, we have a O(dt^3) in the difference step, and thus only a O(dt^2) term in the velocity.

Hope this helped!

leios commented 2 years ago

I think this should be explicitly mentioned. I'll do that today.

harshaxnim commented 2 years ago

@Amaras Ah, yes. It's a mistake on my part! That makes perfect sense, thank you!

harshaxnim commented 2 years ago

@leios that sounds great. Maybe I'll leave this open for you to track and close when you're done?