Student[LinearAlgebra] Examples
Eigenvalues and Eigenvectors
Tools≻Load Package: Student Linear Algebra
Loading Student:-LinearAlgebra
Example 1: Diagonalize a Matrix
Diagonalize A=−1−1216 by finding and applying an appropriate transition matrix P.
Data entry
Control-drag the matrix. Context Panel: Assign to a Name≻A
−1−1216→assign to a nameA
Obtain the transition matrix P, whose columns are the eigenvectors of A
Write the name A. Context Panel: Evaluate and Display Inline
Context Panel: Student Linear Algebra≻Eigenvalues, etc≻Eigenvectors
Context Panel: Select Element≻2
Context Panel: Assign to a Name≻P
A = −1−1216→eigenvectors32,−3−411→select entry 2−3−411→assign to a nameP
Diagonalize A by applying P
Write the appropriate product of matrices. Use dot (period) for matrix multiplication. Context Panel: Evaluate and Display Inline
P−1.A.P = 3002
Example 2: Singular Values of a Matrix
Obtain the singular values of A=−1−1216, and verify the results from first principles
Obtain the singular values
Context Panel: Student Linear Algebra≻Eigenvalues, etc≻Singular Values
A = −1−1216→singular values1942+17021942−1702
From first principles
Enter the product of the transpose of A with A. Context Panel: Evaluate and Display Inline
Context Panel: Student Linear Algebra≻Eigenvalues, etc≻Eigenvalues
Context Panel: Assign to a Name≻V
A%T.A = 21818180→eigenvalues91+824591−8245→assign to a nameV
Expression palette: square-root operator Apply to each component of the vector V, whose components are the eigenvalues of ATA
V1 = 1942+1702
V2 = 1942−1702
Example 3: Jordan Form
Obtain a transition matrix that puts A= 5−5−4−4857−11−7 into Jordan form.
Maple can return the required transition matrix. The calculations below proceed from first principles.
Context Panel: Assign to a Name≻A
5−5−4−4857−11−7→assign to a nameA
Context Panel: Student Linear Algebra≻ Solvers and Forms≻Jordan Form
(Consequently, there is one chain of length 3 corresponding to the eigenvalue 2.)
5−5−4−4857−11−7→Jordan form210021002
Obtain the null spaces of C=A−2 I and C2
Context Panel: Assign to a Name≻C
(Note that Maple tolerates A−2 as a short form of A−2 I, where I is the identity matrix.)
A−2 = 3−5−4−4657−11−9→assign to a nameC
Context Panel: Evaluate and Display Inline Context Panel: Student Linear Algebra≻Vector Spaces≻Null Space
C = 3−5−4−4657−11−9→null space12−121
C2 = 1−1−1−1112−2−2→null space101,110
Select a vector in ℝ3 that is not in the null space of C2 and verify this choice
Context Panel: Assign to a Name≻b[3]
1,0,0→assign to a nameb3
Context Panel: Student Linear Algebra≻ Standard Operations≻Determinant
(Non-vanishing of the determinant shows b3 is not a member of the null space of C2)
111010100→determinant−1
Construct the remaining members of the one chain of linearly independent generalized eigenvectors
Context Panel: Evaluate and Display Inline Context Panel: Assign to a Name≻b[2]
C.b3 = 3−47→assign to a nameb2
Context Panel: Evaluate and Display Inline Context Panel: Assign to a Name≻b[1]
(Note that b1 is an eigenvector.)
C.b2 = 1−12→assign to a nameb1
Construct the transition matrix whose columns are the vectors b1,b2,b3
Context Panel: Evaluate and Display inline
Context Panel: Select Elements≻Combine into Matrix
Context Panel: Assign to a Name≻Q
b1,b2,b3 = 1−12,3−47,100→combine into Matrix131−1−40270→assign to a nameQ
Verify that Q puts A into Jordan form
Context Panel: Evaluate and Display Inline
Q−1.A.Q = 210021002
Solution of Linear Systems
Example 1: Solve a Completely Determined Linear System
Solve the completely determined system consisting of the equations
x+y+z=1,x−y−2 z=3,5 x+2 y−7 z=9
Simply solve the equations
Control-drag the equations. Context Panel: Solve≻Solve
x+y+z=1,x−y−2 z=3,5 x+2 y−7 z=9→solvex=2915,y=−45,z=−215
Convert to a linear system
Control-drag the equations.
Context Panel: Student Linear Algebra≻ Constructions≻Generate Matrix≻Augmented (Complete dialog as per Figure 1.)
Context Panel: Student Linear Algebra≻ Solvers and Forms≻Linear Solve
Figure 1
x+y+z=1,x−y−2 z=3,5 x+2 y−7 z=9→to Matrix form11111−1−2352−79→linear solve2915−45−215
Example 2: Least-Squares Solution of an Overdetermined System
Obtain a least-squares solution to the overdetermined system consisting of the equations
x+y+z=1,x−y−2 z=3,5 x+2 y−7 z=9,3 x−7 y+9 z=−4
Control-drag the equations and press the Enter key.
Context Panel: Student Linear Algebra≻Constructions≻Generate Matrix≻Matrix-Vector pair (Complete dialog as per Figure 1, in Example 1.)
Context Panel: Student Linear Algebra≻Solvers and Forms≻Least Squares
x+y+z=1,x−y−2⁢z=3,5⁢x+2⁢y−7⁢z=9,3⁢x−7⁢y+9⁢z=−4
→to Matrix form
1111−1−252−73−79,139−4
→least squares
1020711574931286−777711574
Example 3: Minimum-Norm Least-Squares
Obtain the minimum-norm least-squares solution of the system 705−101−51910−811−14−691x=1234.
Obtain the minimum-norm least-squares solution
Control-drag the system, editing it to a sequence of matrix and vector.
Context Panel: Student Linear Algebra≻Solvers and Forms≻Least Squares Check the "Optimized" box in the "Specify options for Least Squares" dialog
705−101−51910−811−14−691,1234→least squares−1034175110−5434375552698175110184737555
Work from first principles: obtain the general solution and minimize its norm:
Obtain the general solution
Context Panel: Student Linear Algebra≻Solvers and Forms≻Least Squares Free-Variable Name≻s
Context Panel: Evaluate at a Point≻s
Context Panel: Assign to a Name≻X
705−101−51910−811−14−691,1234→least squaress13⁢s1+1395187⁢s15+357464757⁢s15+313312950→evaluate at points3⁢s+1395187⁢s5+357464757⁢s5+313312950→assign to a nameX
Obtain the norm and minimize it
Write the name X and press the Enter key.
Context Panel: Student Linear Algebra≻Standard Operations≻Norm≻Euclidean
Context Panel: Differentiate≻With Respect To≻s
Context Panel: Conversions≻Equate to 0 (This step is optional.)
Context Panel: Solve≻Solve
Context Panel: Assign to a Name≻S
X
s3⁢s+1395187⁢s5+357464757⁢s5+313312950
→Euclidean-norm
2334418800⁢s2+642796560⁢s+7298521812950
→differentiate w.r.t. s
4668837600⁢s+64279656025900⁢2334418800⁢s2+642796560⁢s+72985218
→equate to 0
4668837600⁢s+64279656025900⁢2334418800⁢s2+642796560⁢s+72985218=0
→solve
s=−1034175110
→assign to a name
S
Expression palette: Evaluation template Evaluate X at the solution in S
Xx=a|f(x)S = −1034175110−5434375552698175110184737555
Example 4: Stepwise Row Reduction and Back-Substitution
If the linear system Ax=y is expressed by the augmented matrix 5−6−23−43−3−11102, row-reduce to upper triangular form and solve for x.
Control-drag the matrix. Context Panel: Student Linear Algebra≻ Standard Operations≻Row-Reduced Form
Context Panel: Select Elements≻Restrict Columns (Complete dialog as per Figure 2. The return is then a vector and not a one-column matrix.)
Figure 2
5−6−23−43−3−11102→row-reduced form10059470103547001−2847→restrict columns59473547−2847
Stepwise row reduction can be done via the Context Panel system, as per Figure 3.
Figure 3 Elementary row operations via the Context Panel system
The elementary row operations are also available in two tutors that can be accessed from the Context Panel (Student Linear Algebra > Tutors) . These are the Gaussian Elimination and Gauss-Jordan Elimination tutors..
Matrix Factorizations
Example 1: LU Decomposition
Obtain the LU decomposition of the matrix 165−22452−6.
Control-drag the given matrix. Context Panel: Student Linear Algebra≻Solvers and Forms≻LU Decomposition
165−22452−6→LU decomposition100010001,100−2105−21,1650141400−3
The returned matrices are P,L,U, with P being the matrix that tracks permutations of the rows; L being the unit lower triangular factor; and U being the upper triangular factor. By default, Maple returns the Doolittle, not the Crout, factorization.
Example 2: QR Decomposition
Obtain the QR decomposition of the matrix 165−22452−6.
Control-drag the given matrix. Context Panel: Student Linear Algebra≻Solvers and Forms≻QR Decomposition
165−22452−6→QR decomposition30302⁢5566−301555−633060−66,302⁢305−11⁢3010014⁢5514⁢550062
Example 3: Singular-Value Decomposition
Obtain the singular-value decomposition of the matrix 165−22452−6.
Control-drag the given matrix. Context Panel: Student Linear Algebra≻Solvers and Forms≻Singular Value Decomposition≻Singular Value Decomposition (U,S,Vt)
165−22452−6→singular value decomposition (U,S,Vt)0.5988918686−0.7180631732−0.35456142980.4864104839−0.025556623020.8733565706−0.6361865833−0.69550854560.3339678021,10.008749777.1046510340.5906452392,−0.35517543160.32909195430.8749565122−0.5833492223−0.80940067990.06763300640−0.73044787460.4863836187−0.4794547714
The return consists of the factor U, the vector of singular values, and the transpose of the factor V. If S is a diagonal matrix whose diagonal elements are the singular values, then A=U S VT.
Queries
Example 1: Positive Definite Matrix
Is the symmetric matrix 741453136 positive definite?
Control-drag the given matrix. Context Panel: Student Linear Algebra≻Queries≻ Is Definite?≻Positive Definite?
741453136→is positive definite?true
Typically, definiteness is assigned to bilinear forms xTAx derived from the symmetric matrix A. If A is not symmetric, the associated bilinear form can be represented by xTBx, where B=A+AT/2, the "symmetric part of A" is symmetric. Hence, Maple assigns definiteness to the symmetric part of a nonsymmetric matrix on the grounds that the matrix represents a bilinear form.
Example 2: Similar Matrices
Show that the matrices A=−5−2−234−14−2−8 and B=−15−1530−23341114332191−5−931−1427 are similar by finding a matrix C for which C A=B C.
Write the sequence of matrices A and B Context Panel: Student Linear Algebra≻Queries≻Similar?
−5−2−234−14−2−8,−15−1530−23341114332191−5−931−1427→is similar?true,100−486581522111533522111−10713480743167305221119852211130011044222→select entry 2100−486581522111533522111−10713480743167305221119852211130011044222→assign to a nameC
Control-drag each matrix. Context Panel: Assign to a Name≻A (or B, as appropriate)
−5−2−234−14−2−8→assign to a nameA
−15−1530−23341114332191−5−931−1427→assign to a nameB
Test for similarity and find C
Write a sequence of the names A and B, then press the Enter key.
Context Panel: Student Linear Algebra≻Queries≻Is Similar?
A,B
−5−2−234−14−2−8,−15−1530−23341114332191−5−931−1427
→is similar?
true,100−486581522111533522111−10713480743167305221119852211130011044222
→select entry 2
100−486581522111533522111−10713480743167305221119852211130011044222
C
Verify similarity
C.A = −5−2−22428078522111326169174037985481522111−1577354522111−212023174037−645562522111
B.C = −5−2−22428078522111326169174037985481522111−1577354522111−212023174037−645562522111
Example 3: Orthogonal Matrix
Construct a (nontrivial) 3×3 orthogonal matrix.
Enter a list of three linearly independent vectors and press the Enter key.
Context Panel: Student Linear Algebra≻Vector Spaces≻Gram-Schmidt≻normalized
−4,1,6,5,3,1,7,−8,9
−416,531,7−89
→Gram-Schmidt (normalized)
−4⁢535353536⁢5353,13⁢3183185⁢3181597⁢318318,66−6366
→combine into Matrix
−4⁢535313⁢3183186653535⁢318159−636⁢53537⁢31831866
Q
Verify that Q is an orthogonal matrix
Write the name Q Context Panel: Evaluate and Display Inline
Context Panel: Student Linear Algebra≻Queries≻Orthogonal?
Q = −4⁢535313⁢3183186653535⁢318159−636⁢53537⁢31831866→is orthogonal?true
An alternative verification consists in showing that QTQ=QQT=I, thereby confirming that the rows (and columns) of Q are sets of orthonormal vectors.
Q%T.Q = 100010001
Q.Q%T = 100010001
Vector Spaces
Example 1: Four Fundamental Subspaces of a 5×3
Find the row space, column space, null space, and null space of the transpose for the matrix
32−8−4−40105−32848−2−172−18−9
(Gilbert Strang of MIT calls these the four fundamental subspaces of A.)
The 5×3 matrix A maps ℝ3 to ℝ5. Maple provides bases for each of the four fundamental subspaces.
The row and null spaces of A are orthogonal subspaces of ℝ3; the column space of A and the null space of AT are orthogonal subspaces in ℝ5. Figure 4 illustrates the relationships between these four subspaces.
Figure 4 The four fundamental subspaces of A
Control-drag (or copy/paste) the given matrix. Context Panel: Assign to a Name≻A
32−8−4−40105−32848−2−172−18−9→assign to a nameA
Row space of A
Write the name A Context Panel: Evaluate and Display Inline
Context Panel: Student Linear Algebra≻Vector Spaces≻Row Space
A = 32−8−4−40105−32848−2−172−18−9→row space1−14−18
Column space of A
Context Panel: Student Linear Algebra≻Vector Spaces≻Column Space
A = 32−8−4−40105−32848−2−172−18−9→column space1−54−11494
Null space of A
Context Panel: Student Linear Algebra≻Vector Spaces≻Null Space
A = 32−8−4−40105−32848−2−172−18−9→null space1801,1410
Null space of AT
Write the notation for the transpose of A Context Panel: Evaluate and Display Inline
A%T = 32−40−32872−8108−2−18−454−1−9→null space−940001,−140010,10100,541000
Example 2: Four Fundamental Subspaces of a 4×5
5042−6−2020−8−1−3737−244743−2926−25−21310−10
The 4×5 matrix A maps ℝ5 to ℝ4. Maple provides bases for each of the four fundamental subspaces.
The row and null spaces of A are orthogonal subspaces of ℝ5; the column space of A and the null space of AT are orthogonal subspaces in ℝ4. Figure 5 illustrates the relationships between these four subspaces.
Figure 5 The four fundamental subspaces of A
5042−6−2020−8−1−3737−244743−2926−25−21310−10→assign to a nameA
A = 5042−6−2020−8−1−3737−244743−2926−25−21310−10→row space106011−59113811,01−73116511−4011
A = 5042−6−2020−8−1−3737−244743−2926−25−21310−10→column space102726−12,018130
A = 5042−6−2020−8−1−3737−244743−2926−25−21310−10→null space−38114011001,5911−6511010,−60117311100
A%T = 50−847−2542−143−21−6−37−293−203721020−246−10→null space12001,−2726−81310
Special Matrices
Example 1: Inverse by Adjoint
Divide the adjoint of A=921−5−4146−2 by the determinant of A, and show that the resulting matrix is A−1, the multiplicative inverse of A.
Control-drag the matrix A. Context Panel: Assign to a Name≻A
921−5−4146−2→assign to a nameA
Obtain the determinant of A
A = 921−5−4146−2→determinant−8
Obtain the adjoint of A
Context Panel: Student Linear Algebra≻Standard Operations≻Adjoint
Context Panel: Assign to a Name≻adjA
A = 921−5−4146−2→adjoint2106−6−22−14−14−46−26→assign to a nameadjA
Divide the adjoint by the determinant
adjA−8 = −14−54−34341147474234134
Obtain A−1, the multiplicative inverse of A
Context Panel: Student Linear Algebra≻ Standard Operations≻Inverse
A = 921−5−4146−2→inverse−14−54−34341147474234134
Example 2: Reflection Matrix (across a Line)
Obtain a matrix that reflects vectors in ℝ2 across the line y=x/3.
The red dashed line line in Figure 6 is the graph of y=x/3. The green vector, 3 i+j, is along this line.
The gold vector, −i+3 j, is orthogonal to the line y=x/3.
The black vector, 2 i+2 j, is an arbitrary vector in ℝ2. Its reflection across the line y=x/3 is the red vector.
The reflection matrix is constructed from the gold vector, that is, from a vector orthogonal to the "mirror" across which reflection is to take place.
Figure 6
Construct the rotation matrix
On a vector orthogonal to the line of reflection: Context Panel: Evaluate and Display Inline
Context Panel: Student Linear Algebra≻Constructions≻Reflection Matrix
Context Panel: Assign to a Name≻R
−1,3 = −13→reflection matrix453535−45→assign to a nameR
Test the rotation matrix
Write sequences of two vectors (black & green, red & green, in Figure 6); press the Enter key.
Context Panel: Student Linear Algebra≻Standard Operations≻Vector Angle
2,2,3,1
22,31
→angle between
arccos⁡2⁢105
R.2,2,3,1
145−25,31
Example 3: Reflection Matrix (across a Plane)
Obtain a matrix that reflects vectors in ℝ3 across the plane x+2 y+3 z=0.
Figure 7 shows the plane across which reflections are to take place. In addition, N, the black vector in the figure, is a normal to the plane.
The red vector, V=i+j+k, is an arbitrary vector in ℝ3.
The green vector is RV, the reflection of V across the given plane, where R is the requisite reflection matrix.
The angles between V and N and RV and -N should be equal if RV is the reflection of V across the plane.
use plots, Student:-VectorCalculus, Student:-LinearAlgebra in module() local p1,p2,p3,R,N,V; N:=<1,2,3>/2; V:=<1,1,1>; R:=ReflectionMatrix(N); p1:=implicitplot3d(x+2*y+2*z=0,x=-1..1,y=-1..1,z=-2..2,style=wireframe); p2:=PlotVector([N,V,R.V],color=[black,red,green],width=.2); p3:=display(p1,p2,scaling=constrained,labels=[x,y,z],axes=frame,orientation=[-5,80,0],tickmarks=[3,4,6],lightmodel=none); print(p3); end module: end use:
Figure 7
On a vector orthogonal to the plane: Context Panel: Evaluate and Display Inline
1,2,3 = 123→reflection matrix67−27−37−2737−67−37−67−27→assign to a nameR
Write sequences of two vectors (V and N, RV and -N, in Figure 7); press the Enter key.
1,1,1,1,2,3
111,123
arccos⁡3⁢147
R.1,1,1,−1,2,3
17−57−117,−1−2−3
Example 4: Rotation Matrix
Rotate the vector V=i−j+2 k through an angle of π/6 radians about the line x=t,y=2 t,z=3 t.
In Figure 8, the black vector, i+2 j+3 k, is along the axis of rotation, shown as the dashed red line.
In Figure 8, the red vector is V=i−j+2 k; its π/6 rotation about the axis of rotation, is the green vector.
use plots, Student:-VectorCalculus, Student:-LinearAlgebra in module() local p1,p2,p3,V,N,R; R:=RotationMatrix(Pi/6,<1,2,3>); V:=<1,-1,2>; N:=<1,2,3>; p1:=spacecurve([t,2*t,3*t],t=-1/5..1.2,color=red,linestyle=dash); p2:=PlotVector([V,R.V,N],color=[red,green,black],width=.2); p3:=display(p1,p2,scaling=constrained,labels=[x,y,z],tickmarks=[3,3,5],orientation=[-65,85,0]); print(p3); end module: end use:
Figure 8
Construct the requisite rotation matrix
Write a sequence of the rotation angle and a vector along the axis of rotation; press the Enter key.
Context Panel: Student Linear Algebra≻Constructions≻Rotation Matrix
π/6,1,2,3
π6,123
→rotation matrix
13⁢328+114−314−3⁢1428+17−3⁢328+1414+314−314+3⁢1428+175⁢314+27−3⁢314−1428+37−3⁢328−1414+314−3⁢314+1428+375⁢328+914
Matrix Operators
Example 1: Matrix Norm Subordinate to Vector Norm
Obtain the Euclidean norm of the matrix A=123−1 and show that it is the maximum value of the Euclidean norm of the vector Av, where v is a unit vector.
Obtain the Euclidean norm of A
Control-drag the matrix A Context Panel: Student Linear Algebra≻Standard Operations≻Norm≻Euclidean
Context Panel: Simplify≻Simplify
123−1→Euclidean-norm152+292= simplify 292+12
Obtain the norm of Ax, where x is a unit vector
Write A times a unit vector and press the Enter key.
Context Panel: Assign to a Name≻f
123−1.x,1−x2
x+2⁢−x2+13⁢x−−x2+1
x+2⁢−x2+12+3⁢x−−x2+12
= simplify
5⁢x2+5−2⁢x⁢−x2+1
f
Maximize the norm of Ax
Write f and press the Enter key.
Context Panel: Differentiate≻With Respect To≻x
→differentiate w.r.t. x
10⁢x−2⁢−x2+1+2⁢x2−x2+12⁢5⁢x2+5−2⁢x⁢−x2+1
10⁢x−2⁢−x2+1+2⁢x2−x2+12⁢5⁢x2+5−2⁢x⁢−x2+1=0
x=1682−290⁢2958,x=−1682+290⁢2958
Evaluate f=Ax at each critical value of x
Expression palette: Evaluation template Evaluate at each of the two critical values.
fx=a|f(x)S1 = 152−25⁢2958−1682−290⁢29⁢12+5⁢295829= simplify −12+292
fx=a|f(x)S2 = 152+25⁢2958+1682+290⁢29⁢12−5⁢295829= simplify 292+12
Example 2: Matrix Norm and Singular Values
Show that the Euclidean norm of the matrix A=123−1 is the largest singular value of A, and the square root of the largest eigenvalue of ATA.
From Example 1:
Obtain the singular values of A
Control-drag the matrix A Context Panel: Student Linear Algebra≻ Eigenvalues, etc≻Singular Values
123−1→singular values292+12−12+292
Obtain the eigenvalues of ATA
Write the product AT.A. Context Panel: Evaluate and Display Inline
123−1%T.123−1 = 10−1−15→eigenvalues152+292152−292
Control-drag the larger of the two eigenvalues.
Select, and click a in the Expression palette
152+12⁢29 = 292+12
Vectors and Vector Operators
Example 1: Vector Angle, Dot and Cross Products
Determine the angle between the vectors u=i+2 j+3 k and v=3 i−7 j+5 k, then obtain their dot and cross products.
Context Panel: Assign to a Name≻u and v, as appropriate
1,2,3→assign to a nameu
3,−7,5→assign to a namev
Determine the angle between u and v
u,v = 123,3−75→angle betweenarccos⁡2⁢14⁢83581
Dot product
Cross product
Common Symbols palette: Dot product operator
Common Symbols palette: Cross product operator
u·v = 4
u×v = 314−13
Context Panel: Student Linear Algebra≻Standard Operations≻Dot Product (or Cross Product)
u,v = 123,3−75→dot product4
u,v = 123,3−75→cross product314−13
Example 2: Orthonormalization
Orthonormalize the columns of the matrix A=−8−49−6433−91, then form Q, a matrix with these orthonormalized vectors, and show that Q is an orthogonal matrix.
Control-drag the matrix A and press the Enter key.
Context Panel: Select Elements≻Split into Columns
−8−49−6433−91
→split into columns
−8−63,−44−9,931
−8⁢109109−6⁢1091093⁢109109,−42⁢6649664923⁢66496649−66⁢66496649,3⁢6161−6⁢6161−4⁢6161
−8⁢109109−42⁢664966493⁢6161−6⁢10910923⁢66496649−6⁢61613⁢109109−66⁢66496649−4⁢6161
Visualizing a Linear Transform
Example 1: Linear Transform Induced by a 2×2 Matrix
Visualize the effect of applying to unit vectors, the linear transformation determined by the matrix A=1234.
Access the Linear Transform Plot tutor through the Context Panel applied to the matrix A. The result is Figure 9.
Context Panel: Student Linear Algebra≻Tutors≻Linear Transform Plot
Figure 9
Return to Index for Example Worksheets
Download Help Document