Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask MATLAB Expert

Question 1. Let A = LU be a LU-factorisation of a NxN matrix A into a product of a lower-triangular matrix L and a upper-triangular matrix U. The solution x = U-1L-1b of Ax = b can be found efficiently by a "forward substitution" followed by a "backward substitution" using the following formulas derived in section §4.3.2 of the Lecture Notes

[L-1b]i = zi = (bi - j=1i-1lijzj ) 1/lii, for i = 1, 2....., N,

[U-1L-1b] = xi = (zi - j=i+1N uijxj ) 1/uii, for i = N, N-1, ....., 1,

Matlab code for forward substitution (1) is provided in Listing 1. Observe how elements of b that are no longer needed are replaced. Write a Matlab function b = backsolve(U,b) to perform backward substitution.

Listing 1: Matlab function implementing equation (1) for the solution of a lower-triangular system by forward substitution.

function b = for wardsolve (L, b)

[N , N ] = size(L);

b (1)= b (1)/ L (1 ,1);

for i = 2: N

b (i) = ( b ( i) - L (i ,1: i -1)* b (1: i -1))/ L (i , i );

end

Question 2. Let A = LU be a LU-factorisation of a given N × N matrix A into a product of a unit-lower-triangular matrix L with lii = 1 and a upper-triangular matrix U, to be determined. Show that the elements of U and L are given by

uij = (aij - k=1i-1likukj ), for i = 1, 2,..... j,     (3)

lij = (aij - k=1j-1likukj )1/ujj, for i = j + 1, j + 2,..... ,N,     (4)

for every j = 1, 2, ...., N .

[HINTS: Start from the explicit expression for matrix multiplication. Take into account the location of zeroes in L and U . May be useful to do Question 3 below before you do Question 2.]

Question 3. Illustrate the usage of equations (3) and (4) and find the LU-factorisation of the square matrix

1980_Matrix.jpg

[HINTS: Follow Example 4.29 from the Lecture Notes but proceed column-by-column rather than crosswise.]

Observe the following.

1. The u's and l's that occur in the right-hand side of (3) and (4) are already determined by the time they are needed. This makes the method possible and efficient.

2. The a's corresponding to u's and l's that are already determined are never needed again. This allows to overwrite the matrix A which is useful for pivoting, see below, and for reducing computer memory requirements.

3. Equation (3) in the case of i = j (its final application) is exactly the same as equation (4) except for the division in the latter equation; in both cases the upper limit of the sum is k = j - 1(= i - 1). This fact allows to incorporate partial pivoting (to select a large by modulus pivot (diagonal element ujj) for the division in (4)), which is essential for the method to work. Practically, compute l'ij = (aij - j-1Σk=1 likukj), swap
the rows of A (which you have been overwriting with L and U ) corresponding to ujj and m = max {|ujj|,|l'j +1,j|, |l'j +2j|,....|l'N,j| and only then divide by the pivot m to fully implement equation (4). Keep a permutation matrix P as you are now actually factorising PA = LU, instead.

Question 4. Write a Matlab function [P,L,U] = ColumnCroutLU(A) to perform the column- wise Crout method given by equations (3) and (4), overwriting the matrix A and performing partial pivoting as described in Question 3. Your function must take as a single argument the square matrix A and return a permutation matrix P, a unit-lower-triangular matrix L and upper-triangular matrix U of the same size. A Matlab function to perform one pivoting row swap is given in Listing2.

Use your ColumnCroutLU to factorise the matrices,

772_Matrix1.jpg

switching pivoting on and off. Verify that your factorisations satisfy PA = LU.

[HINTS: The code of Listing1can serve as an example. The inbuilt Matlab functions tril and triu can be used to extract L and U from the overwritten A.]

Listing 2: Matlab function to perform one pivoting row swap. Takes as arguments a matrix A to be pivoted and a pivot position (j,j) and returns a permutation matrix P and a modified A.

function[P , A ] = ppivot (A , j) [N , N ] =size( A );
P =eye( N );
[ amax , s] =max(abs( A ( j:N , j ))); s = s+ j -1;
A ([ j , s ] ,:) = A ([ s , j ] ,:);
P ([ j , s ] ,:) = P ([ s , j ] ,:);
end

Question 5. Study and run the Matlab function MysteriousCode provided in Listing3. What problem does it solve? Explain the related theory. Explain and comment the given code.

Listing 3: A Matlab function that performs a mysterious computation all the while using your own functions written for Questions 1 and 4.

function MysteriousCode
x = [0:1:10]';
y = cos( x );
A =vander( x );
[P ,L , U ]= ColumnCroutLU(A);
checkfact = L*U - P*A
z = forwardsolve (L, P * y );
a= backsolve (U, z );
xx = [0:0.1:10] ' ;
B = vander( xx );
BB = B (: ,end-10:end);
yy = BB * a; zz = cos( xx );
err =abs( zz - yy );
figure; plot(x ,y ,'-o');
hold on;plot( xx , yy ,'r');hold on;
figure;plot( xx , err );
end

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M92528817
  • Price:- $100

Priced at Now at $100, Verified Solution

Have any Question?


Related Questions in MATLAB

Suppose that a student has the option of enrolling for a

Suppose that a student has the option of enrolling for a single elective during a term. The student must select a course from a limited list of options: "English, " "History, " "Biology, " "Computer, " or "Math." Constru ...

Assignmentq1 find the laplace transforms of the following

Assignment Q.1 Find the Laplace transforms of the following functions: (a) t 2 + at + b and (b) sin(2nΠt/T) Q.2 Find f (t) for the following F(s) = α[ f (t)]. (i) 5/(s + 3), (ii) 1/s 2 + 25, (iii) 1/s(s+1) Q.3 Find the L ...

Question - verify the attached paper with matlab and get

Question - Verify the attached paper with matlab and get all the results in the paper and explain step by step the matlab code. Paper - Improving Massive MIMO Belief Propagation Detector with Deep Neural Network. Attachm ...

Assignment -matlab codes and simulated model in

Assignment - Matlab codes and simulated model in simulink/matlab and truetime. 1. Matlab codes and simulink model for pid controller optimization using particle swarm optimization (PSO) my plant is integer order 1000/(s^ ...

Lab assignment - matlab matrix relationallogical operators

Lab Assignment - MATLAB Matrix, Relational/Logical Operators and Plotting This laboratory exercise/assignment will involve you 1) practicing multiplication operators in MATLAB; 2) practicing relational and logical operat ...

Assignment - matlab programmingusing appropriate matlab

Assignment - MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Recitation problems -1 determine the highest real root of

Recitation Problems - 1. Determine the highest real root of f(x) = 2x 3 - 11.7x 2 + 17.7x - 5 using the Newton-Raphson method with at least four iterations. Start with an initial guess of x 0 = 3. 2. Determine the real r ...

Discrete optimisation- solve the following two problems

Discrete Optimisation - Solve the following two problems with both exhaustive enumeration and branch and bound - Problem 1 is a mixed integer linear optimisation problem (the problem has both discrete and continuous vari ...

Question 1 manipulate spectral imagehyperspectral images

Question 1. Manipulate spectral image Hyperspectral images can be seen as a generalisation of normal colour images such as RGB images. In a normal RGB colour image, there are 3 channels, i.e. channels for red colour, gre ...

Assignment matlab programmingusing appropriate matlab

Assignment: MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As