It's very simple, when you write a 2nd order equation as a first order system, the technique is to introduce the vector (u, v) = (u, u') and to compute its derivative. You have (u, v)' = (u', v') = (v, u"). Now you replace u" by (1/m)(F(t) - f(u') - s(u)). Now, f(u') = f(v) because u'=v, and finally you get (u, v)' = (v, (1/m)(F(t) - f(v) - s(u))).
When you program this, you replace the vector (u,v) by a list u = [u[0], u[1]], and the right hand side is the list [u[1], (1/m)*(F(t) - f(u[1]) - s(u[0])]. Note that this expression of the second order equation as a first order system comes before any numerical scheme is applied. It's pure theory. The hard part is the Runge Kutta method which you have to implement on the system !
Gribouillis 1,391 Programming Explorer Team Colleague
shadwickman commented: Great idea to create my own str class! +2
Gribouillis 1,391 Programming Explorer Team Colleague
Gribouillis 1,391 Programming Explorer Team Colleague
Gribouillis 1,391 Programming Explorer Team Colleague
Gribouillis 1,391 Programming Explorer Team Colleague
Gribouillis 1,391 Programming Explorer Team Colleague
Gribouillis 1,391 Programming Explorer Team Colleague
Gribouillis 1,391 Programming Explorer Team Colleague
Gribouillis 1,391 Programming Explorer Team Colleague
Prahaai commented: :) +4
Gribouillis 1,391 Programming Explorer Team Colleague
Gribouillis 1,391 Programming Explorer Team Colleague
Gribouillis 1,391 Programming Explorer Team Colleague
vegaseat commented: great suggestion +10