You must hand in your matlab codes along with the mathematics (if needed), discussion and results.

engineering

Description

Remember: You must hand in your matlab codes along with the mathematics (if needed), discussion and results. Also, as indicated in class, these codes must be commented in accordance with the examples appearing on the website


(10 points) Consider solving the initial value problem given by y˙ = f(t, y) .= 1 2 sin(t) + cos(y + t)[arctan(y) − 1 2 cos(y)] over t ∈ [0, 5] with initial condition y(0) = 1. You will solve this by two second-order Runge-Kutta methods. The first method is a second-order Runge-Kutta with the parameter from class being γ = 0.5 (equivalently, c2 = 0.5 in the textbook, page 361). The second method is a second-order Runge-Kutta with the parameter from class being γ = 100 (equivalently, c2 = 100 in the textbook, page 361). Apply both methods with n = 10, 102 , 103 and 104 steps. For each method, plot all the approximate solutions (for various n) on a single graph (for two plot windows in total – one per method). Treating the solution with γ = 0.5, n = 105 as the true solution, plot the log10 of the errors (i.e., |yn−y¯(tn)|) versus the log10(n) for each method, all on one graph, but in different colors. Using matlab, indicate which color corresponds to which method on your graph. Comment on the slopes. 


2. (5 points) Do the same thing as in the previous problem, but now include the fourth-order Runge-Kutta method (that you have written yourself) as well. In this problem, treat the fourth-order Runge-Kutta solution with n = 105 as the true solution. Also, in addition to plotting the log10 of the errors (i.e., |yn−y¯(tn)|) versus the log10(n), plot the log10 of the errors versus the log10 of the number of function evaluations (i.e., 1 the number of times that you evaluated f(t, y)) for each method. Has this changed the slopes compared with the plot where the horizontal axis was the number of steps (log10(n))?


3. (3 points) Do the same thing as in the previous problem, but now include Euler’s method. From the log-log plot, estimate the error in Euler’s method with n = 1000 steps. 


Related Questions in engineering category