I have two functions, f(t,x) and g(t,u), where

I am trying to discretize the integral of this system in order to track x and u. I have succeeded using Euler integration, which is quite simple, since x(t) and u(t) are both known at t:

However, I am now trying to implement mid-point integration to get more accurate results. (Eventually Runge-Kutta but I am stuck here for now.)