Lecture Slides for Introduction to Applied Linear Algebra: Vectors, Matrices, and Least Squares

Lecture Slides for Introduction to Applied Linear Algebra: Vectors, Matrices, and Least Squares

Lecture slides for Introduction to Applied Linear Algebra: Vectors, Matrices, and Least Squares Stephen Boyd Lieven Vandenberghe 1. Vectors Outline Notation Examples Addition and scalar multiplication Inner product Complexity Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.1 Vectors I a vector is an ordered list of numbers I written as 1:1 1:1 − − 0:0 0:0 or 2 3:6 3 3:6 6 7 * + 6 7:2 7 . 7:2 / 6 − 7 . − / 6 7 . / or ( 1:1;0;3:6; 7:2) 6 7 − − 4 5 , - I numbers in the list are the elements (entries, coefficients, components) I number of elements is the size (dimension, length) of the vector I vector above has dimension 4; its third entry is 3:6 I vector of size n is called an n-vector I numbers are called scalars Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.2 Vectors via symbols I we’ll use symbols to denote vectors, e.g., a, X, p, β, Eaut I other conventions: g, ~a I ith element of n-vector a is denoted ai I if a is vector above, a3 = 3:6 I in ai, i is the index I for an n-vector, indexes run from i = 1 to i = n I warning: sometimes ai refers to the ith vector in a list of vectors I two vectors a and b of the same size are equal if ai = bi for all i I we overload = and write this as a = b Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.3 Block vectors I suppose b, c, and d are vectors with sizes m, n, p I the stacked vector or concatenation (of b, c, and d) is b a = c 2 3 6 d 7 6 7 I also called a block vector, with (block)46 entries57 b, c, d I a has size m + n + p a = (b1;b2;:::;bm;c1;c2;:::;cn;d1;d2;:::;dp) Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.4 Zero, ones, and unit vectors I n-vector with all entries 0 is denoted 0n or just 0 I n-vector with all entries 1 is denoted 1n or just 1 I a unit vector has one entry 1 and all others 0 I denoted ei where i is entry that is 1 I unit vectors of length 3: 1 0 0 e = 0 ; e = 1 ; e = 0 1 2 3 2 2 3 3 2 3 6 0 7 6 0 7 6 1 7 6 7 6 7 6 7 46 57 46 57 46 57 Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.5 Sparsity I a vector is sparse if many of its entries are 0 I can be stored and manipulated efficiently on a computer I nnz(x) is number of entries that are nonzero I examples: zero vectors, unit vectors Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.6 Outline Notation Examples Addition and scalar multiplication Inner product Complexity Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.7 Location or displacement in 2-D or 3-D 2-vector (x1;x2) can represent a location or a displacement in 2-D x x2 x x2 x1 x1 Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.8 More examples I color: (R;G;B) I quantities of n different commodities (or resources), e.g., bill of materials I portfolio: entries give shares (or $ value or fraction) held in each of n assets, with negative meaning short positions I cash flow: xi is payment in period i to us I audio: xi is the acoustic pressure at sample time i (sample times are spaced 1/44100 seconds apart) I features: xi is the value of ith feature or attribute of an entity I customer purchase: xi is the total $ purchase of product i by a customer over some period I word count: xi is the number of times word i appears in a document Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.9 Word count vectors I a short document: Word count vectors are used in computer based document analysis. Each entry of the word count vector is the number of times the associated dictionary word appears in the document. I a small dictionary (left) and word count vector (right) word 3 in 2 number 2 1 3 6 7 horse 6 0 7 the 6 4 7 6 7 document 6 2 7 6 7 6 7 I dictionaries used in practice are much larger 4 5 Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.10 Outline Notation Examples Addition and scalar multiplication Inner product Complexity Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.11 Vector addition I n-vectors a and b and can be added, with sum denoted a + b I to get sum, add corresponding entries: 0 1 1 7 + 2 = 9 2 3 2 3 2 3 6 3 7 6 0 7 6 3 7 6 7 6 7 6 7 I subtraction is similar 46 57 46 57 46 57 Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.12 Properties of vector addition I commutative: a + b = b + a I associative: (a + b) + c = a + (b + c) (so we can write both as a + b + c) I a + 0 = 0 + a = a I a a = 0 − these are easy and boring to verify Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.13 Adding displacements if 3-vectors a and b are displacements, a + b is the sum displacement a + b b a Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.14 Displacement from one point to another displacement from point q to point p is p q − q p q − p Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.15 Scalar-vector multiplication I scalar β and n-vector a can be multiplied βa = ( βa1;: : : ; βan) I also denoted aβ I example: 1 2 − ( 2) 9 = 18 − 2 3 2 − 3 6 6 7 6 12 7 6 7 6 − 7 6 7 6 7 46 57 46 57 Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.16 Properties of scalar-vector multiplication I associative: ( βγ)a = β(γa) I left distributive: ( β + γ)a = βa + γa I right distributive: β(a + b) = βa + βb these equations look innocent, but be sure you understand them perfectly Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.17 Linear combinations I for vectors a1;:::;am and scalars β1;: : : ; βm, β a + + β a 1 1 ··· m m is a linear combination of the vectors I β1;: : : ; βm are the coefficients I a very important concept I a simple identity: for any n-vector b, b = b e + + b e 1 1 ··· n n Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.18 Example two vectors a1 and a2, and linear combination b = 0:75a1 + 1:5a2 b a2 1.5a2 a1 0.75a1 Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.19 Replicating a cash flow I c = (1; 1:1;0) is a $1 loan from period 1 to 2 with 10% interest 1 − I c = (0;1; 1:1) is a $1 loan from period 2 to 3 with 10% interest 2 − I linear combination d = c + 1:1c = (1;0; 1:21) 1 2 − is a two period loan with 10% compounded interest rate I we have replicated a two period loan from two one period loans Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.20 Outline Notation Examples Addition and scalar multiplication Inner product Complexity Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.21 Inner product I inner product (or dot product) of n-vectors a and b is aT b = a b + a b + + a b 1 1 2 2 ··· n n I other notation used: a;b , a b , (a;b), a b h i h j i · I example: T 1 1 − 2 0 = ( 1)(1) + (2)(0) + (2)( 3) = 7 2 3 2 3 − − − 6 2 7 6 3 7 6 7 6 − 7 6 7 6 7 46 57 46 57 Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.22 Properties of inner product I aT b = bT a I (γa)T b = γ(aT b) I (a + b)T c = aT c + bT c can combine these to get, for example, (a + b)T (c + d) = aT c + aT d + bT c + bT d Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.23 General examples I T ei a = ai (picks out ith entry) I 1T a = a + + a (sum of entries) 1 ··· n I aT a = a2 + + a2 (sum of squares of entries) 1 ··· n Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.24 Examples I w is weight vector, f is feature vector; wT f is score I p is vector of prices, q is vector of quantities; pT q is total cost I c is cash flow, d is discount vector (with interest rate r): n 1 d = (1;1=(1 + r);:::;1=(1 + r) − ) dT c is net present value (NPV) of cash flow I s gives portfolio holdings (in shares), p gives asset prices; pT s is total portfolio value Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.25 Outline Notation Examples Addition and scalar multiplication Inner product Complexity Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.26 Flop counts I computers store (real) numbers in floating-point format I basic arithmetic operations (addition, multiplication, . ) are called floating point operations or flops I complexity of an algorithm or operation: total number of flops needed, as function of the input dimension(s) I this can be very grossly approximated I crude approximation of time to execute: computer speed/flops I current computers are around 1Gflop/sec (109 flops/sec) I but this can vary by factor of 100 Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.27 Complexity of vector addition, inner product I x + y needs n additions, so: n flops I xT y needs n multiplications, n 1 additions so: 2n 1 flops − − I we simplify this to 2n (or even n) flops for xT y I and much less when x or y is sparse Introduction to Applied Linear Algebra Boyd & Vandenberghe 1.28 2.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    470 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us