A Geometric Review of Linear Algebra
Total Page:16
File Type:pdf, Size:1020Kb
A Geometric Review of Linear Algebra The following is a compact review of the primary concepts of linear algebra. I assume the reader is familiar with basic (i.e., high school) algebra and trigonometry. The order of pre- sentation is unconventional, with emphasis on geometric intuition rather than mathematical formalism. For a gentler introduction, I recommend The Appendix on Linear Algebra from the PDP book series, by Michael Jordan. For more thorough coverage, I recommend Linear Algebra and Its Applications by Gilbert Strang, Academic Press, 1980. Vectors (Finite-Dimensional) A vector is an ordered collection of numbers, known as the components of the vector. I’ll use the variable N throughout to represent the number of components, known as the dimension- ality of the vector. We usually denote vector-valued variables with an over-arrow (e.g., v). If we want to indicate the components, we often arrange them vertically (as a “column” vector): v1 v2 v = . , . vN v v3 v v Vectors of dimension 2 or 3 can be graph- 2 ically depicted as arrows, with the tail at the origin and the head at the coordinate lo- v2 cation specified by the vector components. v v 1 1 Vectors of higher dimension can be illus- trated using a “spike plot”. v1 v2 vN 2 The norm (or magnitude) of a vector is defined as: ||v|| = n vn, which has a value that is positive. Geometrically, this corresponds to the length of the vector (in 2 dimensions, this comes from the Pythagorean theorem). A vector containing all zero components has zero • Author: Eero Simoncelli, Center for Neural Science, and Courant Institute of Mathematical Sciences. • Created: 20 January 1999. Last revised: September 22, 2020. • Send corrections or comments to [email protected] • The latest version of this document is available from: http://www.cns.nyu.edu/∼eero/NOTES/ norm, and is called the zero vector. A unit vector is a vector of length one. In two dimensions, the set of all unit vectors may be parameterized in terms of their angle rel- ative to the horizontal axis: cos(θ) v ^ uˆ(θ)= . sin θ u sin(θ) Angular parameterization of unit vectors v θ can be generalized to N dimensions, but is cosθ much messier. 2v Multiplying a vector by a scalar simply changes the length of the vector by that fac- v tor. That is: || av|| = |a|||v|| . Multiplying by a negative number reverses the direction. The set of vectors corresponding to all rescal- v ings of a given vector form a straight line through the origin. Any vector (with the ex- ception of the zero vector!) may be rescaled to have unit length by dividing by its norm: vˆ = v/||v|| . Said differently, any vector may be factorized into a product of a scalar (its norm) and a unit vector (which characterizes its direction): v = ||v|| vˆ. The sum of two vectors of the same dimen- v translated sionality is a vector whose components are sums of the corresponding components of the summands. Specifically, y = w +v means w that: w+v zn = wn + vn, for every n Geometrically, this corresponds to stacking the vectors head-to-foot. v The inner product (also called the “dot product”) of two vectors is the sum of the pairwise product of components: v · w ≡ vnwn. n 2 Note that the result is a scalar. This operation has an equivalent geometric w definition, which allows for a more intuitive, geometric, interpretation: ø vw v · w ≡||v|| || w|| cos (φ ), vw v where φvw is the angle between the two vec- b tors. This is easy to prove in two dimen- b sions: write the two vectors as re-scaled unit w .v = . w . v vectors, write the unit vectors in terms of w their angle (as above), and then use the trig identity cos(θw)cos(θv)+sin(θw)sin(θv)= cos(θw − θv). This cosine is equal to b/||v|| in the figure to the right. Note that the inner product of two perpendicular vectors is 0, the inner product of two parallel vectors is the product of their norms, and the inner product of a vector with itself is the square of its norm. From the definition, you should be able to convince yourself that the inner product is distribu- tive over addition: v·(w +y)=v·w +v·y. And similarly, the inner product is also commutative (i.e., order doesn’t matter): v · w = w · v. Despite this symmetry, it is often useful to interpret one of the vectors in an inner product as an operator, that is applied to an input. For example, the inner product of any vector v with the vector: 1 1 1 1 w =(N N N ··· N ) gives the average of the components of v. The inner product of vector v with the vector w =(100 ··· 0) 3 is the first component, v1. v The inner product of a vector with a unit v vector uˆ has a particularly useful geometric interpretation. The cosine equation implies that the inner product is the length of the v component of lying along the line in the di- (v .u^)u^ rection of uˆ. This component, which is writ- u^ ten as (v · uˆ)ˆu,isreferredtoastheprojection of the vector onto the line. The difference (or residual) vector, v − (v · uˆ)ˆu, is the compo- nent of v perpendicular to the line. Note that the residual vector is always perpendicular to the projection vector, and that their sum is v [prove]. Vector Spaces Vectors live in vector spaces. Formally, a vector space is just a collection of vectors that is closed under linear combination. That is, if the two vectors {v,w } are in the space, then the vector av + bw (with a and b any scalars) must also be in the space. All vector spaces include the zero vector (since multiplying any vector by the scalar zero gives you the zero vector). A subspace is a vector space lying within another vector space (think of a plane, slicing through the 3D world that we inhabit). This definition is somewhat abstract, as it implies that we construct vector spaces by starting with a few vectors and “filling out” the rest of the space through linear combination. But we N have been assuming an implicit vector space all along: the space of all N-vectors (denotedR I ) 4 is clearly a vector space [verify]. Working backwards, a set of vectors is said to span a vector space if one can write any v1 vector in the vector space as a linear com- v3 bination of the set. A spanning set can be redundant: For example, if two of the vec- tors are identical, or are scaled copies of each other. This redundancy is formalized by defining linear independence. A set of vec- {v ,v ,...v } tors 1 2 M is linearly independent if v2 (and only if) the only solution to the equation αnvn =0 n is αn =0(for all n). A basis for a vector space is a linearly in- dependent spanning set. For example, con- sider the plane of this page. One vector is not enough to span the plane: Scalar multi- ples of this vector will trace out a line (which v v 2 is a subspace), but cannot “get off the line” v 2 1 v to cover the rest of the plane. But two vec- 1 v tors are sufficient to span the entire plane. 1 Bases are not unique: any two vectors will do, as long as they don’t lie along the same line. Three vectors are redundant: one can always be written as a linear combination of the other two. In general, the vector space N R requires a basis of size N. Geometrically, the basis vectors define a set of coordinate axes for the space (although e ˆ2 they need not be perpendicular). The stan- dard basis is the set of unit vectors that lie along the axes of the space: 1 0 0 e ˆ1 0 1 0 eˆ1 = 0 , eˆ2 = 0 , ... eˆN = 0 . . . . . . . 0 0 1 5 Linear Systems & Matrices A linear system S transforms vectors in one vector space into those of another vector space, in such a way that it obeys the principle of superposition: S{av + bw} = aS{v} + bS{w}. x a + S y b That is, the system “response” to any linear combination of vectors is equal to that same linear combination of the response to each of a the vectors alone. Linear systems are use- x S ful because they are very well understood (in particular, there are powerful tools for char- + acterizing, analyzing and designing them), and because they provide a reasonable de- scription of many physical systems. y S b The parallel definitions of vector space and linear system allow us to make a strong statement about characterizing linear systems. First, write an arbitrary input vector v in terms of the standard basis: v = v1eˆ1 + v2eˆ2 + ...+ vneˆN Using the linearity of system S,wewrite: S{v} = S{v1eˆ1 + v2eˆ2 + ...+ vneˆN } = v1S{eˆ1} + v2S{eˆ2} + ...+ vnS{eˆN }. 6 Input v That is, the response is a linear combination of the responses to each of the standard basis v1 x v1 x vectors. Each of these responses is a vector. v2 x v2 x Since this holds for any input vector v,the L v3 x v3 x system is fully characterized by this set of re- v4 x v4 x sponse vectors. Output We can gather the column vectors corresponding to the responses to each axis vector into a table of numbers that we call a matrix.