1. Other
  2. Other
  3. please answer question 36 heun with matlab i have posted...

Question: please answer question 36 heun with matlab i have posted...

Question details
Please answer question 36 (Heun with Matlab) I have posted the whole assignment in case that tou need it.
Mathematical Modelling - Assignment 6: Numerical Methods for Differential Equations For this assignment you have to make an individual report. The report should have a front page with a title, your name and student number and a date and version. You may put a nice picture on the front if you like. Of course, your report should also have page numbers (except for the first page). If you use sources (webpages, articles, some help of friends) mention them in the end in a literature list Assignment 34: Euler by hand it is good to apply once the Euler method manually with pen and paper. In this way, you will understand the algorithm better (also you are going to appreciate the computer more). Given is the following differential equation (DE) and boundary condition (BC) -y-2t, y(0)-1 dit The analytical solution of this DE and BC is y(t)-2t +2-e (a) Show that the given solution, is indeed valid (b) Calculate the value of the numerical solution, by means of the Euler method at t 0.3. Use step size t-0.1. Perform your calculations with a precision of 4 digits after the decimal point. Hint: use a table and work properly (c) Can you explain if the Euler approximation is higher or lower than the analytical solution Hint: plot the analytical solution given and sketch the first step of the Euler method. (d) Repeat (b) again, but now with step size t 0.05. Calculate the deviation between the Euler approximation and the analytical solution att 0.3, for both time steps. ErrorA0.05 Error40.1 (e) Calculate the ratio Assignment 35: Euler with Matlab Given is the following header the function Euler: Eunction (t,yl Euler (deriv func, t_end, dt, to,yo) % Function to approximate a first order DE by the Euler method % The DE has the form dy/dt f(t,Y) % inputs : % de rivfunc: a Matlab function in which the right hand side of the DE has been progr ammed % t-end: time until which the DE has to be solved % dt: step size t0: start time % y0: initial value of the solution Assignment 6: Numerical Methods for Differential Equations 1/3
% Outputs: % t: array with times at which the solution has been calculated % y: array with the values of the numerical approximation One of the inputs needed by the Euler function is the expression f(t, y). This expression needs to be programmed in a separation function file. An example might be 1 function dy righthandside (t,y) 3 end Make a Matlab script in which you call the Euler function to solve the DE. Calling the Euler function goes like: 1 to 0; 2 tl 3; 3 dt 0.1: 5 (t,yl Euler (erighthandside, t1,dt,to,yo) We are now going to solve the DE of the previous exercise by means of Matlab. (a) Write a Matlab function righthandside to implement the righthand side of the DE. (b) Write the Euler function itself. (c) Write a Matlab script in which you solve the DE until t 0.3. Use start time t 0 and step size dt 0.1 (d) Plot the solution using markers (e.g. circles). Dont draw a connection line through the points of the solution. (d) The analytical solution has been given in the previous assignment. Evaluate this solution at the same time values as the Euler solution. Plot the analytical solution in the same figure, use this time a line and no markers. (e) Determine now the Euler solution for the step sizes 0.05 and 0.01, and plot these in the same figure. (f) Finally increase the end time to t # 3, take the step size :0.01 and determine the Euler solution. Plot this solution together with the analytical solution in a new figure. Assignment 36: Heun with Matlab (a-f) Repeat the same questions as in assignment 35, but now with the Heun method. This means that you have to implement a new function Heun, which has the same parameters as the Euler function, but of course a different implementation. To compare the Heun method with the Euler method, we will solve again the DE of the first assignment Take again as end time 0.3 and step size dt -0.1 Continue to work in the script which you have written in the precious assignment. Add an extra line in which you solve the DE by means of the Heun method (g) Plot the solutions (with different markers) in the same figure, together with the analytical solution. (h) Compare the precision of the different methods to evaluate the deviation with respect to the analytical solution at t : 03.
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution