Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LUFactorization.m function Q = LUFactorization(A) Q = A; n = size(A,1); for i = 1:n for r = i+1:n if (Q(i,i) == 0) error('Zero pivot

image text in transcribed

LUFactorization.m

function Q = LUFactorization(A)

Q = A; n = size(A,1);

for i = 1:n for r = i+1:n if (Q(i,i) == 0) error('Zero pivot element'); end Q(r,i) = Q(r,i) / Q(i,i); for c = i+1:n Q(r,c) = Q(r,c) - Q(r,i) * Q(i,c); end end end

Solving a linear system Ax-b by LU decomposition requires three phases: compute the decomposition A-LU, solve Ly-b (forward substitution), and solve Uz (backward substitution) Download the m-file LUFactorization.m from Moodle. This program implements the LU decomposition pseudocode from class, not worrying about pivoting (it checks for a zero pivot element and stops). The program returns the matrices L and U as one matrix Q, using the compressed storage method discussed in class: L is stored in the part of Q below the diagonal (the 1s on the diagonal of L are not stored in Q), and U is stored in the upper triangular part of Q (a) You are asked to complete the implementation and code up forward and backward substitution in Matlab, using only primitive commands (i.e. do not appeal to the built-in linear algebra functionality in MATLAB). You should use the function header given for each below and submit a copy of your code on Moodle and in the assignment package submitted to the assignment boxes (i) Forward Substitution. This function should take as input the matrix Q output by LUFactorization.m. function y - ForwardSubstitution(Q, b) % Usage: y- ForwardSubstitution (Q, b) % Perform forward substitution using the unit % lower triangular portion of the matrix Q (ii) Backward Substitution. This function should take as input the matrix Q output by LUFactorization.m. function x - BackwardSubstitution(Q, y) % Usage : x- BackwardSubstitution(Q, y) % Perform backward substitution using the % upper triangular portion of the matrix Q Solving a linear system Ax-b by LU decomposition requires three phases: compute the decomposition A-LU, solve Ly-b (forward substitution), and solve Uz (backward substitution) Download the m-file LUFactorization.m from Moodle. This program implements the LU decomposition pseudocode from class, not worrying about pivoting (it checks for a zero pivot element and stops). The program returns the matrices L and U as one matrix Q, using the compressed storage method discussed in class: L is stored in the part of Q below the diagonal (the 1s on the diagonal of L are not stored in Q), and U is stored in the upper triangular part of Q (a) You are asked to complete the implementation and code up forward and backward substitution in Matlab, using only primitive commands (i.e. do not appeal to the built-in linear algebra functionality in MATLAB). You should use the function header given for each below and submit a copy of your code on Moodle and in the assignment package submitted to the assignment boxes (i) Forward Substitution. This function should take as input the matrix Q output by LUFactorization.m. function y - ForwardSubstitution(Q, b) % Usage: y- ForwardSubstitution (Q, b) % Perform forward substitution using the unit % lower triangular portion of the matrix Q (ii) Backward Substitution. This function should take as input the matrix Q output by LUFactorization.m. function x - BackwardSubstitution(Q, y) % Usage : x- BackwardSubstitution(Q, y) % Perform backward substitution using the % upper triangular portion of the matrix

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago