Notebook 3 – Math 2121, Fall 2020

In today's notebook we'll try to get some feeling for vectors in R2 and R3 and their linear combinations. We'll also think about what a solution to a vector equation means. The code here involves a lot of new plotting functions in Julia.

1.3 ms

Running this notebook (optional)

If you have Pluto up and running, you can access the notebook we are currently viewing by entering this link (right click -> Copy Link) in the Open from file menu in Pluto.

2.3 ms

Vectors in R2

Let's start out by drawing some vectors in R2.

15.7 μs

Create some vectors in R2

u1 = v1 = w1 =

u2 = v2 = w2 =

138 μs

The vectors we created:

9.7 μs
u = [ 6.7]     v = [  -5]     w = [  10]
    [-3.7]         [-5.1]         [ -10]
57.9 μs

Display: u v w

87.1 μs
7.3 ms

The vector u is shown in blue, v in orange, and w in green.

The right hand graph shows the sum of the displayed vectors on the left as the solid arrow. The dotted arrows are just copies of u, v, and w moved around.

11 μs

Linear combinations

Now that we have chosen some vectors u, v, w, let's think about the meaning of the linear combination au+bv+cw where a,b,cR are scalars.

9.1 μs

Choose some scalars in R

a = b = c =

93.8 μs

The scalars we chose:

8.5 μs
a = -1.4     b = -2.1     c = 0
42.7 μs
7 ms

Varying a among positive values scales the length of the arrow that represents the vector u.

If a is negative then this scalaing reverses the direction of u.

The same thing happens to the arrows representing v and w when we change b and c.

24.1 μs

Vector equations

Let's now think of a,b,c as the variables x1=a and x2=b and x3=c.

Choose a target vector t=[t1t2]R2.

What does a solution to the equation x1u+x2v+x3w=t mean?

We know that the solutions x=[x1x2x3] to this equation are the same as the solutions to the linear system whose augmented matrix is A=[u1v1w1t1u2v2w2t2].

16 μs

Let's create a random target vector t.

7.9 μs
target
2×1 Array{Float64,2}:
  1.0
 15.4
13.6 μs

Here's our coefficient matrix.

8.3 μs
coefficient_matrix
2×3 Array{Float64,2}:
  6.7  -5.0   10.0
 -3.7  -5.1  -10.0
52 μs

Here's our augmented matrix.

9.5 μs
augmented_matrix
2×4 Array{Float64,2}:
  6.7  -5.0   10.0   1.0
 -3.7  -5.1  -10.0  15.4
8.5 μs

To solve the corresponding linear system we compute RREF(augmented_matrix).

9.9 μs
rref
2×4 Array{Float64,2}:
 1.0  0.0  1.917600151889121   -1.3651034744636414
 0.0  1.0  0.5695842035314223  -2.02923865578128
8 μs

For typical values of t, the pivot positions are (1,1) and (2,2).

This means x1 and x2 are basic variables and x3 is a free variable.

To get a solution, choose any value for x3, then solve for x1, x2.

9.8 μs
free_variable_value
0
1.5 μs
solution
18.4 μs

The meaninng of this solution is that if we set x1, x2, and x3 to the corresponding values, then the linear combination x1u+x2v+x3w should match up with the target vector t.

We can see this visually below.

11.1 μs

x1 = x2 = x3 =

10.9 μs
x1 = -1.4     x2 = -2.1     x3 = 0
33.3 μs
5.3 ms

Vectors in R3

Let's also try to visualize vectors in R3 and think about their span.

This is a little more challenging to display.

10.2 μs

Display parameters (changing these rotates our view):"

phi = 0

psi = 0

111 μs

Create some vectors in R3

v1 = w1 =

v2 = w2 =

v3 = w3 =

139 μs

The vectors we created:

10.1 μs
v = [   9]     w = [   0]
    [   0]         [  20]
    [   5]         [   7]
63.9 μs

show shadows in xy-plane:

45.3 μs

draw span:

65.2 μs
55.3 μs
34.2 ms

The left picture shows that vectors v and w.

The right picture shows their sum.

We can also display the span of the two vectors, denoted R-span{v,w}.

For different inputs, we can get R-span{v,w} to be either a plane, a line, or a single point.

11.9 μs

Some remarks

Of course, these pictures are not actually in R3!

On a flat surface like this screen, we can only draw vectors in R2.

Secretly, we are drawing many vectors R2 to simulate the appearance of R3. If we erase those extra vectors and display the usual axes, the plots below are what we are actually showing.

43.8 μs
5.8 ms

How are these vectors in R2 computed from v and w, which we chose to be in R3?

Some kind of transformation is used to change vectors in R3 to vectors in R2 that we can display. We'll talk about these kinds of transformations next lecture.

10.2 μs