Beginning to Work on the Runge-Kutta Method I'm starting to play around with techniques in the introductory
numerical methods literature, and I am starting to use the
Runge-Kutta method for approximating solutiosn for systems
of first-order diff eq.'s, and I'm getting a little tripped
up on the method. Take the system
$$u_1' = -4u_1 - 2u_2 + \cos(t) + 4\sin(t), u_1(0) = 0$$
$$u_2' = 3u_1 + u_2 - 3\sin(t), u_2(0) = -1.$$
I can't quite figure out how to develop the endpoints for
this algorithm; Could someone help me with figuring out how
to set this up for algorithmic processing?

We are given the system;
$$u_1' = -4u_1 - 2u_2 + \cos t + 4\sin t, u_1(0) = 0 \\ u_2' = 3u_1 + u_2 - 3\sin t, u_2(0) = -1.$$
Here is the setup for the system of differential equations using a $4^{th}-$ Order Runge-Kutta.
f(t, u_1, u_2) = -4 u_1 - 2 u_2 + cos t + 4 sin t
g(t, u_1, u_2) = 3 u_1 + u_2 - 3 sin t
t_0 = 0
u_1(0) = 0
u_2(0) = -1
h = 0.1
k_1 = h f(t(n), u_1(n), u_2(n))
l_1 = h g(t(n), u_1(n), u_2(n))
k_2 = h f(t(n) + h/2, u_1(n) + 1/2 k_1, u_2(n) + 1/2 l_1)
l_2 = h g(t(n) + h/2, u_1(n) + 1/2 k_1, u_2(n) + 1/2 l_1)
k_3 = h f(t(n) + h/2, u_1(n) + 1/2 k_2, u_2(n) + 1/2 l_2)
l_3 = h g(t(n) + h/2, u_1(n) + 1/2 k_2, u_2(n) + 1/2 l_2)
k_4 = h f(t(n) + h, u_1(n) + k_3, u_2(n) + l_3)
l_4 = h g(t(n) + h, u_1(n) + k_3, u_2(n) + l_3)
u_1(n + 1) = u_1(n) + 1/6 (k_1 + 2 k_2 + 2 k_3 + k_4)
u_2(n + 1) = u_2(n) + 1/6 (l_1 + 2 l_2 + 2 l_3 + l_4)

Here are the first few calculations:
$$(t, u_1(t), u_2(t)) = (0., 0, -1), (0.1, 0.272041, -1.07705), (0.2, 0.495482, -1.11554)$$
If we continue iterating, we get the graphs:

For this system, we can calculate the exact result as:
$$u_1(t) = e^{-2 t} \left(2 e^t+e^{2 t} \sin t-2\right) \\ u_2(t) = -e^{-2 t} \left(3 e^t-2\right)$$
A plot of this exact solution shows:

Of course you can do an error analysis, but those look pretty good visually. 
