Lecture 5a Linear Algebra Review
W. Gambill
Department of Computer Science University of Illinois at Urbana-Champaign
February 2, 2010
W. Gambill (UIUC) CS 357 February 2, 2010 1 / 74 Vector Space Example
The set of n-tuples in Rn form a vector space. v1 v2 = v . . vn
By convention we will write vectors in column form. The transpose operator T converts column vectors to row vectors and vice versa.
T v1 v2 = ... . v1 v2 vn . vn
W. Gambill (UIUC) CS 357 February 2, 2010 2 / 74 Vector Space Example 2
The set of continuous functions defined on a closed interval e.g. f ∈ C([a, b]), f :[a, b] → R form a vector space over the reals R.
If f1, f2 ∈ C([a, b]) then f1 + f2 ∈ C([a, b])
If r ∈ R then r ∗ f1 ∈ C([a, b])
W. Gambill (UIUC) CS 357 February 2, 2010 3 / 74 Vector Operations
Addition and Subtraction Multiplication by a scalar Transpose Linear Combinations of Vectors Inner Product Outer Product Vector Norms
W. Gambill (UIUC) CS 357 February 2, 2010 4 / 74 Vector Addition and Subtraction
Addition and subtraction are element-by-element operations
c = a + b ⇐⇒ ci = ai + bi i = 1,..., n
d = a − b ⇐⇒ di = ai − bi i = 1,..., n
1 3 a = 2 b = 2 3 1 4 −2 a + b = 4 a − b = 0 4 2
W. Gambill (UIUC) CS 357 February 2, 2010 5 / 74 Multiplication by a Scalar
Multiplication by a scalar involves multiplying each element in the vector by the scalar: b = σa ⇐⇒ bi = σai i = 1,..., n
4 2 a a = 6 b = = 3 8 2 4
W. Gambill (UIUC) CS 357 February 2, 2010 6 / 74 Vector Transpose
The transpose of a row vector is a column vector:
1 T u = 1, 2, 3 then u = 2 3
Likewise if v is the column vector 4 T v = 5 then v = 4, 5, 6 6
W. Gambill (UIUC) CS 357 February 2, 2010 7 / 74 Linear Combinations
Combine scalar multiplication with addition u1 v1 αu1 + βv1 w1 u2 v2 αu2 + βv2 w2 α + β = = . . . . . . . . um vm αum + βvm wm
−2 1 r = 1 s = 0 3 3 −4 3 −1 t = 2r + 3s = 2 + 0 = 2 6 9 15
W. Gambill (UIUC) CS 357 February 2, 2010 8 / 74 Linear Combinations
Any one vector can be created from an infinite combination of other “suitable” vectors.
4 1 0 w = = 4 + 2 2 0 1
1 1 w = 6 − 2 0 −1
2 −1 w = − 2 4 1
4 1 0 w = 2 − 4 − 2 2 0 1
W. Gambill (UIUC) CS 357 February 2, 2010 9 / 74 Linear Combinations
4 [2,4] [1,-1] Graphical interpretation: 3 Vector tails can be moved to convenient 2 [4,2] locations [-1,1] Magnitude and 1 direction of vectors is [0,1] [1,1] preserved 0 [1,0]
0 1 2 3 4 5 6
W. Gambill (UIUC) CS 357 February 2, 2010 10 / 74 Vector Inner Product
In physics, analytical geometry, and engineering, the dot product has a geometric interpretation
n
σ = x · y ⇐⇒ σ = xiyi = Xi 1
x · y = kxk2 kyk2 cos θ
W. Gambill (UIUC) CS 357 February 2, 2010 11 / 74 Vector Inner Product
The inner product of x and y requires that x be a row vector y be a column vector y1 y2 x1 x2 x3 x4 = x1y1 + x2y2 + x3y3 + x4y4 y3 y4
W. Gambill (UIUC) CS 357 February 2, 2010 12 / 74 Vector Inner Product
For two n-element column vectors, u and v, the inner product is
n T σ = u v ⇐⇒ σ = uivi = Xi 1 The inner product is commutative so that (for two column vectors) uTv = vTu
W. Gambill (UIUC) CS 357 February 2, 2010 13 / 74 Computing the Inner Product in Matlab
The * operator performs the inner product if two vectors are compatible.
1 >> u = (0:3)’;%u andv are
2 >> v = (3:-1:0)’;% column vectors
3 >> s = u*v
4 ??? Error using ==> *
5 Inner matrix dimensions must agree.
6
7 >> s = u’*v
8 s =
9 4
10
11 >> t = v’*u
12 t =
13 4
14
15 >> dot(u,v)
16 ans=
17 4
W. Gambill (UIUC) CS 357 February 2, 2010 14 / 74 Vector Outer Product
The inner product results in a scalar. Example The outer product creates a rank- one matrix: Outer product of two 4-element column vectors T A = uv ⇐⇒ ai,j = uivj u1 T u2 uv = v1 v2 v3 v4 u3 u4 u1v1 u1v2 u1v3 u1v4 u2v1 u2v2 u2v3 u2v4 = u3v1 u3v2 u3v3 u3v4 u4v1 u4v2 u4v3 u4v4
W. Gambill (UIUC) CS 357 February 2, 2010 15 / 74 Computing the Outer Product in Matlab
The * operator performs the outer product if two vectors are compatible.
1 u = (0:4) ’;
2 v = (4:-1:0)’;
3 A = u*v’
4 A =
5 0 0 0 0 0
6 4 3 2 1 0
7 8 6 4 2 0
8 12 9 6 3 0
9 16 12 8 4 0
W. Gambill (UIUC) CS 357 February 2, 2010 16 / 74 Vector Norms
Compare magnitude of scalars with the absolute value
α > β
Compare magnitude of vectors with norms
kxk > kyk
There are several ways to compute ||x||. In other words the size of two vectors can be compared with different norms.
W. Gambill (UIUC) CS 357 February 2, 2010 17 / 74 Vector Norms Consider two element vectors, which lie in a plane
b = (2,4)
a = (4,2) c = (2,1) a = (4,2)
Use geometric lengths to represent the magnitudes of the vectors √ √ √ p 2 2 p 2 2 p 2 2 `a = 4 + 2 = 20, `b = 2 + 4 = 20, `c = 2 + 1 = 5
We conclude that `a = `b and `a > `c or kak = kbk and kak > kck
W. Gambill (UIUC) CS 357 February 2, 2010 18 / 74 The L2 Norm
The notion of a geometric length for 2D or 3D vectors can be extended vectors with arbitrary numbers of elements. The result is called the Euclidian or L2 norm:
n !1/2 2 2 21/2 2 kxk2 = x1 + x2 + ... + xn = xi = Xi 1
The L2 norm can also be expressed in terms of the inner product √ √ T kxk2 = x · x = x x
W. Gambill (UIUC) CS 357 February 2, 2010 19 / 74 p-Norms
For any positive integer p