Use the kron() function in MATLAB to set up a matrix operator to calculate 8² u ² u + əx² дуг on a mesh of size Nx N. Test your matrix operator on the function u(x, y) = sin(x) cos(Ty) in the domain -1 < x, y < 1. You can use 1g1nodes () (to get the Gauss-Lobatto points) and the DerivMatrix() MATLAB functions provided To generate the evenly spaced grid, use any inbuilt functions in MATLAB. Show that it works by using the contour () or surf() function in MATLAB to plot the results of your matrix operation and compare with the analytical function -27² sin(x) cos(Ty). You should show this for both the evenly spaced grid and the Gauss- Lobatto grid. You should get very good results, even with relatively small values of N.

Advanced Engineering Mathematics
10th Edition
ISBN:9780470458365
Author:Erwin Kreyszig
Publisher:Erwin Kreyszig
Chapter2: Second-order Linear Odes
Section: Chapter Questions
Problem 1RQ
icon
Related questions
Question

Please help 

Use the kron() function in MATLAB to set up a matrix operator to calculate
8² u
² u
əx² Əy²
+
=
sin(x) cos(Ty) in
on a mesh of size N × N. Test your matrix operator on the function u(x, y)
the domain -1 < x, y < 1. You can use 1g1nodes () (to get the Gauss-Lobatto points) and the
DerivMatrix() MATLAB functions provided
To generate the evenly spaced grid, use
any inbuilt functions in MATLAB. Show that it works by using the contour () or surf() function in
MATLAB to plot the results of your matrix operation and compare with the analytical function
-27² sin(x) cos(Ty). You should show this for both the evenly spaced grid and the Gauss-
Lobatto grid. You should get very good results, even with relatively small values of N.
Transcribed Image Text:Use the kron() function in MATLAB to set up a matrix operator to calculate 8² u ² u əx² Əy² + = sin(x) cos(Ty) in on a mesh of size N × N. Test your matrix operator on the function u(x, y) the domain -1 < x, y < 1. You can use 1g1nodes () (to get the Gauss-Lobatto points) and the DerivMatrix() MATLAB functions provided To generate the evenly spaced grid, use any inbuilt functions in MATLAB. Show that it works by using the contour () or surf() function in MATLAB to plot the results of your matrix operation and compare with the analytical function -27² sin(x) cos(Ty). You should show this for both the evenly spaced grid and the Gauss- Lobatto grid. You should get very good results, even with relatively small values of N.
function [x,w,P]=lglnodes(N)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Iglnodes.m
%
% Computes the Legendre-Gauss-Lobatto nodes, weights and the LGL Vandermonde
% matrix. The LGL nodes are the zeros of (1-x^2)*P'_N(x). Useful for numerical
% integration and spectral methods.
%
% Reference on LGL nodes and weights:
% C. Canuto, M. Y. Hussaini, A. Quarteroni, T. A. Tang, "Spectral Methods
% in Fluid Dynamics," Section 2.3. Springer-Verlag 1987
%
% Written by Greg von Winckel - 04/17/2004
% Contact: gregvw@chtm.unm.edu
% This MATLAB Function is taken from MATLAB Central File Exchange
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Truncation + 1
N1=N+1;
% Use the Chebyshev-Gauss-Lobatto nodes as the first;
guess
x=cos(pi*(0:N)/N)';
% The Legendre Vandermonde Matrix
P=zeros(N1,N1);
% Compute P_(N) using the recursion relation
% Compute its first and second derivatives and
% update x using the Newton-Raphson method.
xold=2;
while max(abs(x-xold))>eps
xold=x;
P(:,1)=1; P(:,2)=x;
for k=2:N
P(:,k+1)=((2*k-1)*x.*P(:,k)-(k-1)*P(:,k-1) )/k;
end
x=xold-(x.*P(:,N1)-P(:,N) )./( N1*P(:,N1));
w=2./(N*N1*P(:,N1).^2);
end
end
Transcribed Image Text:function [x,w,P]=lglnodes(N) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Iglnodes.m % % Computes the Legendre-Gauss-Lobatto nodes, weights and the LGL Vandermonde % matrix. The LGL nodes are the zeros of (1-x^2)*P'_N(x). Useful for numerical % integration and spectral methods. % % Reference on LGL nodes and weights: % C. Canuto, M. Y. Hussaini, A. Quarteroni, T. A. Tang, "Spectral Methods % in Fluid Dynamics," Section 2.3. Springer-Verlag 1987 % % Written by Greg von Winckel - 04/17/2004 % Contact: gregvw@chtm.unm.edu % This MATLAB Function is taken from MATLAB Central File Exchange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Truncation + 1 N1=N+1; % Use the Chebyshev-Gauss-Lobatto nodes as the first; guess x=cos(pi*(0:N)/N)'; % The Legendre Vandermonde Matrix P=zeros(N1,N1); % Compute P_(N) using the recursion relation % Compute its first and second derivatives and % update x using the Newton-Raphson method. xold=2; while max(abs(x-xold))>eps xold=x; P(:,1)=1; P(:,2)=x; for k=2:N P(:,k+1)=((2*k-1)*x.*P(:,k)-(k-1)*P(:,k-1) )/k; end x=xold-(x.*P(:,N1)-P(:,N) )./( N1*P(:,N1)); w=2./(N*N1*P(:,N1).^2); end end
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Advanced Engineering Mathematics
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
Numerical Methods for Engineers
Numerical Methods for Engineers
Advanced Math
ISBN:
9780073397924
Author:
Steven C. Chapra Dr., Raymond P. Canale
Publisher:
McGraw-Hill Education
Introductory Mathematics for Engineering Applicat…
Introductory Mathematics for Engineering Applicat…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Mathematics For Machine Technology
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,
Basic Technical Mathematics
Basic Technical Mathematics
Advanced Math
ISBN:
9780134437705
Author:
Washington
Publisher:
PEARSON
Topology
Topology
Advanced Math
ISBN:
9780134689517
Author:
Munkres, James R.
Publisher:
Pearson,