LinearAlgebra Visualization - 1
The visualization component of the Student[LinearAlgebra] subpackage contains routines that can be used to work with and visualize various concepts in an introductory linear algebra course. This worksheet demonstrates the basics of this functionality for problems involving vectors, planes, and linear systems. The companion worksheet, LinearAlgebra Visualization - 2, demonstrates the similar functionality for problems relating to least squares approximation and eigenvectors.
For further information about the commands in the LinearAlgebra package, see the help page for that command. For a general overview, see LinearAlgebra.
Getting Started
Commands in the package can be referred to using the long form, that is, Student[LinearAlgebra][EigenPlot].
It is recommended to load the package first and then use the shorter command names.
restart
withStudentLinearAlgebra:
The following examples show how the various routines work.
Note: If you set infolevel[Student] := 1 or infolevel[Student[LinearAlgebra]] := 1, many of the routines in this package provide additional information about the objects they are passed in the form of userinfo messages. This setting is recommended.
infolevelStudentLinearAlgebra≔1:
Vectors and Planes
Vector Sum
The VectorSumPlot command displays the sum of a collection of vectors. The sum is displayed graphically by connecting the head of each vector in the collection to the tail of another vector in the collection. As there are many ways to form these connections, the routine by default displays all connections, effectively producing a lattice whose edges can be followed from the origin to the point that corresponds to the sum. By default, the sum vector is drawn in black.
VectorSumPlot⁡1,12,13,−1
sum = <4/3, -1/2>
VectorSumPlot⁡1,0,0,0,−1,0,0,0,1
sum = <1, -1, 1>
Alternatively, an animation showing the possible paths one at a time can be requested.
To run any of the animations in this worksheet:
Click the plot. The plot toolbar is displayed.
In the toolbar, click the Play button.
Alternatively, right-click (Control-click, on Mac) the plot to display the context menu. Select Animation > Play.
VectorSumPlot⁡1,0,0,0,−1,0,0,0,1,output=animation
Cross Product
The cross product of 2 vectors can be displayed using the CrossProductPlot command. By default, the result is colored magenta.
CrossProductPlot⁡1,−1,12,0,2,−1
<1, -1, 1/2> &x <0, 2, -1> = <0, 1, 2>
The visualization commands in the Student[LinearAlgebra] subpackage allow you considerable control over the appearance of the resulting plot. Some controls are associated with particular components of the plot. For example, the colors of the vectors in a CrossProductPlot can be adjusted.
CrossProductPlot⁡1,−1,12,0,2,−1,vectorcolors=green,cyan,yellow
Other controls are global in nature.
CrossProductPlot⁡1,−1,12,0,2,−1,orientation=−50,50,title=Cross product with orientation and view specified,view=−3..3,−3..3,−3..3
Planes
To visualize planes and their related vectors in three dimensions, the Student[LinearAlgebra] package provides the PlanePlot command. This command allows you to specify a plane in different ways. It also displays the plane and, optionally, a normal vector, a pair of basis vectors, a vector to a point on the plane from the origin, and the vector from the origin to the closest point on the plane to the origin.
For example, you can specify the plane by specifying its normal vector and a point on it.
PlanePlot⁡−1,12,1,−1,−1,−1
normal vector: <-1., .5000, 1.> equation of plane: -1.*x+.5000*y+1.*z = -.5000 point on plane nearest origin: <.2222, -.1111, -.2222> basis vectors: <.5774, 1.617, -.2309>, <1.155, -.2309, 1.270>
To see a pair of vectors that form a basis for the plane (when added to the specified point), use the showbasis option.
PlanePlot⁡−1,12,1,−1,−1,−1,showbasis
The plane can also be specified via a set or list of Vectors (the basis), a Vector-valued function of two parameters, or as an equation or algebraic expression in 3 variables. In either the normal vector form or the basis vectors form, if a point on the plane is not specified, then the plane passes through the origin.
PlanePlot⁡1,−1,1,1,0,−2
normal vector: <.8944, 1.342, .4472> equation of plane: .8944*x+1.342*y+.4472*z = 0. point on plane nearest origin: <0., 0., 0.> basis vectors: <1., -1., 1.>, <1., 0., -2.>
PlanePlot⁡s,t→1,1,1+s⁢−1,0,2+t⁢0,1,1,showbasis,basisoptions=color=black,orientation=100,125
normal vector: <1.095, -.5477, .5477> equation of plane: 1.095*x-.5477*y+.5477*z = 1.095 point on plane nearest origin: <.6667, -.3333, .3333> basis vectors: <0., 1.225, 1.225>, <-.7746, 0., 1.549>
In the equation or algebraic form, the variable names must be specified unless there are exactly 3 such names in the first argument.
PlanePlot⁡2⁢y+3⁢z=2,x,y,z,showpoint=false
normal vector: <0., 2., 3.> equation of plane: 2.*y+3.*z = 2. point on plane nearest origin: <0., .3077, .4615> basis vectors: <-.5547, .6923, -.4615>, <-.8321, -.4615, .3077>
Projections
Projecting vectors onto lines and planes is a common and important operation. To visualize this operation, use the ProjectionPlot command.
ProjectionPlot⁡1,12,−12,13
Vector: <1, 1/2> Projection: <.4615, -.3077> Orthogonal complement: <.5385, .8077> Norm of orthogonal complement: .9707
By default, the plot displays the vector being projected, the line or plane onto which it is being projected, the projected vector, and the projection onto the orthogonal complement of the projection line or plane. Furthermore, dashed lines from the head of the input vector to the heads of its projections onto the line or plane and its projection onto the corresponding orthogonal complement are drawn. Using various show... options you can suppress these components and optionally request that the vector or vectors used to define the projection line or plane be shown.
ProjectionPlot⁡1,12,−12,13,showbasis=true,showlines=false
A plane to be projected on is specified as a set or list of vectors. Note: An option of the form option_name = true can be abbreviated to option_name.
ProjectionPlot⁡2,−1,3,32,1,12,−13,1,−18,showbasis
Vector: <2, -1, 3> Projection: <2.704, -1.023, .9336> Orthogonal complement: <-.7045, .2348e-1, 2.066> Norm of orthogonal complement: 2.183
Linear Systems
Solutions of Linear Systems
Solving a linear system involves finding the set of points that simultaneously satisfy all the equations of the system. In 2-D space, this solution is one of the empty set, a point, or a line. In 3-D space it can be any of those, or a plane. By displaying a plot of the input equations, which represent lines or planes, the physical interpretation of this solution becomes clearer. For a 2-D plot, little more is required.
LinearSystemPlot⁡x+y=1,2⁢x−3⁢y=12
The solution is the point <.7000, .3000>
LinearSystemPlot⁡x−y=1,2⁢x−2⁢y=1
The solution is the point <.3000, -.3000>
In three dimensions, the solution to the system may not be apparent from the first presentation of the plot. However, by clicking on the plot and dragging with the mouse, you can manipulate the plot to get a better view. In the default presentation of the following system, one of the planes may appear as a line. Drag the plot to see all 3 planes and their common point of intersection more clearly.
LinearSystemPlot⁡x+y+z=1,1−2⁢y+z=3,x−y=0
The solution is the point <-.2500, -.2500, 1.500>
The input linear system can also be specified as a Matrix/Vector pair, or as an augmented Matrix.
LinearSystemPlot⁡1,2|3,−1|0,1
The solution is the point <.4286, -.1429>
The dimensionality of the system (2x2 or 3x3) is normally determined from the system. In the case of a system specified by a set of equations, you can force the dimensionality to be higher than the apparent dimensionality by specifying the full set of variable names in a list.
LinearSystemPlot⁡x+1⁢y2=1,x,y,z,axes=normal
The solution is the plane -1.*a-.5000*b = -1.
Linear Transformations
The Student[LinearAlgebra] subpackage provides two commands that can be used to visualize the action of a linear transformation. The first, LinearTransformPlot, displays domain and range objects in a single plot. The domain object is a line segment, circle, or sphere, as determined by the column dimension of the matrix, while the range object is the image of the domain object under the action of that matrix.
LinearTransformPlot⁡1,2|1,−1
Rank: 2 Norm: 2.303 Determinant: -3 Eigenvalue: 3^(1/2) Multiplicity: 1 Eigenvector: < 1.366, 1. > Eigenvalue: -3^(1/2) Multiplicity: 1 Eigenvector: < -.3660, 1. >
LinearTransformPlot⁡1,2,3|4,5,6|7,8,9,showeigenvectors=false,nullspaceoptions=thickness=3,color=black,spheregrid=10
Rank: 2 Norm: 16.85 Determinant: 0 Eigenvalue: 15/2+3/2*33^(1/2) Multiplicity: 1 Eigenvector: < .6856, .8425, 1. > Eigenvalue: 15/2-3/2*33^(1/2) Multiplicity: 1 Eigenvector: < -2.183, -.5928, 1. > Eigenvalue: 0 Multiplicity: 1 Eigenvector: < 1, -2, 1 >
The second command, ApplyLinearTransformPlot, can be used to show the action of a given linear transformation as applied to different domain objects. These input objects can be any of a regular set of objects (circle, square, sphere, cube, or grid) or an arbitrary plot object. The default object is a circle in the 2-D case and a sphere in the 3-D case. Also, by default, 4 successive applications of the transformation are applied (where the input at each step after the first is the output from the previous step).
ApplyLinearTransformPlot⁡1,2|−1,1
Determinant: 3 Norm: (7/2+1/2*13^(1/2))^(1/2) Eigenvalue: 1+I*2^(1/2) Multiplicity: 1 Eigenvector: < .7070*I, 1. > Eigenvalue: 1-I*2^(1/2) Multiplicity: 1 Eigenvector: < -.7070*I, 1. >
p:=plot⁡sin⁡x,x=−π..π;p
ApplyLinearTransformPlot⁡1,12|−13,−12,p
Determinant: -1/3 Norm: (29/36+1/36*697^(1/2))^(1/2) Eigenvalue: 1/4+1/12*57^(1/2) Multiplicity: 1 Eigenvector: < 2.757, 1. > Eigenvalue: 1/4-1/12*57^(1/2) Multiplicity: 1 Eigenvector: < .2417, 1. >
This command can also produce animations.
ApplyLinearTransformPlot⁡12,0,1|0,−1,12|−13,12,0,output=animation
Determinant: -11/24 Norm: RootOf(576*_Z^3-1648*_Z^2+1116*_Z-121,index = 3)^(1/2) Eigenvalue: -1/6*(58+2*787^(1/2))^(1/3)-1/(58+2*787^(1/2))^(1/3)-1/6 Multiplicity: 1 Eigenvector: < .1983, -2.752, 1. > Eigenvalue: 1/12*(58+2*787^(1/2))^(1/3)+1/2/(58+2*787^(1/2))^(1/3)-1/6+1/4*I*3^(1/2)*(-1/3*(58+2*787^(1/2))^(1/3)+2/(58+2*787^(1/2))^(1/3)) Multiplicity: 1 Eigenvector: < .1780-.5844*I, .3238+.1260*I, 1. > Eigenvalue: 1/12*(58+2*787^(1/2))^(1/3)+1/2/(58+2*787^(1/2))^(1/3)-1/6-1/4*I*3^(1/2)*(-1/3*(58+2*787^(1/2))^(1/3)+2/(58+2*787^(1/2))^(1/3)) Multiplicity: 1 Eigenvector: < .1780+.5844*I, .3238-.1260*I, 1. >
To see the action of the transformation more clearly, use the iterations and trace options. If the norm of the matrix is large, use the logscale option.
ApplyLinearTransformPlot⁡1,12|−13,35,output=animation,iterations=20,trace=4
Determinant: 23/30 Norm: (1549/1800+13/1800*2929^(1/2))^(1/2) Eigenvalue: 4/5+1/30*I*114^(1/2) Multiplicity: 1 Eigenvector: < .4000+.7116*I, 1. > Eigenvalue: 4/5-1/30*I*114^(1/2) Multiplicity: 1 Eigenvector: < .4000-.7116*I, 1. >
Return to Index of Example Worksheets
Download Help Document