2. Write a function usolve, analogous to function 1solve in section 7.2.2, to solve an upper triangular system Ux y. [Hint: Loops can be run backwards, say, from n down to 1, by typing in MATLAB: for i=n: - 1:1. Remember also that the diagonal entries in U are not necessarily 1.] =

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
2. Write a function usolve, analogous to function 1solve in section 7.2.2,
to solve an upper triangular system Ux = y. [Hint: Loops can be run
backwards, say, from n down to 1, by typing in MATLAB: for i=n: -
1:1. Remember also that the diagonal entries in U are not necessarily 1.]
I at
Transcribed Image Text:2. Write a function usolve, analogous to function 1solve in section 7.2.2, to solve an upper triangular system Ux = y. [Hint: Loops can be run backwards, say, from n down to 1, by typing in MATLAB: for i=n: - 1:1. Remember also that the diagonal entries in U are not necessarily 1.] I at
140
matrix below the main diagonal) are zeroed out during Gaussian elimination,
Therefore this space could be used to store the strict lower triangle of L, and
since the diagonal entries in L are always 1, there is no need to store these.
The entries in L are simply the multipliers (the variable called mult in the
previous code) used to eliminate entries in the lower triangle of A. Therefore
the Gaussian elimination code can be modified as follows:
% LU factorization without pivoting.
for j=1:n-1
for i=j+1:n
mult = A(i, j)/A (j,j);
end;
A(i, j) = mult;
end;
% Loop over rows below j.
% Subtract this multiple of
% row j from row i
% to make A (i, j)=0.
A(i, j+1:n) = A (i, j+1:n) - mult*A (j, j+1:n); % This works on
% columns j+1
% through n.
% Since A(i, j)
becomes 0, use
% the space to store L(i, j).
a linear system Ax = LUx =
As noted previously, once A has been factored in the form LU, we can solve
b by first solving Ly = b and then solving
11 0
l21 22
Ux
To solve Ly= b, we solve the first equation for y1, then substitute
= y.
this value into the second equation in order to find y2, etc., as shown below:
90-0-
::
l n 1 l2n
% Loop over columns.
...
y₁ = b₁/l11,
y2 = (b2l21 y1)/22,
:
⠀⠀
CHAPTER 7
Y₁ =
i-1
bi - Σlijv; /lii.
j=1
The procedure simplifies slightly when the diagonal entries in L are all 1s.
The following MATLAB function solves Ly - b, when L has a unit diagonal
and the strict lower triangle of L is stored:
function y = 1solve (L, b)
%
% Given a lower triangular matrix L with unit diagonal
% and a vector b,
% this routine solves Ly = b and returns the solution y.
DIRECT
Transcribed Image Text:140 matrix below the main diagonal) are zeroed out during Gaussian elimination, Therefore this space could be used to store the strict lower triangle of L, and since the diagonal entries in L are always 1, there is no need to store these. The entries in L are simply the multipliers (the variable called mult in the previous code) used to eliminate entries in the lower triangle of A. Therefore the Gaussian elimination code can be modified as follows: % LU factorization without pivoting. for j=1:n-1 for i=j+1:n mult = A(i, j)/A (j,j); end; A(i, j) = mult; end; % Loop over rows below j. % Subtract this multiple of % row j from row i % to make A (i, j)=0. A(i, j+1:n) = A (i, j+1:n) - mult*A (j, j+1:n); % This works on % columns j+1 % through n. % Since A(i, j) becomes 0, use % the space to store L(i, j). a linear system Ax = LUx = As noted previously, once A has been factored in the form LU, we can solve b by first solving Ly = b and then solving 11 0 l21 22 Ux To solve Ly= b, we solve the first equation for y1, then substitute = y. this value into the second equation in order to find y2, etc., as shown below: 90-0- :: l n 1 l2n % Loop over columns. ... y₁ = b₁/l11, y2 = (b2l21 y1)/22, : ⠀⠀ CHAPTER 7 Y₁ = i-1 bi - Σlijv; /lii. j=1 The procedure simplifies slightly when the diagonal entries in L are all 1s. The following MATLAB function solves Ly - b, when L has a unit diagonal and the strict lower triangle of L is stored: function y = 1solve (L, b) % % Given a lower triangular matrix L with unit diagonal % and a vector b, % this routine solves Ly = b and returns the solution y. DIRECT
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to classical planning
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education