Starting from:
$35

$29

Programming Assignment 2 Solution

    1. Improving Euler’s method (again):

        (a) Read section 7.2 of the text. Make sure you can explain the idea of improved Euler’s method.

        (b) Write a function named \ImprovedEuler" using the same inputs and output as the \Euler" function in project 1.

        (c) Write a script to reproduce table 7.1 in the text. Plot the approximate solution combined with the true solution.

    2. The Runge-Kutta Method:

        (a) Read section 7.3 of the text. Make sure you can explain the idea of the Runge-Kutta method.

        (b) Write a function named \RK" using the same inputs and output as the \Euler" function in project 1.

        (c) Write a script to reproduce table 7.2 in the text. Plot the approximate solution combined with the true solution.

    3. Order of convergence: We showed in class that (forward) Euler’s method is a rst order method. That is, the error can be shown to be of the form


jeN j = jyN    y(tN )j = C    t    ( rst power for    t):

where C is a constant independent of t. An order p method has error of the form jeN j = jyN y(tN )j = C tp (pth power for t)
so that for    t small,    tp is very small for big whole number p implying the error is very small as well.

(a) If a method is of order p, then
jeN j = C  tp:

. Taking half the stepsize (twice the number of steps), we have that

je2N j = C

t

p




:

2


Show that
je2Nj  :
p   log2




eN





j


j

Use this formula for the next two parts.

(b) Using the example in the previous two problems, write a script which computes the error and order of convergence for t = 101 ; 201 ; 401 ; for each of the following methods.


            i. Euler’s method

            ii. Improved Euler’s method

            iii. The Runge-Kutta method

        (c) Find a way to see the order of convergence for centered Euler’s method. Compare this method to other methods.

    4. Scilab ODE solver:

        (a) Use the Scilab command \ode(y0,t0,t,f,‘rk’)" to solve the problem in the previous three problems.

        (b) Find the order of convergence of this method.

        (c) Compare this method to our other methods.


1

    5. (Bonus Problem!) Scilab is open source. Track down the source code for the \ode" command and explain what you nd.

    6. (Bonus Problem!) Prove that improved Euler’s method is an order 2 method. Prove that Runge-Kutta is an order 4 method.

    7. (Bonus Problem!) Eventually you will see these high order methods stop improving in your Scilab outputs. Explain why.
































































More products