Make a function

``def rhs(u, t):``

for returning the right-hand side of the first-order differential equation system
from Exercise 11.36. As usual, the u argument is an array or list with the two
solution components u[0] and u[1] at some time t. Inside rhs, assume that
and external(t) for evaluating f(u˙ ), s(u), and F(t), respectively.

The equation is:
mv' + f(v ) + s(u) = F(t), t > 0, u(0) = U0, v (0) = V0
where v=u'
For the record the equation was:
mu'' + f(u' ) + s(u) = F(t), t > 0, u(0) = U0, u' (0) = V0 .

Test the rhs function in combination with the functions f(u' ) = 0, F(t) = 0, s(u) = u, and the choice m = 1. The differential equation then reads
u'' + u = 0. With initial conditions u(0) = 1 and u'(0) = 0, one can show
that the solution is given by u(t) = cos(t). Apply two numerical methods:
the 4th-order RungeKutta method and the Forward Euler method from the
ODESolver module developed in Chapter 11.4, using a time step dt = pi /20.

The soltion is:

``````def rhs(u, t):
return [u[1],
(1./m)*(external(t) - friction(u[1]) - spring(u[0]))]``````

can someone help me understand why?