Math Assignment 3 - Linear Algebra

Similar documents
MATH 315 Linear Algebra Homework #1 Assigned: August 20, 2018

Lecture 4: Gaussian Elimination and Homogeneous Equations

NOTES ON LINEAR ALGEBRA CLASS HANDOUT

MATRICES. knowledge on matrices Knowledge on matrix operations. Matrix as a tool of solving linear equations with two or three unknowns.

January 18, 2008 Steve Gu. Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,

Matlab Exercise 0 Due 1/25/06

Linear Algebra Practice Problems

Linear Algebra Using MATLAB

Finite Mathematics Chapter 2. where a, b, c, d, h, and k are real numbers and neither a and b nor c and d are both zero.

Linear Algebra March 16, 2019

0.1 Eigenvalues and Eigenvectors

(Linear equations) Applied Linear Algebra in Geoscience Using MATLAB

Lecture 3: Gaussian Elimination, continued. Lecture 3: Gaussian Elimination, continued

Introduction to Matlab

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 1 x 2. x n 8 (4) 3 4 2

Lecture 12: Solving Systems of Linear Equations by Gaussian Elimination

(Mathematical Operations with Arrays) Applied Linear Algebra in Geoscience Using MATLAB

Quiz ) Locate your 1 st order neighbors. 1) Simplify. Name Hometown. Name Hometown. Name Hometown.

Pre-Calculus I. For example, the system. x y 2 z. may be represented by the augmented matrix

Elementary maths for GMT

MAT 343 Laboratory 3 The LU factorization

MATLAB and Mathematical Introduction Will be discussed in class on 1/24/11

ENGI 9420 Lecture Notes 2 - Matrix Algebra Page Matrix operations can render the solution of a linear system much more efficient.

ECE 102 Engineering Computation

Linear Algebra. The analysis of many models in the social sciences reduces to the study of systems of equations.

LINEAR SYSTEMS, MATRICES, AND VECTORS

is Use at most six elementary row operations. (Partial

PH1105 Lecture Notes on Linear Algebra.

Algebra & Trig. I. For example, the system. x y 2 z. may be represented by the augmented matrix

Contents. 1 Vectors, Lines and Planes 1. 2 Gaussian Elimination Matrices Vector Spaces and Subspaces 124

Linear Algebra review Powers of a diagonalizable matrix Spectral decomposition

L3: Review of linear algebra and MATLAB

Homework 1 Solutions

Note: The command name is upper case in the description given by help, but must be lower case in actual use. And the backslash Anb is dierent when A i

MOL410/510 Problem Set 1 - Linear Algebra - Due Friday Sept. 30

Topics. Vectors (column matrices): Vector addition and scalar multiplication The matrix of a linear function y Ax The elements of a matrix A : A ij

Identity Matrix: EDU> eye(3) ans = Matrix of Ones: EDU> ones(2,3) ans =

Properties of Linear Transformations from R n to R m

ANALYTICAL MATHEMATICS FOR APPLICATIONS 2018 LECTURE NOTES 3

Chapter 9: Systems of Equations and Inequalities

[Disclaimer: This is not a complete list of everything you need to know, just some of the topics that gave people difficulty.]

SOLVING LINEAR SYSTEMS

Linear Systems and Matrices

MAC Module 1 Systems of Linear Equations and Matrices I

Math 4377/6308 Advanced Linear Algebra

1 Last time: linear systems and row operations

The value of a problem is not so much coming up with the answer as in the ideas and attempted ideas it forces on the would be solver I.N.

Relationships Between Planes

Linear Algebra and TI 89

CITS2401 Computer Analysis & Visualisation

MATH 220 FINAL EXAMINATION December 13, Name ID # Section #

1 - Systems of Linear Equations

4 Elementary matrices, continued

Linear Algebra review Powers of a diagonalizable matrix Spectral decomposition

Eigenvalues and Eigenvectors

Introduction to SVD and Applications

Notes on Row Reduction

MATH 213 Linear Algebra and ODEs Spring 2015 Study Sheet for Midterm Exam. Topics

SECTION 2: VECTORS AND MATRICES. ENGR 112 Introduction to Engineering Computing

MATLAB BASICS. Instructor: Prof. Shahrouk Ahmadi. TA: Kartik Bulusu

MATRICES. a m,1 a m,n A =

Chapter 3. Determinants and Eigenvalues

Chapter 1 Linear Equations. 1.1 Systems of Linear Equations

Example. We can represent the information on July sales more simply as

9.1 - Systems of Linear Equations: Two Variables

Chapter 1: Systems of Linear Equations

Math "Matrix Approach to Solving Systems" Bibiana Lopez. November Crafton Hills College. (CHC) 6.3 November / 25

Fundamentals of Linear Algebra. Marcel B. Finan Arkansas Tech University c All Rights Reserved

Using MATLAB. Linear Algebra

An Introduction to Scilab for EE 210 Circuits Tony Richardson

Recall, we solved the system below in a previous section. Here, we learn another method. x + 4y = 14 5x + 3y = 2

MATH Topics in Applied Mathematics Lecture 12: Evaluation of determinants. Cross product.

MTH 464: Computational Linear Algebra

CITS2401 Computer Analysis & Visualisation

All of my class notes can be found at

Solutions Problem Set 8 Math 240, Fall

Linear Algebra. Matrices Operations. Consider, for example, a system of equations such as x + 2y z + 4w = 0, 3x 4y + 2z 6w = 0, x 3y 2z + w = 0.

+ MATRIX VARIABLES AND TWO DIMENSIONAL ARRAYS

MAC Module 3 Determinants. Learning Objectives. Upon completing this module, you should be able to:

Introduction to Matrices and Linear Systems Ch. 3

Math 110 Linear Algebra Midterm 2 Review October 28, 2017

Math 309 Notes and Homework for Days 4-6

2. Every linear system with the same number of equations as unknowns has a unique solution.

Math 360 Linear Algebra Fall Class Notes. a a a a a a. a a a

Finite Math - J-term Section Systems of Linear Equations in Two Variables Example 1. Solve the system

Introduction to Linear Algebra

ELEMENTARY LINEAR ALGEBRA

USE OF MATLAB TO UNDERSTAND BASIC MATHEMATICS

and let s calculate the image of some vectors under the transformation T.

Matrix notation. A nm : n m : size of the matrix. m : no of columns, n: no of rows. Row matrix n=1 [b 1, b 2, b 3,. b m ] Column matrix m=1

Lecture 1: Systems of linear equations and their solutions

Reduction to the associated homogeneous system via a particular solution

Mathematica 3.0. we will not discuss all the possibilities for every command we illustrate.

4 Elementary matrices, continued

4 Gaussian Mixture Models

Matrix Solutions to Linear Equations

1 Overview of Simulink. 2 State-space equations

Math 307 Learning Goals. March 23, 2010

Matrices and systems of linear equations

Eigenvalue and Eigenvector Homework

Transcription:

Math 216 - Assignment 3 - Linear Algebra Due: Tuesday, March 27. Nothing accepted after Thursday, March 29. This is worth 15 points. 10% points off for being late. You may work by yourself or in pairs. If you work in pairs it is only necessary to turn in one set of answers for each pair. Put both your names on it. Do Problems 1-12 in the discussion below. Copy and paste the input and output for each problem from the Command Window (or plot window) to a Microsoft Word file. Do this after you are satisfied with your input and output. Label the work for each problem in the Word file: Problem 1, Problem 2, etc. Print a copy of this file to hand in. Or use a Live Script. Lab 1 looked at the representation of vectors. Here we look at the representation of matrices and calculations with vectors and matrices. More about vectors To represent a row vector, one encloses the components in brackets and separates them with spaces or commas. To represent a column vector one separates the components with semicolons instead of spaces or commas. For example, the following commands assign the row vector 4 (2, - 1, 3) to p and the column vector - 6 to x. The number of components of a vector p is - 3 obtained by length(p). >> p = [2, - 1, 3]; >> x = [4; - 6; - 3]; >> length(x) 3 If one uses spaces to separate the components of a vector, then the minus sign that specifies a negative number must not be separated from the rest of the number by a space. If it is, then the rest of the number is subtracted from the preceding component. For example, 1

>> [2-1 3] 1 3 >> [2-1 3] 2-1 3 The colon notation is used to create row vectors whose components are separated by a fixed amount. For example, this assigns the row vector (2, 2.5, 3, 3.5, 4) to q. >> q = 2: 0.5: 4 A single quote ' is the transpose operator. When it is applied to vectors it changes a row vector to a column vector with the same components or a column vector to a row vector with the same components. For example, the following forms the transpose of the vector stored in p and assigns it to y. >> y = p' y = 2-1 3 Vectors can be concatenated (or joined together). If p and q are row vectors, then [p, q] or [p q] is the row vector consisting of the components of p followed by the components of q. For example, if p = (2, -1, 3) and q = (2, 2.5, 3, 3.5, 4) are as above then [p, q] = (2, -1, 3, 2, 2.5, 3, 3.5, 4) >> r = [p, q] r = 2.0000-1.0000 3.0000 2.0000 2.5000 3.0000 3.5000 4.0000 2

More than two vectors can be concatenated in this way. For example, [p q 3:-1:1] = (2, -1, 3, 2, 2.5, 3, 3.5, 4, 3, 2, 1). p(j) refers to the j th component of the vector p. This notation can be extended to create a vector of arbitrary components of another vector. If p = (p1, p2,..., pn) is a vector and if k = (k1, k2,..., km) is a vector of integers then p(k) is the vector (pk 1, pk 2,..., pk m ). For example, >> q([4, 1, 3, 5, 2]) 3.5000 2.0000 3.0000 4.0000 2.5000 >> q(4:-1:2) 3.5000 3.0000 2.5000 [ ] denotes the empty vector. One can delete a component of a vector by setting it equal to [ ]. For example, >> q(3) = [ ] q = 2.0000 2.5000 3.5000 4.0000 Problem 1: Scalar variables are also vectors! Define a scalar variable (e.g. x = pi). Find its length? Problem 2: Assuming r = (r1, r2,..., r8) is as above, compute (r7, r2, r5). Compute (r2, r3,..., r7) using the colon notation. Compute (r8, r6, r4, r2) using the colon notation. Problem 3: Suppose p = [3 1 4 1 5 9 2 6 5 3 5 2 7 1 8 2 8 1 8 2 8] is a vector. Compute the vector q whose components are the components of p in the reverse order without simply entering them in reverse order. Use the colon notation. 3

Problem 4: Create the vector p = [1, 2,..., 10, 9,..., 6, 5, 6,..., 9, 10, 9,..., 2, 1] using the colon notation and concatenation. A number of vector operations were discussed in the first Lab. In particular the product of a row vector and a column vector is formed using *. For example, here is px = p1x1 +... + pnxn. >> p*x 5 Matrices 1 4 1 4 2 1 A matrix is a two dimensional table of numbers, e.g. M = 2 2 3 6 0 6 is a matrix with 2 rows and 6 columns. To enter a matrix, we enter the rows one at a time as row vectors and we use a semicolon between each row and enclose the whole matrix in square brackets. For example, M above would be entered by >> M = [1, 4, 1, 4, 2, 1; 2, 2, 3, 6, 0, 6] M = 1 4 1 4 2 1 2 2 3 6 0 6 Commonly used matrices have shortcuts to create them. For example, zeros(2, 4) is a 2 4 matrix of all zeros, ones(3, 2) is a 3 2 matrix of all ones, eye(3) is the 3 3 identity matrix, diag([3, -2, 4]) is a 3 3 diagonal matrix with 3, -2 and 4 on the main diagonal and zeros off the main diagonal. 1 4 Problem 5: Enter the following matrices A = 2 2, B = 0 0 0 0, C = 1 1 1 1, D = 1 0 0 1, 2 0 E = 0-1 size(m) is the size of the matrix M which is a row vector with the number of rows of M and the number of columns of M. >> size(m) 4

2 6 M(i, j) refers to the component in the i th row and j th column of M. >> M(2, 4) 6 Problem 6: Change the component in the 2 nd row and 3 rd column of M to 40. Then add 1 to the component in the 1 st row and the 2 nd column of M. As with vectors, one can refer to more than a single component. M(i, :) is the i th row of M. M(:, j) is the j th column of M. M(i:j, m:n) is the submatrix of M consisting of the components whose row is between i and j and whose column is between m and n. When the colon is used by itself, it means "select all". For example M(3:5,:) is the submatrix of M consisting of rows 3 through 5 of M. Determine which values of M you get when you enter each of the following commands. >> M(2, :) >> M(:, 4) >> M(1, 2:4) >> M(:, 3:5) Problem 7: Compute the vector consisting of the elements of M that are in column 2. Compute the submatrix of M consisting of the elements in columns 2 through 5. 1-2 1 0 Enter the following sequence of commands which assign the matrix - 4 5 9-9 to A, add 0 2-8 8 4 times the first row of A to the second, divide the third row by 2 and then interchange the second and third rows. The commands are doing row operations on the matrix A that are working toward bringing it to reduced row echelon form. 5

>> A = [1-2 1 0; -4 5 9-9; 0 2-8 8] >> A(2,:) = A(2,:) + 4*A(1,:) >> A(3,:) = A(3,:)/2 >> A(2:3, :) = A(3:-1:2,:) Problem 8: After entering the above commands, enter some more commands to bring 1-2 1 0-4 5 9-9 to reduced row echelon form. The commands will need to add or 0 2-8 8 subtract multiples of one row to another, interchange rows and multiply rows by numbers. These operations simply imitate the things one does with the equations in a system of equations when one solves the equations using Gaussian elimination. 1 0 0 a In this case reduced row echelon form is when the matrix has the form 0 1 0 b 0 0 1 c where a, b and c are numbers you are to find. These numbers will be the solutions x1-2x2 + x3 = 0 to the system of equations - 4x1 + 5x2 + 9x3 = - 9? 2x2-8x3 = 8 In practice one would not solve a system of equations by doing individual row operations to bring the augmented matrix to reduced row echelon form. A faster way is to use the \ operator. To do this we put the coefficients of the unknowns in a matrix T, the right hand side of the equations in a column vector b. Then the vector of solutions is obtained by entering T\b. The solution is T -1 b, but T\b is the best way to compute this in MATLAB. >> T = [1-2 1; -4 5 9; 0 2-8] >> b = [0; -9; 8] >> T\b 29 16 3 Matrices can be concatenated in a fashion similar to vectors. If M and N are matrices with the same number of rows, then [M, N] or [M N] is the matrix whose i th row consists of the i th row of M concatenated with the i th row of N. If M and N are matrices with the same number of columns, then [M; N] or [M N] is the matrix whose j th column consists of the j th column of M concatenated with the j th column of N. For example 6

>> A = [1 2; 3 4]; >> B = [5 6; 7 8]; >> [A B] 1 2 5 6 3 4 7 8 >> [A; B] 1 2 3 4 5 6 7 8 Matrix Operations The usual matrix operations work as expected. If M and N are matrices then transpose(m) or M' is the transpose of M, inv(m) is the inverse of M, M + N and M - N are the sum and difference of M and N and M * N is the matrix product of M and N. If t is a number then t*m is the usual product of the number t times the matrix M. If t is a positive integer then M^t is the matrix obtained by multiplying M by itself t times. 1 4 Problem 9: Suppose, as in Problem 5, A = 2 2, B = 0 0 0 0, C = 1 1 1 1, D = 1 0 0 1, 2 0 E = 0-1. Compute (A + 1 0 2I)-1 (C - 3E). Here I = 0 1 is the 2 2 identity matrix. As an illustration of matrix multiplication, let's recall some information about geometric x1 transformations. In the following x = x2 and y = y1 are points in the plane. If one obtains y y2 1 0 by reflecting x across the x1 axis then y = 0-1 x. If one obtains y by reflecting x across then - 1 0 x2 axis then y = 0 1 x. If one obtains y by reflecting x across the line x1 = x2 axis then 0 1 y = 1 0 x. If one obtains y by reflecting x through the origin the x2 axis then y = - 1 0 0-1 x. If 1 0 one obtains y by projecting onto the x across the x1 axis then y = 0 0 x. If one obtains y by rotating x counterclockwise by an angle about the origin the x2 axis then y = cos - sin sin cos x. 7

Suppose one obtains y from x by first doing a geometric transformation with formula z = Tx and then doing a geometric transformation with formula y = Sz. Then y = Rx where R = ST. With this in mind, suppose one obtains y from x by first rotating counterclockwise by 60, then reflecting across the line x2 = x1 and finally by rotating clockwise by 45. Find T so that y = Tx. The following sequence of commands find T. >> A = [cos(pi/3) -sin(pi/3),sin(pi/3) cos(pi/3)]; >> B = [0 1;1 0]; >> C = [cos(- pi/4) -sin(- pi/4),sin(- pi/4) cos(- pi/4)]; >> C*B*A 0.9659-0.2588-0.2588-0.9659 As an illustration of raising a matrix to a positive integer power, suppose x and y are represent two physical quantities that evolve in discrete time so that xn and yn are the values of discrete xn+1 = axn + byn time n. Suppose x and y evolve in time in such a way that yn+1 = cxn + or in matrix terms dyn xn un+1 = Aun where un = yn and A = a b c d. Then xn = yn An x0. y0 With this in mind, suppose xn is the number of population of a city n years from the year 2017 and yn is the population of the suburbs. Suppose in the course of a year 5% of the city's population moves to the suburbs and 3% of the suburbs population moves back to the city. Suppose the population of the city in the year 2017 is 600,000 and the population of the suburbs is 400,000. What would this model predict the populations of the city and suburbs to be in the year 2025? The following sequence of commands can be used to answer this. >> A = [0.95 0.03;0.05 0.97]; >> x17 = [600000; 400000]; >> A8 = A^8 >> A8 * x17 A8 = 0.6958 0.1825 0.3042 0.8175 1.0e+05 * 4.9047 5.0953 8

So according to this model the population of the city in 2025 would be about 490,470 and the population of the suburbs would be about 509,530. Note the output writes the answer as 10 5 4.9047 5.0953. Also, after 8 years about 30.5% of the people in the city have ended up in the suburbs and about 18% of the people in the suburbs are back in the city. If M is a square matrix, then det(m) is the determinant of M. If M is a square matrix, then [V, D] = eig(m) gives a diagonal matrix D with the eigenvalues of M and a matrix V of corresponding eigenvectors. Thus M*V = V*D. For example, >> A = [1, 3; 4, 2]; >> [T, D] = eig(a) T = D = -0.7071-0.6000 0.7071-0.8000-2 0 0 5 So the eigenvalues are 1 = 2 and 2 = 5. The eigenvectors for the eigenvalue 1 = 2 are the - 0.7071 multiples of u1 = 0.7071. It would be equally valid to say the eigenvectors for the eigenvalue 1 1 = 2 are the multiples of v1 = - 1. The eigenvectors for the eigenvalue 2 = 5 are the - 0.6 multiples of u2 = 0.8. It would be equally valid to say the eigenvectors for the eigenvalue 3 2 = 2 are the multiples of v2 = - 4. If M and N are matrices which have trfhe same size then M.* N, then this is the matrix obtained by multiplying the corresponding components of M and N. This is similar to vectors. If you double-click on a vector or matrix variable such as M in the Workspace a new window opens up with a spreadsheet like table with the components of the vector or matrix stored in the variable. This table is editable. In fact, you can change the dimension of v by entering values in empty cells, or by control-clicking on a cell and deleting a row or column. Problem 10: Use the \ operator to find the solution of x1 + 3x2 + 4x3 = 1-2x1 + 2x2-3x3 = - 13. 3x1 - x2 = 11 9

Problem 11. Suppose one obtains y from x by first projecting on the x 2 axis, then rotating counterclockwise by 45, and finally reflecting across the x 1 axis. Find T so that y = Tx. Problem 12. Find the eigenvalues and eigenvectors of 4 0 1-2 1 0. - 2 0 1 10