Assignment #6

Part A (You do not need to turn in anything for this part):

  1. Download and run the Matlab codes in
    http://www.cse.ucsc.edu/~hongwang/Codes/ODE_RK
    First run "calc_RK4.m" to generate and save the data. Then run "plot_RK4.m" to read in the data and plot the curve. Run other Runge Kutta methods in the same way.
    Try to see how the codes work and learn how to implement the Runge Kutta type methods. Also try to learn how to put two figures on one page.
    Notice that "calc_small_h.m" outputs one solution point for every 100 time steps. This is useful when we need to use small time step but do not want to output all solution points.

  2. Download and run the Matlab codes in
    http://www.cse.ucsc.edu/~hongwang/Codes/ODE_sys_RK
    First run "calc_sRK4.m" to generate and save the data. Then run "plot_sRK4.m" to read in the data and plot the curve. Run other Runge Kutta methods in the same way.
    Try to see how the codes work and learn how to implement the Runge Kutta type methods for ODE systems.

  3. Computer demonstration of the advantages of implicit methods in solving stiff ODEs
    http://www.cse.ucsc.edu/~hongwang/Codes/Stiff_ODE

  4. Computer demonstration of the Gibbs phenomenon
    http://www.cse.ucsc.edu/~hongwang/Codes/Interpolation


Part B (You need to turn in results with descriptions):

  1. Use RK4 (the classic fourth order Runge-Kutta method) with time step h=0.05 to solve
    y'' + sin(y) = 0,
    This is the ODE describing the motion of a frictionless pendulum. Here y is the displacement and y' is the velocity. This is a second order nonlinear ODE. First we need to convert it into a first oder ODE system. In class, we discussed how to convert a second order ODE to a first order ODE system.
    Plot y(t)/y(0) against t for t in [0,25] for the three sets of initial conditions listed below.
    y(0)=0.1, y'(0)=0.0
    y(0)=1.0, y'(0)=0.0
    y(0)=1.5, y'(0)=0.0
    Plot three curves in one figures. Here we plot y(t)/y(0) so that all three curves have the same amplitude.
    Compare three curves. Which one has the highest frequency? Which one has the lowest frequency?
    It will help you do this problem if you understand how the Matlab codes work in
    http://www.cse.ucsc.edu/~hongwang/Codes/ODE_sys_RK

  2. In problem 1 above, for the initial conditions y(0)=1.5 and y'(0)=0.0, run simulations with time steps h=0.2, h=0.2*2^(-1), h=0.2*2^(-2), h=0.2*2^(-3), h=0.2*2^(-4), h=0.2*2^(-5), h=0.2*2^(-6). For each value of h (excluding h=0.2*2^(-6)), estimate the error in the numerical solution of y at t=25 (Notice that 25 is integer multiples of all values of h used in simulations). Plot the estimated error against the step size h. Use logarithmic scales for both the X- and Y- axes. Estimate the order of accuracy of RK4 for this problem.
    It will help you do this problem if you understand how the Matlab codes work in
    http://www.cse.ucsc.edu/~hongwang/Codes/Estimate_error and
    http://www.cse.ucsc.edu/~hongwang/Codes/ODE_sys_RK.

  3. Use RK4 with time step h=0.05 to solve the van der Pol equation:
    y'' - (1-y^2)*y' + y = 0,
    This is the ODE governing electric circuits containing vacuum tubes. Here y is the electric current. This is a second order nonlinear ODE. First we need to convert it into a first oder ODE system.
    Plot y'(t) against y(t) for t in [0,25] for the two sets of initial conditions listed below.
    y(0)=0.25, y'(0)=0.0
    y(0)=-2.0, y'(0)=4.0
    Plot two curves in one figures.
    From your simulations, it should be clear that no matter what the initial conditions are the steady state is a curve going around the origin. This is called a limiting cycle.
    It will help you do this problem if you understand how the Matlab codes work in
    http://www.cse.ucsc.edu/~hongwang/Codes/ODE_sys_RK

Bonus part (Optional) (turn in results with brief descriptions)

  1. Use the backward Euler method to solve y'= -a*(exp(y)-1-0.75*cos(t)), y(0)=0 with a=1.0e8.
    Use time step h=0.1. Run the simulation from t=0 to t=10.
    Plot the solution as a function of time.

Start working on the course project