2.1 Vectors¶
Operations¶
Vector Addition¶
The addition of vectors occurs component-wise. For two vectors in \(\mathbb R^4\):
If two vectors have a different number of components, they cannot be added or subtracted.
Scalar Multiplication¶
Suppose we take a real number \(r\). We can multiply a vector by this scalar by multiplying each component of the vector by \(r\). For example, if \(r = 3\), then:
Vector Subtraction¶
To substract \(\vec v - \vec u\) we add \(\vec v\) to \((-1)\vec u\).
Clearly, like addition, we are subtracting component-wise.
MATLAB and Vectors¶
Let’s create the vectors used in the above examples.
v = [3 ; -1 ; 2 ; 9]
u = [4 ; 5 ; -2 ; -5]
v =
3
-1
2
9
u =
4
5
-2
-5
Addition and subtraction work exactly as you would guess.
v + u
ans =
7
4
0
4
v - u
ans =
-1
-6
4
14
Scalar multiplication also makes sense, for example, if \(r = 3\).
3 * v
ans =
9
-3
6
27
Be sure to spend time reading and interacting Margalit and Robanoff textbook to visualize what it means to add, subtract vectors and to take the scalar multiple of a vector.
Note
In this course, the word scalar amost always means real number. However, we can have complex-valued matrices and vectors. In those cases, a scalar would be a complex number.
Linear Combinations of Vectors¶
A linear combination of the vectors \(\vec v_1, \vec v_2, \dots \vec v_n\) uses scalars \(c_1, c_2, \dots c_n\) as weights. If we have the vectors
and weights \(c_1 = 4, c_2 = -1, c_3 = 2\), then the result is the linear combination:
Linear Combinations in MATLAB¶
Let’s create the vectors from the above example.
v1 = [5 ; 3 ; -2]
v2 = [ 0; 2 ; 5 ]
v3 = [3 ; 4 ; 3]
v1 =
5
3
-2
v2 =
0
2
5
v3 =
3
4
3
Then we apply addition, subtraction and scalar multiplications as before.
4 * v1 - v2 + 2 * v3
ans =
26
18
-7