LinearAlgebra Visualization - 2
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 least squares approximations and eigenvectors. The companion worksheet, LinearAlgebra Visualization - 1, demonstrates the similar functionality for problems relating to vectors, planes, and linear systems.
For further information about the commands in the LinearAlgebra package, see the help page for that command. For a general overview, see LinearAlgebra.
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.
The following examples show how the various routines work.
Note: If you set either 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:
Visualizing the curve which best fits a given set of data in the least squares sense is accomplished through the LeastSquaresPlot command. By default, this command plots squares (2-D case) or rectangular solids (3-D case) at each of the data points, whose area or volume represents the fit error at that point.
Fitting curve: .8140e-1+.9663*x
Least squares error: 2.339
Maximum error: 1.447
To specify a non-linear fitting curve, use the curve option. Note: The unknowns in the problem (the coefficients of the curve) must appear only linearly in the curve expression.
Fitting curve: -3.782+6.841*x-2.230*x^2+.2328*x^3
Least squares error: .4797
Maximum error: .3109
The data points can be given as a list of 2- or 3-element lists (as in the above two examples), or as a pair or triple of lists, with each list giving the values for a given coordinate.
Fitting surface: 2.214+.5079e-1*x-.9917*y
Least squares error: 2.000
Maximum error: 1.674
To illustrate the concepts of eigenvalues and eigenvectors, the EigenPlot command shows the action of a given square matrix on a selection of unit vectors emanating from the origin. These image vectors are drawn with their tails at the tips of the corresponding input unit vectors (to prevent the plot from being too cluttered). The eigenvectors of the matrix are unit vectors whose images under the action of the matrix are collinear with the original vectors. In the following plot, there are 2 eigenvectors, which are drawn in red and blue (the default colors).
Eigenvector: < 1.309, 1. >
Eigenvector: < -.5093, 1. >
To see the input unit vectors as well, use the showunitvectors option.
Because the input vectors are unit vectors, the lengths and directions of the eigenvectors are determined by the corresponding eigenvalues. In the case of a 0 eigenvalue, the visual information about the corresponding eigenvector is therefore lost. To recover an indication of this, the eigenspaces are indicated by thin lines drawn in the same colors as the corresponding eigenvectors.
Eigenvector: < 0, 1 >
Eigenvector: < 1, 0 >
In the 3-D case, the eigenvectors corresponding to negative eigenvalues are shifted so that they remain outside the unit sphere. This reduces the visual clutter and allows you to see the action of the matrix more clearly.
Eigenvector: < 1, 0, 1 >
Eigenvector: < 0, 1, 0 >
Eigenvector: < 1/2, 1, 0 >
Note: This command plots only real eigenvectors. Also, a matrix may have fewer eigenvectors than its dimension. For either of these reasons the plot may show fewer eigenvectors than might otherwise be expected.
Eigenvector: < I, 1 >
Eigenvector: < -I, 1 >
Eigenvector: < 1, 0 >
Return to Index of Example Worksheets
Download Help Document