Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Make a MATLAB code that will answer Task 1 and Task 2. Computational Problem/Code 1 (Related to Project 1.3h, not really h, but the spirit
Make a MATLAB code that will answer Task 1 and Task 2.
Computational Problem/Code 1 (Related to Project 1.3h, not really h, but the spirit of h with less work.) Implement equations/algorithms 1.17 and 1.69, as separate numerical codes using MATLAB. Task one: determine approximate solutions of the IVP u(t)=sin(t)u(t),u(0)=1.4,t[0,10]. You will implement the Euler methods derived from the forward and backward difference schemes for 10 time steps, t=h=1. Write Matlab codes for the forward difference (forward Euler method) and backward difference (backward Euler method). Provide copies of the codes and output. Copy and paste the code and associated output in the form of a table, for each method, into a word processed document then save as a pdf. The job for both codes is to have them working and producing the output. The output table should have the discrete time values in column one and the approximate solution associated with each time step in column two. For this task use n=10 Euler steps. Label your tables. ( 35 pts) Task two: Determine the true solution of the DE. Compute the errors in each method and produce a table for each method containing the step size, Euler (backward Euler) estimates and the error in the Euler (backward Euler) estimates. Provide plots of the a.) Euler error, b.) backward Euler error. (15 pts) 36 1. Setting the Scene 1.6 Projects 37 Problems (CONTINUED) (d) Use (1.68) to derive the backward Euler method, (s) Show that the matrices A1 and A4 are symmetric and positive definite, and that the matrix A5 is symmetric and positive semidefinite. (t) Show that a sum of symmetric and positive definite matrices is vm+1tf(vm+1)=vm,m=0,1,. also symmetric and positive definite. (u) Let ARn,n be a nonsingular matrix and define B=ATA. Show that B is symmetric positive definite. (v) A matrix ARn,n, not necessarily symmetric, is called positive real if (f) Explain why xTAx>0forallnonzeroxRn. Show that if A is positive real, then the matrix B=A+AT is (e) Apply the backward Euler method to the problem (1.65) and show that symmetric and positive definite. vm=(1+t)m1,m=0,1, Project 1.3 Numerical Methods for ODEs (g) Apply (1.71) to (1.65) and show that The purpose of this project is to illustrate that there is more to life than forward Euler. Numerical methods for ordinary differential equations is a vast subject reaching far beyond our scope. However, some ideas applied in that field will appear later in the text, so we use this project to present them in a simple framework. We start by considering the problem (h) Compare the accuracy of the three methods by computing approxima- u(t)u(0)=u(t)=1, tions to the solutions of (1.65) at t=1. Use the technique displayed in Table 1.1 and Project 1.1 to argue that the errors when using the schemes (1.66), (1.70), and (1.72) are O(t),O(t), and O((t)2) respectively. which we know has the analytical solution u(t)=et. (i) Implement the schemes discussed above for f(v)=v. Check the (a) Show that the numerical solution computed by the forward Euler correctness of your implementation by using your code to generate method (see (1.17) page 8 ) is given by approximations of (1.65). vm=(1t)m,m=0,1, (j) Generalize your codes to the problem (b) Show that vm converges toward the correct solution at t=1 as t tends to zero. u(t)=u2(t)u(0)=1. (c) In the derivation of the forward Euler method on page 8 , we argued that tu(tm+1)u(tm)u(tm)=f(u(tm)) (k) Derive the exact solution of (1.73) and use this to study the error of three schemes at t=1. Do the conclusions of (h) above also apply to this nonlinear problem? see (1.15). Show, in a similar manner, that we have tu(tm+1)u(tm)u(tm+1)=f(u(tm+1)). 8 1. Setting the Scene 1.3 A Numerical Method 9 timelevels tm=mt,m=0,1,, where t>0 is given. Let vm,m=0,1, denote approximations of u(tm). Obviously we put v0=u0, which is the given initial condition. Next we assume that vm is computed for some m0 and we want to compute vm+1. Since, by (1.12) and (1.14), tu(tm+1)u(tm)u(tm)=f(u(tm)) for small t, we define vm+1 by requiring that tvm+1vm=f(vm). Hence, we have the scheme FIGURE 1.3. The four plots show the convergence of the numerical approximations generated by the forward Euler scheme. vm+1=vm+tf(vm),m=0,1,. where M>0 is a given integer. Since the numerical solution at t=1 is This scheme is usually called the forward Euler method. We note that it is given by a very simple method to implement on a computer for any function f. Let us consider the accuracy of the numerical approximations computed vM=(1+t)M=(1+t)1/t, by this scheme for the following problem: the error is given by u(t)u(0)=u(t),=1. From calculus we know that The exact solution of this problem is u(t)=et, so we do not really need any lim0(1+)1/=e, approximate solutions. But for the purpose of illustrating properties of the so clearly scheme, it is worthwhile addressing simple problems with known solutions. In this problem we have f(u)=u, and then (1.17) reads vm+1=(1+t)vm,m=0,1,. meaning that we get convergence towards the correct solution at t=1. In Table 1.1 we have computed E(t) and E(t)/t for several values By induction we have of t. From the table we can observe that E(t)1.359t and thus conclude that the accuracy of our approximation increases as the number of timesteps M increases. As mentioned above, the scheme can also be applied to more challenging In Fig. 1.3 we have plotted this solution for 0tm1 using t=1/3, problems. In Fig. 1.4 we have plotted the exact and numerical solutions of 1/6,1/12,1/24. We see from the plots that vm approaches u(tm) as t is the problem (1.10) on page 6 using u0=2.1. decreased. Even though this problem is much harder to solve numerically than the Let us study the error of this scheme in a little more detail. Suppose we simple problem we considered above, we note that convergence is obtained are interested in the numerical solution at t=1 computed by a time step as t is reduced. t given by Some further discussion concerning numerical methods for ordinary differential equations is given in Project 1.3. A further analysis of the error t=1/M, introduced by the forward Euler method is given in Exercise 1.15Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started