Lab 12: Problems on ODEs


In this lab, use the Euler, RK-1 and RK-4 code you wrote in Lab 10 to solve the problems given below. You also need to use the code written in Lab 10 to solve the given boundary value problems.


Problems

  1. Solve the following problems using Euler, RK-1 and RK-4 Methods. Try dt = 0.2 (the default value) and with dt = 0.02, 0.05 and dt = 1e-5 . Compare your results with the three methods and analyse which method seems to work better.
    1. $$ \frac{dx}{dt} = x^2, \,\,\,\, x(2) = -2 \,\,\,\mbox{Find} \,x\,\,\mbox{at} \,\,\,\,t = 4 $$
    2. $$ \frac{dy}{dx} = 5x, \,\,\,\, x(0) = 3 \,\,\,\mbox{Find} \,y\,\,\mbox{at} \,\,\,\,x = 3 $$
    3. $$ \frac{dx}{dt} = 2t - x, \,\,\,\, x(0) = 0 \,\,\,\mbox{Find} \,x\,\,\mbox{at} \,\,\,\,t = 4 $$
    If the correct answers are $-0.4, 25.5$ and $6.04$ respectively, how close did you get to the true values?
  2. Solve the following boundary value problem in the range $0$ to $2$ in steps of $0.2$. $$ \frac{d^2y}{dx^2} = -x^2 $$ $y(0) = 0, y(2) = -4$.
In [ ]: