# Exercise 100% We will apply backward and forward Euler to approxim...

## Transcribed Text

Exercise 100% We will apply backward and forward Euler to approximate the solution system sapplemented by the initial condition x(0) Here =.==(j-1)6 for j = 1,,2N and the matrix A isgiven by -1 -1 A -1 In short Aij= ifi=j£1 mod 2N. otherwise. This corresponds tothe PDE Example 27.1 (Lecture 27)but with (0. replaced by (0. 2x) and the boundary condition replaced by the periodic boundary conditions The reason for these modifications that the exact solution the system can be computed using the code obtained in Homework This because the eigenvectors for are given by with eigenvalue & 1. Run backward Euler Take 10 until E using NT time of size To assess the efficiency of the method. you will need to compute the error ENT where is the exact solution at point x=x; and time t = and cistheresult from the backward Euler at L=1. The exact solution can be obtained by executing EXACTODE(N.1) Run for NT 10. 100. 1000. 10000 ablt to see first order convergence *= ** 2. Modify your routinesoit computes the forward Nom for N 10. 20. 40.80 try get rough idem where the scheme becomes unstable by running different values NT. Note that you may need to tun more steps with the same N and to see the blow up. For example: NT max clusiom 19 clear probably blowing up definitely blowing up. For the last note that (== 1/19. be able see that N 10 and 1/20still blows /22 Thus the blow up value for N= 10is between &= 1/22 Do 3. The Crank- Nicholson or This scheme is A-stable and secoad order. Modify your code so it runs Crank -Nicholsor and report the error as a function of NT 4.8 16.32.64 Yom should be able to see the second order convergence. EXACTODE.r % computes the exact solution of the ODE at function [ex]=EXACTODE(N,t) forj=1:2*N xj=pi*(j-1)/N; f(j)=xj*(2*pi-xj); end x=TRIGCOEF(N,f); hs=(pi/N)^2; % multiply by the symbol or ==1:2*N js=-N+j; cx(j)=cx(j)*exp(-(2-2°cos(js*pi/N))/hs*t); end ex=TRIGEVAL(N,cx): % From exercise 5 function [tf]=TRIGEVAL(n,tc) for i=1:n+1 tcl(j)=tc(j+n- 1); end for j=2:n tcl(j+n)=tc(j-1); end tf=fft(tc1); function [cx]=TRIGCOEF(n.f) cx1=ifft(f); for j=1:n+1 cx(j+n-1)=cxl(j); end forj=2:n cx(j-1)=cx1(j+n); end

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

Q1

clear; clc; close all;
N = 10; t = 1;
yEx = real(EXACTODE(N,t));
NT = power(10,1:4);
eNT = [];
for i=1:length(NT)
tv = linspace(0,t,NT(i));
h = pi/N;
j =1:2*N;
xv = (j-1)*h;
v0 = xv.*(2*pi-xv);
yNum = eulerBackward(tv,@myODE,v0,N);
eNT = cat(2,eNT, max(abs(yEx-yNum(end,:))));
end
str1 = 'Error plot for N=10:Backward Euler';
figure('Name',str1);
loglog(NT,eNT); hold on;   xlabel('NT');    ylabel('e_N_T');
title(str1);...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

\$90.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Numerical Analysis Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.