Ordinary differential Equations

  1. Solve using Euler’s explicit method the following ODE from x = 0 to x = 2:
    ��
    �� = −1.2� + 7�,-../
    with y(0) = 3
    a. Use a step size h = 0.5 (solve by hand)
    b. Write a script to solve this again with h = 0.05 and h = 0.005. How do you expect the
    truncation errors to change?
    c. The analytical solution is available in this case and is given by:
    �0123 � = 70
    9 �,-../ − 43
    9 �,8.9/
    Calculate the truncation error at x = 0.5, x = 1, x = 1.5, and x = 2 for each of the step sizes.
    Plot, compare, and discuss.
  2. Solve using the midpoint method (modified Euler) from x = 0 to x = 2:
    ��
    �� = � −2� +
    1
    � ��� � ≠ 0
    ��
    �� = 1 ��� � = 0
    a. Use a step size h = 0.5 (solve by hand)
    b. Write a script to solve this again using a step size h = 0.2
    c. The analytical solution is also available in this case and is given by:
    �0123 � = ��,/?
    Calculate the truncation errors at each x with the step size h = 0.2. Plot and discuss.
  3. Consider the following IVP over x = 0 to 2, and y(0) = 3:
    ��
    �� = 4��,8 − ��
    a. Solve by hand using the classic 4th order Runge-Kutta method with an h = 0.5 (it’s tedious,
    but I want you to do this just once…it’s a very good exercise for really understanding the
    method)
    b. Write a script to solve this using 4th order Runge-Kutta method with a step size h = 0.05
    c. Use Matlab ode45 to solve this. Compare and discuss.
    d. The analytical solution is also available in this case and is given by:
    �0123 � = 4 + 5�,/?
    Calculate the truncation errors at each x with the step size h = 0.5. Compare with the
    truncation errors of the solution using ode45