Consider the 100 times 100 matrix A = (-4 1 1 1 - 4 1 1 1 - 4 1 1), b = (1 1), c
ID: 3883197 • Letter: C
Question
Consider the 100 times 100 matrix A = (-4 1 1 1 - 4 1 1 1 - 4 1 1), b = (1 1), c =(0 1 2) which has -4 on the main diagonal and ones ons the 2nd and n/2-th sub/super diagonals (use integer division for n/2) (a) Solve the systems Ax = b and Ay = c. Calculate the LU-decomposition only once. Useful Python functions: scipy.linalg.lu factor, scipy.linalg.lu.solve (b) Calculate the LU-decomposition and plot the "sparsity patterns" of A, L and U. These are plots which are black in the positions where the respective matrices are non-zero and white where they are zero. What do you observe? Useful Python functions: scipy.linalg.lu, matplotlib.pyplot.spy (c) What is the difference between lu and lu_factor (In terms of the returned results)? Which one would you use in practice?Explanation / Answer
In order to find all solutions to Ax = b we first check that the equation is
solvable, then find a particular solution. We get the complete solution of the
equation by adding the particular solution to all the vectors in the nullspace.
A particular solution
One way to find a particular solution to the equation Ax = b is to set all free
variables to zero, then solve for the pivot variables.
For our example matrix A, we let x2 = x4 = 0 to get the system of equations:
x1 + 2x3 = 1
2x3 = 3
1
which has the solution x3 = 3/2, x1 = 2. Our particular solution is:
2
0
xp = . 3/2
0
Combined with the nullspace
The general solution to Ax = b is given by xcomplete = xp + xn, where xn is a
generic vector in the nullspace. To see this, we add Axp
get A xp + xn = b for every vector xn in the nullspace.
= b to Axn = 0 and
Last lecture we learned that the nullspace of A is the collection of all combi
2
1 2
0
nations of the special solutions and
. So the complete solution 0 2
0 1
1
to the equation Ax = 5 is:
6
2
0
3/2
+
2
1
0
2
+ c2
0
2
1
xcomplete = ,
0 0
where c1 and c2 are real numbers.
The nullspace of A is a two dimensional subspace of R4, and the solutions
2
0
to the equation Ax = b form a plane parallel to that through xp =
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.