Vectors I: Generators

Basics of nD vectors

Basics of nD vectors

Vectors in have real number components:

Such vectors are added componentwise, and scalars multiply every component simultaneously. All the abstract operations and properties of vectors apply to vectors in :

  • Operations: addition and scalar multiplication,
  • Properties: commutativity, associativity, distributivity, zero vector.

There are standard basis vectors:

Decomposition works as in D:

Pairs of vectors in D also have dot products defined by summing component products:

The norm of an D vector is still .

Dot product still has the meaning of “relative alignment between vectors,” and can still be used to determine the angle between vectors using the cosine formula, . However, this angle is considerably less important in D.

Projection in D is very important. It is computed with the same formula:

We also have . Notice that now lives in the hyperplane perpendicular to . Given various and a fixed , the various are all parallel to , but the various are not all parallel to each other.

The Cauchy-Schwartz and Triangle inequalities become more important in D:

The vector formula for a line through in the direction of , namely , still works in D. However, the formula for a plane:

determines a hyperplane in D, meaning an D space inside of . We could write this space in scalar form as

where:

Link to original

Spans

Spans

Linear combinations of vectors in D work just as in D:

A span is a collection of all vectors which could be obtained as linear combinations of certain given vectors. For example, the collection of all possible that can be written as above, for any , in terms of the given at the outset, is called either of:

It is still an important fact that a span passes through the origin . This is because linear combinations do not include a constant term, so the point can always be achieved by setting for all .

Link to original

Example

Computing a span by hand

Computing a span by hand

Consider the vectors and .
Problem: Show that the set of vectors perpendicular to both and is a span.

Solution: Let be an arbitrary vector such that . By writing these dot products using components, we find a system of two equations:

Solve for and in terms of the others:

Now, we can let , , and take any value, and using these equations we can specify and to guarantee that the system of equations is valid, implying that . Conversely, given values of , , and , these equations fully determine the only possible values of and . Therefore, the set of possible is given by varying , , and in the vector:

Observe that this vector can be written as the linear combination , with

So indeed the set of vectors perpendicular to and is the span .

Link to original

Spans (part 2)

Convex combinations
A convex combination of vectors is a linear combination with a certain constraint on the coefficients:

Link to original

Subspaces

Subspaces

A subspace is any collection of vectors that satisfies the rules of a vector space, meaning the operations and properties. Since the properties automatically hold for vectors from the original space, the key point is that a subspace is a collection of vectors including the origin, all of whose linear combinations are still in the subspace.

Symbolically: if is any subset of vectors containing , and if automatically whenever , then is a subspace.

Link to original

Question

01

Subspaces

Suppose a set satisfies the symbolic hypothesis above:

Show that any linear combination of vectors from must lie in .

Link to original

Exercise

01

Subspaces given by perpendicularity

Let be defined as the set of vectors which are perpendicular to the given set . Show that is a subspace.

Link to original

Subspaces (part 2)

To say that is a subspace is to say that is a vector space in its own right, even though vectors in may also live in a bigger space.

Link to original

Example

Simple subspaces of n-dimensional space

Simple subspaces of

Let be the collection of all possible vectors , meaning that the final term is always zero, and the other terms can be anything.

This set is a subspace because it contains , and any linear combination will still have a zero in the final component, so it lies in .

Link to original

Question

02

Iterating from to

How many distinct subspaces of can you describe using the general idea of the previous example?

Link to original

Spans and subspaces

Spans and subspaces

A span is always a subspace: it contains , and any linear combination of some vectors in a span can be written as a linear combination of the original vectors defining the span (by expanding each vector in terms of the original vectors, and then collecting like terms).

The converse is also true: any subspace is the span of some vectors. This is not so easy to prove! Here is the proof:

Why every subspace is a span

We consider by using the first components, setting the last components to zero. We prove that if we assume every subspace of is a span, then every subspace of must also be a span. (The result will follow because it is clearly true for , and we can use this fact to build up to one dimension at a time.)

So we assume that every subspace of is a span. Now suppose is any subspace. Consider the last components of vectors . If all of these last components are zero, then actually , and by the assumption, it is a span.

Suppose, on the other hand, that at least one vector has a last component . Now we create the subspace defined as

The collection is a subspace of , so it is a span by the assumption, and we can find a generating set of vectors:

Now we propose the following key fact:

To prove this, let be any vector. If , then , so it is in the proposed span above. If , then consider the vector . This vector has zero in the last component. So , which can be expanded as a linear combination of . By vector algebra, , and we can substitute the expansion of to see that is in the proposed span.

The difference between the concept of span and the concept of subspace is a matter of connotation. When working with a ‘span’, we have in mind a collection of vectors that generates the span using linear combinations. When working with a ‘subspace’, we have in mind the abstract rules of vector spaces.

Incidentally, the above proof shows that any subspace of can be written as the span of or fewer vectors.

Link to original

Dimension

Dimension

The dimension of a subspace , written , is the smallest possible number of vectors needed to span .

This definition is very intuitive: a space has dimensions if different numbers are needed to locate every item in the space. These numbers are the coefficients of the spanning vectors in a minimal spanning set for the space.

The definition can also be hard to work with in a rigorous way. How could we prove that a given space could not be spanned by an ever smaller number of vectors?

For example, of course should be -dimensional. That is why we have been saying “D.” Of course it is spanned by the standard basis vectors . But how do we know it cannot be spanned by a smaller number?

In the next section the concept of independence will be developed to handle this question more generally. However, it is worthwhile practice with the general theory of spans to demonstrate this fact by learning about Steinitz Exchange:

Showing is -dimensional: Steinitz Exchange Process

Suppose some set with only vectors could span with , so:

This means that . Then it turns out we can “exchange” for one of the :

where the notation means some subset of with only elements, but we don’t care which is which. The reason we can do this is important: since , we can write a linear combination

with at least one . The equation can be solved for using the other vectors in the equation, and therefore every vector in can be expressed as a linear combination of those other vectors in the equation. But that is the meaning of “.”

Now iterate this process: we can exchange for another vector out of :

The reason we can do this is similar, but with a slight twist. As before, write a linear combination:

This time, however, we know that at least one of is nonzero, say , because there is no way to generate using combinations of alone. So we solve for using the other vectors in the equation. This means we can eliminate from the spanning set, provided we add in .

Now iterate the process times, replacing some at each successive stage with a new vector , observing that the linear combination for could not involve nonzeros only on the other .

After iterations, we have . This is impossible! Since , there is no way to get nonzero entries in components higher than .

Link to original

Vectors II: Independence

Independence

Independence

A collection of vectors is called independent when the only solution to the equation

is given by setting for every .

Link to original

Question

01

Independence vs. dependency equations

Prove the statement:

The collection is dependent (i.e. not independent) if and only if at least one of the vectors can be written as a linear combination of the others, i.e. one of them is in the span of the others.

Link to original

Example

Dependent columns implies non-invertible

Dependent columns implies non-invertible

If a square matrix has column vectors which form a dependent set, then the square matrix is not invertible.

Proof: Let be numbers giving the dependency relation. These numbers can be combined into a vector . Then:

However, since the are not all zero, we know , and therefore sends something nonzero to zero, which means it cannot be invertible. (Otherwise, what would be the preimage of zero?)

Link to original

Independence (part 2)

Independence and dimension
Recall that the dimension of a subspace is equal to the smallest number of vectors needed to span the subspace.

If a set of vectors has the smallest number that spans whatever they span, then this set is independent. (If there is any dependency relation, then a smaller set will have the same span: just eliminate the dependent vector.)

Conversely, if some vectors are independent, then they are automatically the smallest number that spans their span:

Theorem: Independent vectors span their span minimally

Let be the subspace spanned by the set of vectors , and suppose the set is independent. Then any set of vectors spanning must have at least elements.

Proof

We use Steinitz Exchange but with in place of . Suppose for other vectors . Our goal is to show that .

First, since , we know there is a linear combination

with at least one coefficient . Solve for in terms of the others in this equation to obtain the fact that , where we introduce the labels with for whichever vectors are left from after removing .

By iterating this process, we obtain

and this is only possible if .

(Notation: here stands for with ticks, just as for higher derivatives.)

We are able to iterate the process because the vectors are independent: at each stage, the next can be written as a linear combination of the previous () and some other . But the coefficient on at least one of the must be nonzero, otherwise we have written in terms of alone, and that is impossible by independence.

Link to original

Exercise

01

Understanding independence

Explain in more detail why we can iterate the process because the are independent. Specifically compare the reason it works here with the reason it worked for the in the Steinitz Exchange at the end of the section on dimension.

Link to original

Question

02

Completing the logic

Explain in more detail the statement: “and this is only possible if .” Why is this statement true? What would happen if ?

Link to original

Example

Independence

Independence

Problem: Is the following set of vectors dependent or independent?

Solution: It must be a dependent set. These vectors live in , which is spanned by . If these vectors were independent, then we could use Steinitz Exchange to write as the span of just three of them. Since the fourth is also in , it could then be written as a combination of the other three, contradicting independence.

Link to original

Basis

Basis

A basis for is a set of independent vectors which span the entire subspace .

For example, the standard basis is a basis for the whole space .

The criterion of independence is a function of the relationships between the vectors in the set. The criterion of spanning also depends upon what other vectors there may be in the subspace.

(Independence is an intrinsic concept, whereas spanning the subspace is an extrinsic concept. These are not precise mathematical terms.)

Any set of vectors spans a certain subspace, namely the span itself. Therefore any independent set of vectors is a basis for its own span.

Because an independent set of vectors is always the minimal number needed to span its span (the theorem above), and a basis for a given space is an independent set of vectors spanning the subspace, every basis for a given subspace has the same number of vectors. (Since every basis has the minimal number needed to span the given subspace.) This number as the dimension of the subspace.

The most important way to think about and use the concept of basis is this: Given a basis for a subspace , every vector in can be obtained uniquely as a linear combination of basis vectors:

(Here ‘unique’ means that the coefficients are uniquely determined by .)

From this way of thinking about a basis, we see that the dimension is the number of quantities that are needed to describe everything in the space without redundancy.

Link to original

Example

3 vectors spanning 3D space must be independent

3 vectors spanning 3D space must be independent

In Problem 05-02, we saw that the span

is a 3-dimensional subspace of . (In fact it is , since the Steinitz Exchange will put all three in the same span as this.) Therefore we know the vectors are independent, because there are three vectors spanning a 3D space.

Link to original

Basis (part 2)

Orthonormal systems, orthonormal bases
A collection of vectors is called an orthonormal system when they are:

  • unit vectors, meaning for all
  • pairwise orthogonal, meaning when

If the collection is also a basis, then it is called an orthonormal basis.

Vector components in a given basis
The typical application of a basis is to write other vectors as its linear combinations. Since a basis spans the whole space, every other vector in the space can be written using some set of coefficients. Since a basis is linearly independent, there is a unique set of coefficients that will generate a given vector.

For example, if is a basis of a subspace , which incidentally therefore has dimension , then we can write any by:

Using such linear combinations to express vectors , we find a unique association between a vector and the quantities which express that vector in terms of the . We can group those quantities into a list . The terms are called the components of in the basis .

The ordinary component entries of a vector are actually just the components of the vector in the standard basis. (Think about this!)

Link to original

Vectors III: Orthogonality

Introduction

Subspaces of are extremely important. For example, if represents the number of pixels in an image, a vector might represent an image. The number is very large, and even computers can take a (relatively) long time to perform operations on vectors in such as multiplying matrices to compose linear transformations.

Frequently a given dataset will belong (or ‘nearly’ belong) to a subspace of of much smaller dimension. It is very useful to be able to describe and work with vectors in such a subspace in an efficient way. This typically means finding a good basis. A good basis should be easy to work with, and it should have a useful interpretation.

Link to original

Orthogonal bases

Orthogonal bases

An orthogonal basis is simply a basis in which the vectors are pairwise perpendicular, meaning for . It is very easy to tell if a basis is orthogonal: just compute all pairwise dot products. This is a central reason that orthogonal bases are very popular.

If a basis is orthogonal, there is a very fast way to find the components of any given vector in this basis. Suppose , meaning is a vector in the subspace of . Suppose that is -dimensional with orthogonal basis . The components of in this basis are by definition the unique coefficients in the linear combination:

Now, take the dot product of both sides with , for any given , using the fact that unless :

so

Summarizing:

Finding components in an orthogonal basis

Given an orthogonal basis, the components of are given by the formulas:

If is not only orthogonal but also orthonormal, then the components are even simpler:

The fact that components are so easy to calculate for orthogonal bases is one of their most important features, and frequently is the main reason they are used.

Link to original

Question

01

Orthogonal vectors, finding components

Show that the set of vectors is orthogonal:

and then compute the components of in the basis .

Link to original

Orthogonal bases (part 2)

The above method can be written out succinctly in what is sometimes called the Fourier expansion formula:

A simple observation shows another advantage of orthogonal sets of vectors – that they are automatically independent:

Orthogonal vectors are automatically independent

Suppose that is an orthogonal set.

Assume hypothetically that .

By dotting both sides with any , we see that , so we must have (because since we assume ). This can be done for any , so in fact for all .

Therefore is an independent set of vectors.

Link to original

Projection

Projection

Projection and orthogonal bases
Recall the projection formula:

So is just the scalar coefficient of the projection of onto (sometimes called the ‘scalar projection’).

Using this fact, we could equally write a vector as a decomposition according to an orthogonal basis using a sum of projections to the basis elements:

Projection to a subspace
The projection formula for provides the closest vector to that is on the line spanned by , and the difference is perpendicular to . Furthermore, does not depend on the length of at all, in fact it only depends on the subspace spanned by , which is a line. Therefore, could really be called where is the subspace spanned by .

It is extremely useful to be able to compute the projection of a vector onto any subspace . This result should be the unique vector inside which is closest to . It is also the unique vector such that the displacement is perpendicular to (meaning: perpendicular to every vector in ).

Now suppose that we have an orthogonal basis of . We can define the projection of onto the subspace in terms of this basis:

Projection of to a subspace

  • Notice that is a linear combination of basis vectors. (Consider the separate formulas for .) Therefore it lies inside the subspace . We might have though, because here we do not assume that .

  • In addition, using this formula we can deduce that the displacement vector is perpendicular to every vector in : Consider the dot product against any basis vector :

    So for all . Any element of can be written as a linear combination of the basis vectors , so is perpendicular to any vector in .

Link to original

Question

02

Perpendicularity to a subspace

Explain and justify in more detail the last statement: “ for all ” implies “ for all .”

Link to original

Projection (part 2)

To summarize, orthogonal bases allow us to:

  • Easily calculate the components of any vector in the orthogonal basis
  • Formulate the projection of any vector onto a subspace using an orthogonal basis of the subspace
Link to original

Gram-Schmidt process

Gram-Schmidt process

In this section, we learn a procedure to create an orthogonal basis of a given subspace, starting only with some vectors that are known to generate the subspace as their span. If the original vectors are not independent, we will discover that fact along the way, and possibly wind up with a smaller number of vectors.

center
Let us illustrate the process with a span of three vectors . We do not assume they are independent.

  • Write .
  • Exchange for . Since is a linear combination of and , and is a linear combination of and , we know . Furthermore, and are orthogonal.
  • Now exchange for , where . Since is a linear combination of and items in , we know , and is orthogonal to everything in .

We conclude with , where the unless . So these vectors are orthogonal.

Link to original

Question

03

Dependence?

What happens in the above Gram-Schmidt process if is a dependent set?

Link to original

Example

Gram-Schmidt illustration for 3 vectors

Gram-Schmidt illustration for 3 vectors

Problem: Use the Gram-Schmidt process to find an orthogonal basis for the following span:

Solution: We first define . Then compute :

and therefore . At this point we have . Since we are just trying to preserve the span, it is convenient to change the definition of to by multiplying it by . This won’t change the span, and we eliminate the fractions.

Finally compute . Since , and this is actually an orthogonal basis for , we can use the formula for that splits it into components according to the orthogonal basis:

Therefore , and we can scale this up as with and use instead . So we have an orthogonal basis:

Link to original

Exercise

01

Gram-Schmidt practice

Perform Gram-Schmidt to find an orthogonal basis of the subspace:

Link to original

Gram-Schmidt process (part 2)

General Gram-Schmidt process

The Gram-Schmidt process can be continued in the same way for more than three vectors. Here is the general rule, in the abstract, for :

  • Set .
  • Write .
  • Set .
    • First step: use .
    • We know that by considering each formula .
    • We know that when (orthogonality of the we are building).
    • Therefore we compute using: .
  • Repeat with the next step .
  • Produce a new list of vectors with .
    • If the original vectors were independent, then we never have for any .
    • If there is some redundancy in , then at some point and .
    • We can detect this and throw out any from the final list to obtain truly independent vectors , none of which is zero.
    • The dimension of the space is then , then number of nonzero items we obtained.
Link to original

Application: distance from point to subspace

Application - distance from point to subspace

Many applications of linear algebra involve the measure of distance from a given vector to a subspace that does not include the vector. Typically the subspace is known as the span of a list of given vectors.

Suppose and is a subspace, given as the span of the vectors .

Here is a standard solution to the problem of finding the distance from to :

  • First use Gram-Schmidt to produce an orthogonal basis of . It’s possible that .
  • Now compute the projection .
  • The orthogonal part is a vector from straight to .
  • is the distance from to .
Link to original

Example

Computing distance of point to subspace

Computing distance of point to subspace

Problem: Find the closest point on the subspace given by the span

to the vector .

Solution: Label the vectors in the span , in order. Notice that they are already pairwise orthogonal, so we can skip Gram-Schmidt. Then compute :

Therefore

and the length of this vector is , which is our answer.

Link to original

Application - distance from point to subspace (part 2)

Basic linear regression as projection

Linear regression: projection of dependent data vector to subspace of “best fit lines”

Basic linear regression is essentially an application of the above idea. Later we will focus on the details for a more general version; here is a preview summary:

  • Data is given by vectors and matching input to output by the order of components. If there are data pairs , then will have components.
  • The line of best fit should have the form . We seek and , as well as the correlation coefficient which expresses how close the data is to the best fit line. It is specifically the sum of the square distances from each component, i.e. each data pair.
  • The span is all vectors of the form . These vectors encode outputs of the possible fit lines evaluated at the input data .
  • The best fit line is where is the closest vector to in the span .
    • Convert to the orthogonal basis . Here where is the average of the components of .
    • Compute .
    • Define as the coefficients and .
    • Therefore we have , so then , and we have found and .
  • The distance determines the correlation . The absolute distance is divided by the relative length of to get a scale-invariant number. The final formula is: center
Link to original

Exercise

02

Computing a best fit line

Following the steps above, compute the best fine line (i.e. compute and ) for the data used in Problem 05-03:

In Problem 05-03, you already found and , and implicitly and .

Link to original

Application - distance from point to subspace (part 3)

[optional] Derivation of correlation coefficient formula

Here we verify that

First, since , it is sufficient (confirm this for yourself!) to show that

Since and are chosen to give the closest vector to via projection, we know:

where we have used the fact that , as well as the fact that and is perpendicular to so it can be dropped from the penultimate projection. (Confirm this for yourself!)

Finally, we know that and are perpendicular. (The former lies in the span of and the latter is perpendicular to this span.) Therefore

and by plugging in we see .

Link to original