Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function usolve, analogous to function lsolve in section 7 . 2 . 2 , to solve an upper triangular system U x =
Write a function usolve, analogous to function lsolve in section
to solve an upper triangular system Hint: Loops can be run
backwards, say, from down to by typing in MATLAB: for :
: Remember also that the diagonal entries in are not necessarily Use this starting code in MATLAB:
Gaussian elimination without pivoting
for solving linear systems Axb
A ; ; ; b ;
A ; ; ; ; b ; another example
n sizeA;
This is Step of Gaussian Elimination
for i:n Loop over rows below row
mult AiA; Subtract this multiple of row from
row i to make Ai
Ai: Ai:multA:; this line is equivalent to the "for loop:
for k:n Aik AikmultAk; end;
bi bi multb;
end
U A display U
All steps of Gaussian elimination
A ; ; ; b ;
A ; ; ; ; b ; another example
n sizeA;
for j:n Loop over columns.
for ij:n Loop over rows below j
mult AijAjj; Subtract this multiple of row j from
row i to make Aij
Ai: Ai: multAj:; This does more work than necessary! WHY?
bi bi multbj;
end
end the resulting A is an upper triangular matrix
U A display U
Modified Gaussian elimination
to avoid recomputing zeros
A ; ; b ; ;
A ; ; ; b ;
A ; ; ; ; b ; another example
n sizeA;
for j:n Loop over columns.
for ij:n Loop over rows below j
mult AijAjj; Subtract this multiple of row j from
row i to make Aij
Aij:n Aij:n multAjj:n; modified! no more recomputing of
of zeros in columns to j and rows j to n
bi bi multbj;
end
end the resulting A is an upper triangular matrix
U A display U
Step 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