next up previous
Next: About this document ...

ESC 251 HW 35 Due: Dec. 6

(15 pts) Recall that the standard 4th order Runge-Kutta method for solving a first order initial value problem is given by

     y(0) = yO

     for i = 0,1,....
        k1 = f(t(i),y(i))
        k2 = f(t(i)+h/2,y(i)+h*k1/2) 
        k3 = f(t(i)+h/2,y(i)+h*k2/2) 
        k4 = f(t(i)+h,y(i)+h*k3) 
        y(i+1) = y(i) + h*(k1 + 2*k2 + 2*k3 + k4)/6



Write a main program and accompanying subroutines/functions that will implement this method for solving the first order initial value problem

\begin{displaymath}y'(t) = f(t,y(t)),\quad y(0) = y_0,\quad\mbox{on}\quad t \in [0,b].\end{displaymath}

Use your program to solve the following problems. In each case, determine the value of n necessary for the 2-norm of the error vector to be less than 10-6. Use separation of variables or the Wolfram Alpha site to determine the exact solutions.
a)

\begin{displaymath}y' = -ty,\quad y(0) = 2,\quad\mbox{on}\quad t \in [0,4].\end{displaymath}

How does the value of n for this problem compare to the one for Euler's method?
b)

\begin{displaymath}y' = -y\sin(t),\quad y(0) = 3,\quad\mbox{on}\quad t \in [0,4].\end{displaymath}

c)

\begin{displaymath}y' = -30y + \cos(t),\quad y(0) = 3,\quad\mbox{on}\quad t \in [0,4].\end{displaymath}

What is different about the value of n you obtain for this problem? Why do you think this is happening?





2017-12-04