for Linear Algebra
Department of Mathematics
Rowan University
TABLE OF CONTENTS
Chapter One Introduction
1.1 Mathematica's Conventions 2
1.2 Computations and Basic Inputs 4
1.3 Exercises 5
Chapter Two Matrices annd Linear Equations
2.1 Matrices: Addition, Multiplication, Transpose, Inverse 6
2.2 Special Matrices: Identity, Diagonal, Random 10
2.3 Solutions of Linear Systems of Equations 11
Chapter Three Determinants 18
Chapter Four Vectors and Vector Spaces
4.1 Vector Algebra 21
4.2 Linear Independence and Span 23
4.3 Null Space and Rank of a Matrix 25
4.4 Transtion Matrix 27
4.5 The Gram-Schmidt Orthogonalization Process 28
Chapter Five Eigenvalues and Eigenvectors
5.1 Eigenvalues, Eigenvectors, Diagonalization 31
5.2 Diagonalization of Symmetic Matrices 34
Chapter One Introduction to Mathematica
1.1 Mathematica's Conventions
1. 1. 1 Naming
Built-in Mathematica commands, functions, constants, and other expressions begin with capital letters, and are - for the most part- one or more full-length English words. Mathematica is case sensitive and so a common cause of error is the failure to capitalize command names. For example, Plot, Integrate, FindRoot, ParametricPlot3D are valid function names. Sin, Exp, Det, GCD, Max are some of the standard mathematical abbreviations that are exceptions to the full-length-English-word(s) rule. User defined functions and variables can be any mixture of upper and lower case letters and numbers. However, a name cannot begin with a number. By convention, user defined functions begin with a lower-case letter, but this is not required. For example f, g1, myPlot, r12, sOLution, Method1, are permissible function names.
Example 1: Evaluate cos(π)
Solution: We will use this example to show two possible errors before giving the correct answer.
In[1]:=
Out[1]=
This is a typical capitalization error one makes when using Mathematica. The comment before the output Out[1] = cos[π] indicates a possible error.
In[2]:=
Out[2]=
Here Mathematica did not recognize pi and hence returned the command unevaluated. The correct command to evaluate cos(π) is
In[3]:=
Out[3]=
NOTE: It is worth noting that Mathematica keeps track of the calculations it performs in a given session. The inputs are denoted by In[k] and the outputs are denoted by Out[k]. Thus, In[1] is the first input and Out[1] is the output of the first input.
1. 1. 2 Parentheses, Square Brackets and Braces
Mathematica interprets various types of brackets differently. Using an incorrect type of bracket is another common source of error. Mathematica's bracketing conventions are:
1) Parentheses, ( ), are used only for grouping. For example (x-y)^2, 1/(a+b), (x^3-y)/(x+3y^2). It is worth noting that Mathematica understands f(2) as f times 2, and not as the value of the function f at 2.
2) Square Brackets, [ ], are used for function arguments. Thus Sin[Pi], Simplify[(x^3-y`^3)/x-y)], Sqrt[346] are proper use of square brackets. If f is a user-defined function, then f[2] is f evaluated at 2.
3) Braces or curly brackets, { }, are used for lists, ranges, and iterators. In all cases, elements are separated by commas. Here are the typical use of braces:
{1, 4, 9, 16, 25 ,36} the list of the square of the first six positive integers.
Plot[ f[x], {x, -5,5}] specifies the range of values for x.
Table[m^3, {m, 1, 100}] specifies the values of the iterator m, i.e., the values of m; m goes from 1 to 100.
NOTE: We can write comments with an input. The comments should be enclosed by (* and *). For example, Table[
,{ n, 1, 6 } ] (*returns a list of the square of the first six positive integers*)
Example 2: Below we give examples of the correct and incorrect usage of brackets.
In[4]:=
Out[4]=
In[5]:=
In[5]:=
Out[5]=
In[6]:=
Out[6]=
1. 1. 3 Equal Signs
The following are Mathematica rules of using the equal sign symbol.
1) A single equal sign ( = ) assigns a value to a variable. Thus q=3 means that q will be assigned the value 3. If we enter 10+q^3, Mathematica will return 37. As another example take y=x^3-x+1. Now, if we assign a value for x, say x=2, then Mathematica evaluates y using that value of x and uses the result, 7 in our case, in any input containing y afterwards.
2) A colon-equal sign( := ) creates a delayed statement for an expression, used in defining a function. For example f[x_]:=x^3-x+1 will reevaluate the function f for each new value of x.
3) A double equal sign( = = ) is a test for the equality of two expressions. If we set x = -5, then evaluating x == -5 returns True, and x == 5 returns False. Another common usage of == is as in Solve[x^3-x+1==0,x]
1. 1. 4 Referring to Previous Results
Mathematica remembers all of the inputs and outputs in a session, and we can refer to a previous output by using the percent sign (%) notation. A single % refers to Mathematica's last output, %% refers to the next-to-last output, and so on. %k refers to output line numbered k. For example %45 refers to output number 45. (NOTE: CTRL +L reproduces the last input and CTRL+SHIFT+ L reproduces the last output.)
1.2 Computations and Basic Inputs
Mathematica uses +, - , * , / , and ^ for addition, subtraction, multiplication, division and power, respectively. Multiplication can also be performed by leaving a blank space between factors.
Mathematica can convert numerical values to decimal form. The command for this is N[expr] or N[expr,n]. In most cases, N[expr] returns six digits of expr or gives expr in the form n.abcde*
. N[expr,n] attempts to give n digits of expr. Mathematica can perform calculations to arbitrary precision and can handle numbers that are arbitrarily large or small.
Example 3: Here are some typical usages of N[..]
In[7]:=
Out[7]=
In[8]:=
Out[8]=
Note that the command N[%] gives a decimalized version of the last output. Similarily N[%k] can be used to get the decimal equivalent of Output[k].
In[9]:=
Out[9]=
Mathematica 3.0 allows us to enter mathematical expressions and some of the commonly used commands from 6 different palettes. If we click on the File menu and go to Palettes we will find 7 options. The first six options conatin most of the symbols we need. BasicInput is a palette which can be used to enter mathematical expressions involving exponents, rational expressions, radicals, integrals, derivatives, summation, product, matrices, some of the commonly used constants( π, e, i, ∞) and some of the Greek letters.
Example 4: Enter ![]()
dx in a notebook.
Solution: One way to enter this expression into a Mathematica notebook is as follows: Go to the BasicInput palette and click on the definite integration symbol
□d□ . Type 0 in the lower box and using the TAB key move to the top box and type 1. Use the TAB to go to the box where the integrand should be typed. While in this box go to the palette and click on
. Go back to the pallete and click on
and type
in this box. Go to the box in the denominator and then go to the palette to click on
and type 2x-1. Finally, using the TAB once again, go to the last box and type x.
1.3 Exercises
1. Evaluate the following expressions:
a) 103.41+20*76 b)
c)
d)
2. Enter the following expressions in a notebook.
(a)
(b)
(c) ![]()
(d)
(e)
(f)
Chapter Two Linear Equations and Matrices
2.1 Matrices: Addition, Multiplication, Transpose, Inverse
Example 1: Consider the following matrices:
A=(
); B =(
2
3
1
3
3
1
2
4
1
) ; X =(
2
0
0
1
-4
8
1
-1
2
) ; Y =(
2
4
0
1
2
6
); Z =(
1
0
6
)
-1
1
4
Compute each of the following.
a) 3A - 4B b) AB c) BA d) X^T e) X^T B Y Z
Solution: We first enter the matrices in Mathematica as follows. A matrix can be typed using braces, with a pair of braces around each row. A comma separates the rows as well as the entries in a row. For example, the matrix A can be entered as follows.
In[10]:=
Out[10]=
In order to display matrix A in the usual form, we use the command:
In[11]:=
Out[11]//MatrixForm=
In the above, note that the semicolon tells Mathematica not to print the result of matrix A in a list form.
Another way of entering a matrix, such as B, is to perform the following. From the Input menu choose Create Table/Matrix/Palette. Then, select Matrix and identify the number of rows and columns of the matrix to be 3. Click OK and a 3x3 matrix is generated. You can now insert the entries of the matrix and use TAB to go from one entry to the next.
In[12]:=
Out[12]=
Similarly, we enter matrix X.
In[13]:=
Out[13]=
A column matrix such as Y is entered by putting braces around each entry.
In[14]:=
Out[14]//MatrixForm=
We can also use the palettes to create a matrix and enter matrix Y as follows.
In[15]:=
Out[15]=
Next, we enter the row matrix Z.
In[16]:=
Out[16]//MatrixForm=
a ) We evaluate the matrix 3A - 4B and display it in matrix form.
In[17]:=
Out[17]//MatrixForm=
b) The product of the matrices A & B is obtained by typing A .B. Note that if you omit the dot that is between A & B, then the product is not obtained.
In[18]:=
Out[18]//MatrixForm=
c) Similarly, we get the product of matrices B and A.
In[19]:=
Out[19]//MatrixForm=
Observe that the above calculations show that matrix multiplication is not commutative.
d) The transpose of X is obtained by entering:
In[20]:=
Out[20]//MatrixForm=
e) First, observe that the product of the matrices
B Y Z is a 2x3 matrix (Do you see why?). This product is obtained by entering:
In[21]:=
Out[21]=
Out[22]//MatrixForm=
Remark: In Mathematica, the notation % refers to the last output. Thus, in the above, the command MatrixForm[%] is used to express the last output in the usual matrix representation.
Example 2: Use the matrices in Example 1 to verify each of the following identities.
a)
= ![]()
b) (AB)X =A (BX) c) (A+B)X = AX + BX
Solution: a) We verify that Transpose[AX] = Transpose[X]. Transpose[A] by computing:
In[23]:=
Out[23]=
b) Next, we verify that matrix multiplication, when defined, is associative.
In[24]:=
Out[24]=
c) We show that matrix multiplication is distributive over matrix addition.
In[25]:=
Out[25]=
Example 3: Let W = 3A - 4B, where A and B are the matrices defined in Example 1. Find each of the following.
a)
= the entry in row 2 and column 1
b) the second row of W
c) the third column of W
d) the submatrix obtained by deleting row 1 and column 3 of W.
Solution: First, we find the matrix W as follows.
In[26]:=
Out[26]//MatrixForm=
From a given matrix, such as W, we can extract single entries, rows, columns or submatrices as follows.
a) To obtain the entry in row 2 and column 1, the command is:
In[27]:=
Out[27]=
b) To obtain the second row of W, the command is:
In[28]:=
Out[28]=
c) To obtain the third column of W, we enter:
In[29]:=
Out[29]//MatrixForm=
d) The submatrix obtained by deleting row 1 and column 2 of W is the one having rows 2 & 3 and columns 1 & 3 of W. This can be obtained as follows.
In[30]:=
Out[30]//MatrixForm=
Example 4: a) For the matrix A in Example 1, find
and show that A
= I.
b) Find the inverse of a general 2x2 matrix (
) assuming that ad - bc is nonzero.
a
b
c
d
Solution: a) The inverse of a nonsingular square matrix A is obtained by the command Inverse[A]. For our case, we see that
In[31]:=
Out[31]//MatrixForm=
We can check the result by computing the product of A with Inverse[A].
In[32]:=
Out[32]//MatrixForm=
b) The formula for computing the inverse of a general 2x2 square matrix can be obtained as follows.
In[33]:=
Out[34]//MatrixForm=
2.2 Special Matrices: Identity, Diagonal, Random
1. The command IdentityMatrix[n] gives the n×n identity matrix. For example, the 3x3 identity matrix is obtained by:
In[35]:=
Out[35]=
Out[36]//MatrixForm=
2. The command DiagonalMatrix[list] gives the diagonal matrix with the elements of the list on the main diagonal and 0 elsewhere. An example of a 3x3 diagonal matrix is,
In[37]:=
Out[37]=
Out[38]//MatrixForm=
3. One can generate a random matrix of any size. For example a 3x3 random matrix whose entries are numbers between 0 and 1 can be obtained by:
In[39]:=
Out[39]=
Out[40]//MatrixForm=
An example of a 5x4 random matrix whose entries are integers -9 and 9 can be btained by:(Note: the semicolon at the end of the first input tells Mathematica not disply the output.)
In[41]:=
Out[41]=
Out[42]//MatrixForm=
2.3 Solutions of Linear Systems of Equations
Example 5: Solve the following system of linear equations.
a)
b)
![]()
![]()
![]()
![]()
![]()
c)
d)
![]()
![]()
![]()
2x +y +z-2w= 1
3x-2y+z-6w=-2
x + y-z- w=-1
6x + z-9w=-2
5x-y+2z-8w=3
Solution: A system of linear equations that is equivalent to the matrix equation Ax=b may be solved using the command LinearSolve[A,b].
a) The system is equivalent to the matrix eqiuation Ax = b. We type A and b and then apply the command LinearSolve.
In[43]:=
Out[43]//MatrixForm=
In[44]:=
Out[44]//MatrixForm=
In[45]:=
Out[45]=
Thus, we see that the solution is
=1
=-1 and
=2. Another way of solving the above is to form the augmented matrix Ao and express it in reduced row echelon form. The augmented matrix Ao is given by
In[46]:=
Out[46]//MatrixForm=
We now use the command RowReduce that puts the augmented matrix in reduced row echelon form. This gives matrix A1:
In[47]:=
Out[47]//MatrixForm=
We can now read the solution
=1
=-1 and
=2. A third way of solving the above system is to use x=Inverse[A].b, if the matrix A is invertible. In our case, this becomes
In[48]:=
Out[48]//MatrixForm=
Again, note that we get the previously obtained solution of the system.
b) We type the coefficient matrix A and the constant matrix b and then apply LinearSolve.
In[49]:=
Out[49]=
In[50]:=
Out[50]=
In[51]:=
Out[51]=
In this case, Mathematica is indicating that the coefficient matrix is nonsingular and the system has no solution. However, the system has clearly infinite solutions given by
=3 -
,
arbitrary. This shows that it is always important to check the results. The reason for failure may be due to round-off error in the use of decimals. Thus, we try to solve this by retyping A as A1, and b as b1, by expressing all entries as fractions, and applying the command LinearSolve.
In[52]:=
Out[52]=
Out[53]=
Out[54]=
In this case, Mathematica gives a solution of
=3,
=0. This is just one of the infinitely many solutions. This shows that when using the command LinearSolve one has to avoid using decimals. Also, Mathematica may give one of infinitely many solutions.
Another approach is to find the reduced row echelon form of the augmented matrix. First, we enter the augmented matrix A2 where all entries are expressed in fractional form.
In[55]:=
Out[55]//MatrixForm=
Next, we compute A3, the reduced row echelon form of A2.
In[56]:=
Out[56]//MatrixForm=
From the above we see that the system has infinite solutions given by
=t,
=3-t.
c) First, we use the command LinearSolve after entering the coefficient matrix A and the constant matrix b.
In[57]:=
Out[57]//MatrixForm=
In[58]:=
Out[58]=
In[59]:=
Out[59]=
In this case, among the infinite solutions of the system, Mathematica gives a solution of the system where
=0. We can obtain these infinite solutions by expressing the augmented matrix in reduced row echelon form. First, we enter the augmented matrix as Ao.
In[60]:=
Out[61]//MatrixForm=
Next, we find the reduced row echelon form of the augmented matrix and call it A1.
In[62]:=
Out[62]//MatrixForm=
From the above, we see that
is a free variable. Thus, the solution is given by
=t,
=535/72+77/36 t,
=1669/90+37/9 t, and
=8473/360+19/36 t. In particular, if we use t=0, we get a solution of the system as
=0,
=535/72,
=1669/90, and
=8473/360, which was the solution obtained previously using the command LinearSolve.
d) We first enter the coefficient matrix A and the constant matrix b.
In[63]:=
Out[63]=
In[64]:=
Out[64]=
In[65]:=
Out[65]=
The above indicates that the system has no solution. We can check this by obtaining the reduced row echelon form of the augmented matrix as follows.
In[66]:=
Out[66]=
In[67]:=
Out[67]//MatrixForm=
The fourth row of the above matrix shows that the system has no solution (do you see why?).
Example 6: Determine the value of the parameter a for which the linear system:
(3+a)x+2y+3z=4
-x+ y - z=-2
y+ a z=0
is inconsistent.
Solution: First, we form the augmented matrix A. Then, we apply elementary row operations on A.
In[68]:=
Out[69]=
Interchange rows 1 and 2 of matrix A and denote the resulting matrix by A1.
In[70]:=
Out[70]=
Out[71]//MatrixForm=
Next, we multiply row 1 of matrix A1 by -1 to obtain matrix A2.
In[72]:=
Out[72]=
Out[73]//MatrixForm=
Myltiply row 1 of matrix A2 by -(3+a) and add it to row 2 of A2 to get matrix A3.
In[74]:=
Out[74]=
Out[75]//MatrixForm=
We interchange rows 2 and 3 of A3 to obtain matrix A4.
In[76]:=
Out[76]=
Out[77]//MatrixForm=
We now multiply row 2 of A4 by - (5+a) and add it to row 3 of A4. This gives matrix A5.
In[78]:=
Out[78]=
Out[79]//MatrixForm=
In[80]:=
Out[80]=
Out[81]//MatrixForm=
From the above matrix, we see that the system is inconsistent when a = 0, a= -6 or a= -1. (Do you see why?)
Chapter Three Determinants
Example 1: Let A be the matrix given by A= (
).
2
1
-3
0
4
5
-1
3
2
a) Find Det(A).
b) Show that Det(
) = Det(A)
c) Verify that Det(2A) =
Det(A)
d) Let
be the matrix that is obtained by interchanging rows 1 and 2 of A. Show that Det(
) = - Det(A).
e) Let
be the matrix that is obtained from A by replacing the third row of A by the sum of row 3 and 5 times row 1. Show that Det(
) = Det(A).
Solution: We first enter the matrix A.
In[82]:=
Out[82]//MatrixForm=
a) Next, we evaluate the determinant of A:
In[83]:=
Out[83]=
b) We evaluate the determinant of Transpose[A]:
In[84]:=
Out[84]=
c) We find the determinant of 2A and compare it with 8 times the determinant of A.
In[85]:=
Out[85]=
In[86]:=
Out[86]=
d) We first define matrix A1, the matrix obtained by interchanging rows 1 & 2 of A. Then, we evaluate its determinant.
In[87]:=
Out[87]//MatrixForm=
In[88]:=
Out[88]=
e) The matrix A2 obtained by adding 5 times row 1 to row 3 of A is given by:
In[89]:=
Out[89]//MatrixForm=
In[90]:=
Out[90]=
Example 2: Redo Example 1 if A is an arbitrary 3x3 matrix.
Solution: We first enter a general 3x3 matrix A.
In[91]:=
Out[91]=
a) The determinant of A is given by:
In[92]:=
Out[92]=
b) To show that Det[Transpose A] = Det[A], we compute
In[93]:=
Out[93]=
c) To show that Det[2A] = 8 Det[A], we compute
In[94]:=
Out[94]=
It is not clear why the above is equal to zero and so we:
In[95]:=
Out[95]=
d) First we enter matrix A1 that is obtained by interchanging rows 1 & 2 of A.
In[96]:=
Out[96]//MatrixForm=
To show that Det[A1] = -Det[A], we compute
In[97]:=
Out[97]=
e) The matrix A2, obtained by adding 5 times row 1 to row 3 of A, is given by:
In[98]:=
Out[98]//MatrixForm=
To show that Det[A2] = Det[A], we calculate
In[99]:=
Out[99]=
Chapter Four Vectors and Vector Spaces
4.1 Vector Algebra
Vectors are typed in braces with commas between components. For example if a is the vector a= i+3j -5k we type
In[100]:=
a={1,3,-5}
Out[100]=
Vector addition, subtraction and scalar multiplication are perfomed in the same way as the corresponding operations on numbers.The dot product of vectors a and b is obtained by a.b and the length of a is obtained by using the command Sqrt[a.a].
Example 1: Let a= i+3j -5k and b= -i+2j +3k. Find 3a-2b, a.b, and ||b||.
Solution: First we will enter the components of a and b as lists. Then, we enter the solutions for all the problems in one cell:
In[101]:=
a={1,3,-5}
b={-1,2,3}
Out[101]=
Out[102]=
In[103]:=
Out[103]=
Out[104]=
Out[105]=
Example 2: Show that the dot product of vectors is commutative and that dot product is distributive over addition, that is , a.b= b.a and a.(b+c)=a.b+a.c for any vectors a ,b and c.
Solution: We will verify the above properties for vectors in space.
In[106]:=
Clear[a,b,c,a1,a2,a3,b1,b2,b3,c1,c2,c3]
a={a1,a2,a3}
b={b1,b2,b3}
c={c1,c2,c3}
a.b-b.a (*if this is equal to 0, this proves the
distributive property*)
a.(b+c)-(a.b+a.c) (*if this is equal to 0, this proves the
distributive property*)
Out[107]=
Out[108]=
Out[109]=
Out[110]=
Out[111]=
It is not clear why the last output is zero. We check this by entering:
In[112]:=
Simplify[%]
Out[112]=
Example 3: Let u= i+3j + 2k, v= 2i+3 j and w = -2i+3j +4k. Find u × v and (u × v).w
Solution: In order to calculate the cross product of two vectors we need a package, called Calculus`VectorAnalysis`. It is recommended that you load this package before starting your work. The command to load this package is Needs["Calculus`VectorAnalysis`"]. To compute the cross product u × v of u and v we type Cross[u,v]. In Mathematica 3.0, there is a palette that contains the command for cross product. It is in File-Palettes-Lists and Matrices-Matrix Operations and is denoted by Cross[□ ,□]. First, we load the package:
In[113]:=
Needs["Calculus`VectorAnalysis`"]
In[114]:=
u={1,3,2}
v={-2,3,0}
w={-2,3,4}
Out[114]=
Out[115]=
Out[116]=
In[117]:=
prod= CrossProduct[u,v]
prod.w
Out[117]=
Out[118]=
Thus, we see that u x v = -6i - 4j + 9k and (u x v ) . w = 36.
Example 4: Consider the parallelepiped with sides a=i+k, b=2i+j+3k and c=i+j-2k.
a) Find the volume. b) Find the area of the face determined by b and c.
Solution:
In[119]:=
Out[119]=
Out[120]=
Out[121]=
Out[122]=
Out[123]=
Hence, the volume of the parallellepiped is 4 and the area of the face determined by vectors b and c is 5
/ 2
4.2 Linear Independence and Span
Example 5: If S={
(t),
(t),
(t)}={t-1, t+1,
+t+1}, determine whether p(t)= 2
+ t - 2 belongs to the span of S.
Solution: We find scalars
,
,and
such that ![]()
(t) + ![]()
(t) + ![]()
(t) = p(t). This is equivalent to solving a system of linear equations with augmented matrix:
In[124]:=
Out[124]=
The reduced row echelon form of A is obtained by:
In[125]:=
Out[125]//MatrixForm=
The above shows that
= 3/2,
= - 5/2 and
= 2 and so p(t) belongs to the span of S.
Example 6: Determine if S ={(1,1,-1), (1, 7, 2), (0, 4, 2), (2, 8, 1) } spans
.
Solution: Given any vector (a,b,c) in
, we have to check if there exist scalars
,
,
, and
such that:
(1, 1, -1) +
(1, 7, 2) +
(0, 4, 2) +
(2, 8, 1) = (a, b, c).
This leads to solving a system of equations whose augmented matrix is given by:
In[126]:=
Out[127]=
Now, we use elementary row operations on A to solve the system. Add -1 times row 1 to row 2 and add row 1 to row 3 to obtain matrix A1.
In[128]:=
Out[128]=
Out[129]//MatrixForm=
Next, we divide row 2 of A1 by 6 to get a leading 1. We denote the resulting matrix by A2.
In[130]:=
Out[130]=
Out[131]//MatrixForm=
Next, we multiply row 2 of A2 by -3 and add it to row 3 and denote the resulting matrix by A3.
In[132]:=
Out[132]=
Out[133]//MatrixForm=
The last row of the above matrix shows that the vectors do not span
. (do you see why?)
Example 7: Determine if S={ (1, 1, 0, 0), (2, 1, 1, -1), (0, 0, 1, 1), (1 , 2, 1, 2)} is a basis of
.
Solution: Since we know that the dimension of
is 4 and S contains 4 elements, it suffices to check whether or not S is linearly independent. Thus, we consider a solution of the system of equations
+
+
+ ![]()
= 0 . Thus the augmented matrix, A , of the system of equations has the given vectors as column vectors(do you see why?) and so:
In[134]:=
Out[134]=
In[135]:=
Out[135]//MatrixForm=
The above shows that
=
=
=
= 0 and so S is linearly independent. Hence S forms a basis of
.
4.3 Null Space and Rank of a Matrix
Example 8: Let A= (
).
2
1
2
0
0
0
0
0
1
2
2
1
4
5
6
2
3
3
4
1
a) Find a basis for the null space of A. Also, find the nullity of A and the rank of A.
b) Find a basis for the row space of A consisting of vectors that are not row vectors of A.
c) Find a basis for the row space of A consisting of vectors that are row vectors of A.
d) It can be shown that v = (7, 11, 12, 5) is in the row space of A. Express v as a linear combination of the basis elements obtained in b) and c) above.
Solution: We first enter the matrix as:
In[136]:=
Out[136]=
The command NullSpace[A] gives a basis for the null space of A, and so we find:
In[137]:=
Out[137]=
This shows that a basis for the null space of A is {(1, -2, 0, 3), (-2, -2, 3, 0)} and so the nullity is 2. Hence, the rank of the matrix is given by 4 - nullity of A = 2. (Do you see why?
b) To find a basis for the row space of A consisting of vectors that are not row vectors of A, we find the nonzero vectors in the reduced row echelon form of A and so we calculate:
In[138]:=
Out[138]//MatrixForm=
Thus, a basis for the row space of A is given by {(1, 0, 2/3, -1/3), (0, 1, 2/3, 2/3)}.
c) To find a basis for the row space of A consisting of row vectors of A, we find the reduced row echelon form of the transpose of A.
In[139]:=
Out[139]//MatrixForm=
The leading 1's occur in columns 1 and 3. Hence, the vectors corresponding to columns 1 & 3 of the transpose of A form a basis of the row space of A. Thus, a basis is { (2,1,2,0), (1,2,2,1)}.
d) Using the "natural basis" obtained in a): We see that the leading 1's in the reduced row echelon form of A occur at columns 1 and 2. Thus, v= (7, 11, 12, 5) = 7 (1, 0, 2/3, -1/3) +11 (0, 1, 2/3, 2/3). For the basis obtained in b) above, we have to find scalars a and b such that a (2, 1, 2, 0) + b ( 1, 2, 2, 1) = v= (7, 11, 12, 5). This leads to a system of equations whose augmented matrix is B, given by:
In[140]:=
Out[140]=
Out[141]//MatrixForm=
Thus, we see that a = 1 and b = 5 and so v = (7, 11, 12, 5) = (2, 1, 2, 0) + 5 (1, 2, 2, 1).
4.4 Transtion Matrix
Example 9 : In
consider the bases S and T given by:
S = {
,
,
} ={ (1, 1, 0), (1, 0, 1), (1, 1, 1)} and T = {
,
,
} ={ (1, 2, 1), (1, 2, 0), (1,0,2)} .
a) Find the transition matrix P from the T-basis to the S-basis.
b) Let v be a vector whose coordinates with respect to the T-basis is
= (-1,2,5). Find the coordinates of v with respect to the S-basis by using the transition matrix P.
Solution: We proceed by finding the coordinates of the basis vectors
,
, and
with respect to the S-basis. This computation requires that we solve 3 linear systems whose coefficient matrix is composed of the vectors from the S-basis and the constant matrix is a column matrix with entries from
,
, and
. So we consider the augmented matrix:
In[142]:=
Out[142]=
In[143]:=
Out[143]=
Out[144]//MatrixForm=
Hence the transition matrix is given by:
P = (
).
0
1
-1
-1
-1
1
2
1
1
b) In order to find the coordinates of v with respect to the S-basis, we use the equation:
= P .
. Hence the coordinates of v with repect to the S-basis is given by:
In[145]:=
Out[145]=
We can verify our work by computing:(do you see why?)
In[146]:=
Out[146]=
4.5 The Gram-Schmidt Orthogonalization Process
For many purposes, the most convenient type of basis for a vector space is an orthonormal basis, i.e., the vectors are of unit length and are pairwise orthogonal. The Gram-Schmidt procedure takes an arbitrary basis of
and generates an orthonormal one. Given a basis {
,
, ...,
} of
, an orthonormal basis is obtained by using the command GramSchmidt[{
,
, ...,
}].
Example 10: Cosider the basis S={
,
,
} for
, where
= (1,1,1),
= (-1, 0, -1), and
=(-1,2,3).
a) Use the Gram-Schmidt process to transform S into an orthonormal basis for
.
b) Express v=(-1, 2, 0) as a linear combination of the orthonormal basis obtained in a) above, i.e., find the coordinates of v with respect to the orthonormal basis.
Solution: First, we load the package to use the Gram-Schmidt process.
In[147]:=
If we denote the orthonormal basis, obtained from the given basis S, by w1, w2, and w3, then we obtain
In[148]:=
Out[148]=
The above gives an orthonormal basis. Thus, the dot product of each pair of different vectors is zero and each vector has length 1. We can verify this by computing the dot products as follows.
In[149]:=
Out[149]=
b) To find the coordinates of v with respect to the orthonormal basis obtained above, we find real numbers a, b, and c such that a w1 + b w2 + c w3 = v. Recall that if a basis is orthonormal, then the coordinates a, b, and c are obtained by computing the dot products v.w1, v.w2, and v.w3, repectively. We obtain this as follows.
In[150]:=
Out[150]=
In[151]:=
Out[151]=
In[152]:=
Out[152]=
The above gives the values of a, b, and c, respectively. We can check the above result by computing:
In[153]:=
Out[153]=
It is not clear why the above is equal to v =(-1, 2, 0) and so we:
In[154]:=
Out[154]=
Example 11: Let W be the subspace of
with basis S={
,
,
} where
= (1, -2, 0, 1),
= (-1, 0, 0, -1), and
=(1,1,0, 0). Use the Gram-Schmidt process to find an orthonormal basis for W.
Solution: An orthonormal basis of W is obtained by:
In[155]:=
Out[155]=
Chapter Five Eigenvalues and Eigenvectors
5.1 Eigenvalues, Eigenvectors, Diagonalization
If A is a square matrix of size n, then the command Det[A - λ* IdentityMatrix[n]] gives the characteristic polynomial of A. The command Eigenvalues[A] gives the eigenvalues of A. Repeated eigenvalues are represented as many times as the algebraic multiplicity indicates. Eigenvectors are obtained by the command Eigenvectors[A].
Example 1: Find the characteristic polynomial, the eigenvalues and the corresponding eigenvectors of
A=(
).
1
2
-1
1
0
1
4
-4
5
Is A diagonalizable? If so, find a diagonal matrix D and an invertible matrix P such that
A P = D.
Solution:
In[156]:=
Out[156]=
We obtain the characteristic polynomial , f (λ), as follows.
In[157]:=
Out[157]=
We can obtain the eigenvalues by solving for the roots of the characteristic polynomial. We do this as follows.
In[158]:=
Out[158]=
From the above, we see that there are 3 real eigenvalues: 1, 2, and 3. We can also find the eigenvalues and eigenvectors as follows.
In[159]:=
Out[159]=
In[160]:=
Out[160]=
Thus, the matrix has three eigenvalues: 1, 2, & 3 and three eigenvectors: (-1, 1, 2), (-2, 1, 4), and (-1, 1, 4). However, the eigenvalues and eigenvectors may not appear in corresponding order. Thus, to find both the eigenvalues and their corresponding eigenvectors, we use the command:
In[161]:=
Out[161]=
This shows that 1 is an eigenvalue of A and (-1, 1, 2) is the corresponding eigenvector. Similarly, for the eigenvalue 2, an eigenvector is (-2,1,4) ; for the eigenvalue 3 an eigenvector is (-1, 1, 4). We can verify this by computing:
In[162]:=
Out[162]=
Out[163]=
Out[164]=
Since A has distinct eigenvalues, A is diagonalizable. If we now let P be the matrix whose columns are the eigenvectors, then
A P = D, where D is the diagonal matrix whose diagonal entries are the respective eigenvalues. We verify this as follows.
In[165]:=
Out[165]=
Out[166]=
Out[167]//MatrixForm=
Example 2: Let A = (
). Find the eigenvalues and corresponding eigenvectors of A. Also, if A is diagonalizable , find an invertible matrix P and a diagonal matrix D such that
4
2
3
2
1
2
-1
-2
0
A P = D.
Solution:
In[168]:=
Out[168]=
Out[169]=
The above shows that A has two eigenvalues λ = 1 and λ = 3. The eigenvalue λ =1 has multiplicity 2. However, the eigenspace for λ =1 has dimension 1. Thus A is not diagonalizable.
Example 3: Let A = (
). Find the eigenvalues and corresponding eigenvectors of A. Also, if A is diagonalizable , find an invertible matrix P and a diagonal matrix D such that
0
0
-2
1
2
1
1
0
3
A P = D.
Solution:
In[170]:=
Out[170]=
Out[171]=
The above shows that A has two eigenvalues λ = 1 and λ=2. The eigenvalue λ =2 has multiplicity 2 and has two eigenvectors (-1,0,1) and (0,1,0), which are clearly linearly independent(do you see why?). In other words, the eigenspace for λ =2 has dimension =2. Thus A is diagonalizable, P is the matrix whose columns are the eigenvectors of A, and D is the diagonal matrix whose diagonal entries are the eigenvalues of A. We verify this as follows:
In[172]:=
Out[172]=
Out[173]=
Out[174]//MatrixForm=
5.2 Diagonalization of Symmetic Matrices
Example 4: Find an orthogonal matrix P that diagonalizes the symmetric matrix: A= (
).
1
-4
2
-4
1
-2
2
-2
-2
Solution: First, we find the eigenvalues and corresponding eigenvectors of A.
In[175]:=
Out[175]=
Out[176]=
Next, for each eigenvalue, we find an orthonormal basis of the eigenspace using the Gram-Schmidt Orthogonalization Process. First, we consider the eigenspace for the eigenvalue λ = -3 which has dimension 2. An orthonormal basis of its eigenspace is given by w1, w2 where
In[177]:=
In[178]:=
Out[178]=
For the eigenvlaue λ=6, the eigenspace has dimension 1 and an orthonormal basis is given by w3:
In[179]:=
Out[179]=
Recall that the diagonalizing matrix P is the matrix whose column entries are the orthonormal basis of the eigenspaces. Thus, matrix P is given by:
In[180]:=
Out[180]=
We verify that P is an orthogonal matrix by computing:
In[181]:=
Out[181]=
Finally, we show that P is a diagonalizing matrix by computing:
In[182]:=
Out[182]=
It is not clear that this is a diagonal matrix whose diagonal entries are the eigenvalues of A and so we :
In[183]:=
Out[183]//MatrixForm=
Exercises
1 Consider the following system of linear equations.
4x-3y+2z-w = -5
2x+y-3z = 7
-x+4y+z+2w = 8
a) Use the command LinearSolve[A,b] to find the solutions of the above system.
b) Express the augmented matrix in reduced row echelon form and find the solutions of the system of equations.
2. Let A=(
) and b=(
1
-2
3
-1
3
0
2
-5
5
). Solve the system A X= b.
9
-4
1
3. Let B=(
) Find the matrices that are obtained by performing the following row operations in succession on matrix B.
1
3
4
-5
2
-3
5
6
4
9
-6
7
a) Multiply row 1 by 2.
b) Add 3 times row 1 to row 2.
c) Add -4 times row 1 to row 3.
d) Interchange rows 2 and 3.
4. For what values of a does the following system of equations have no solution, a unique solution or infinitely many solutions?
x-y+z=1
x+3y+a z=2
2x+a y+3z=3
5. Let A=(
) B=(
1
2
3
4
2
0
-1
3
2
-5
5
1
)
1
2
3
4
6
8
5
19
4
-5
4
4
C=(
) D=(
4
1
4
4
2
0
-1
3
2
4
6
8
)
-4
10
-10
-2
2
0
-1
3
2
4
6
8
i) Find a) A-3B b)
D c) B(
+
)
ii) Use the RowReduce command to detrmine which of the above matrices are row equivalent.
6. Let F=(
).
0
1
0
0
-1
0
0
0
0
0
0
1
0
0
1
0
a) Find the smallest positive integer k so that
= F. [ Hint: Note that the command MatrixPower[F,n] gives
.]
b) Assume that F is nonsingular. Use the result in a) to find the smallest value of n for which
=
.
7. Let A=(
). Find
1
![]()
0
![]()
,
, and
. Can you guess what
is?. Verify your guess.
8. If S={
(t),
(t),
(t)}={t, 2t+1,
+t}, determine whether p(t)= 2
+ t - 2 belongs to the span of S.
9. Determine if S ={(
), (
2
1
0
), (
-1
0
3
), (
-4
1
8
) } spans
0
1
1
.
10. Determine if S ={(
), (
1
0
2
0
), (
2
1
-1
-1
), (
1
0
2
0
) } is a basis of
1
3
-1
4
.
11. In
consider the bases S and T given by:
a) Find the transition matrix P from the T-basis to the S-basis.
b) Let v be a vector whose coordinates with respect to the T-basis is
= (
). Find the coordinates of v with respect to the S-basis by using the transition matrix P.
-1
2
5
12. Cosider the basis S={
,
,
} for
, where
=(
),
1
1
1
= (
), and
1
1
0
=(
)
0
1
-2
a) Use the Gram-Schmidt process to transform S into an orthonormal basis for
.
b) Express v=(
) as a linear combination of the orthonormal basis obtained in a) above, i.e., find the coordinates of v with respect to the orthonormal basis.
-1
2
0
13. Let W be the subspace of
with basis S={
,
,
} where
= (
),
1
0
2
1
= (
) and
-1
0
1
0
=(
). Use the Gram-Schmidt process to find an orthonormal basis for W.
1
1
0
1
14. Let a= -i+3j -k and b= i-2j +5k. Find 3a-2b, a.b, and ||b||.
15. Let A be the matrix given by A= (
).
2
7
3
1
6
1
3
4
5
a) Find Det(A).
b) Show that Det(
) = Det(A)
c) Verify that Det(2A) =
Det(A)
d) Let
be the matrix that is obtained by interchanging rows 1 and 2 of A. Show that Det(
) = - Det(A).
e) Let
be the matrix that is obtained from A by replacing the third row of A by the sum of row 3 and 5 times row 1. Show that Det(
) = Det(A).
16. Let A = (
). Find the eigenvalues and corresponding eigenvectors of A. Also, if A is diagonalizable , find an invertible matrix P and a diagonal matrix D such that
1
0
0
-1
3
0
3
2
-2
A P = D.
| Created by Mathematica (May 24, 2007) |