MATLAB Project 2: MATH240, Spring 2013

Similar documents
Topic 15 Notes Jeremy Orloff

Math 22AL Lab #4. 1 Objectives. 2 Header. 0.1 Notes

5.1 Simplifying Rational Expressions

0.1 Eigenvalues and Eigenvectors

MATH 1553, C. JANKOWSKI MIDTERM 3

MATH 3330 INFORMATION SHEET FOR TEST 3 SPRING Test 3 will be in PKH 113 in class time, Tues April 21

8 Square matrices continued: Determinants

Unit 2, Section 3: Linear Combinations, Spanning, and Linear Independence Linear Combinations, Spanning, and Linear Independence

Sections 6.1 and 6.2: Systems of Linear Equations

Chapter 2:Determinants. Section 2.1: Determinants by cofactor expansion

Second-Order Homogeneous Linear Equations with Constant Coefficients

MAT 1302B Mathematical Methods II

Final Review Sheet. B = (1, 1 + 3x, 1 + x 2 ) then 2 + 3x + 6x 2

The following steps will help you to record your work and save and submit it successfully.

MATH 300, Second Exam REVIEW SOLUTIONS. NOTE: You may use a calculator for this exam- You only need something that will perform basic arithmetic.

Determinants and Scalar Multiplication

Solution Set 7, Fall '12

1. What is the determinant of the following matrix? a 1 a 2 4a 3 2a 2 b 1 b 2 4b 3 2b c 1. = 4, then det

Lecture 2 Systems of Linear Equations and Matrices, Continued

Honors Advanced Mathematics Determinants page 1

21 Linear State-Space Representations

LS.1 Review of Linear Algebra

Solutions to Homework 3, Introduction to Differential Equations, 3450: , Dr. Montero, Spring 2009 M = 3 3 Det(M) = = 24.

MATH 320: PRACTICE PROBLEMS FOR THE FINAL AND SOLUTIONS

Math 369 Exam #2 Practice Problem Solutions

Chapter 1 Linear Equations. 1.1 Systems of Linear Equations

Math 54 Homework 3 Solutions 9/

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

Math Computation Test 1 September 26 th, 2016 Debate: Computation vs. Theory Whatever wins, it ll be Huuuge!

Computer Assignment 2

1 Last time: inverses

Eigenvalues and Eigenvectors

Review for Exam Find all a for which the following linear system has no solutions, one solution, and infinitely many solutions.

Eigenvalues by row operations

KEY. Math 343 Midterm 2 Instructor: Scott Glasgow Sections: 1, 6 and 8 Dates: October 26 th and 27 th, 2005

Math 320, spring 2011 before the first midterm

Computationally, diagonal matrices are the easiest to work with. With this idea in mind, we introduce similarity:

88 CHAPTER 3. SYMMETRIES

Math 240 Calculus III

Math 110 (Fall 2018) Midterm II (Monday October 29, 12:10-1:00)

Final Exam Practice Problems Answers Math 24 Winter 2012

Properties of Linear Transformations from R n to R m

1. In this problem, if the statement is always true, circle T; otherwise, circle F.

Determinants of 2 2 Matrices

Math 308 Midterm Answers and Comments July 18, Part A. Short answer questions

Announcements Wednesday, November 01

2.3. VECTOR SPACES 25

Chapter 2. Polynomial and Rational Functions. 2.5 Zeros of Polynomial Functions

22.3. Repeated Eigenvalues and Symmetric Matrices. Introduction. Prerequisites. Learning Outcomes

Math 138: Introduction to solving systems of equations with matrices. The Concept of Balance for Systems of Equations

Quadratic Equations Part I

And, even if it is square, we may not be able to use EROs to get to the identity matrix. Consider

What is A + B? What is A B? What is AB? What is BA? What is A 2? and B = QUESTION 2. What is the reduced row echelon matrix of A =

1300 Linear Algebra and Vector Geometry

1 Last time: multiplying vectors matrices

Midterm 1 NAME: QUESTION 1 / 10 QUESTION 2 / 10 QUESTION 3 / 10 QUESTION 4 / 10 QUESTION 5 / 10 QUESTION 6 / 10 QUESTION 7 / 10 QUESTION 8 / 10

Inverses and Determinants

Linear Algebra, Summer 2011, pt. 2

Handout 1 EXAMPLES OF SOLVING SYSTEMS OF LINEAR EQUATIONS

Eigenvalues and Eigenvectors

(b) If a multiple of one row of A is added to another row to produce B then det(b) =det(a).

Partial Fractions. June 27, In this section, we will learn to integrate another class of functions: the rational functions.

MATH 211 review notes

Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

We have already seen that the main problem of linear algebra is solving systems of linear equations.

(Practice)Exam in Linear Algebra

Summer Session Practice Final Exam

Math 2174: Practice Midterm 1

Linear Algebra- Final Exam Review

Linear Algebra Practice Final

Question: Given an n x n matrix A, how do we find its eigenvalues? Idea: Suppose c is an eigenvalue of A, then what is the determinant of A-cI?

Math 240, 4.3 Linear Independence; Bases A. DeCelles. 1. definitions of linear independence, linear dependence, dependence relation, basis

6 EIGENVALUES AND EIGENVECTORS

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

Linear Algebra Exercises

Vector, Matrix, and Tensor Derivatives

Math 308 Spring Midterm Answers May 6, 2013

MTH Linear Algebra. Study Guide. Dr. Tony Yee Department of Mathematics and Information Technology The Hong Kong Institute of Education

1. Select the unique answer (choice) for each problem. Write only the answer.

A = 3 B = A 1 1 matrix is the same as a number or scalar, 3 = [3].

MATH 320, WEEK 11: Eigenvalues and Eigenvectors

PREMUR Seminar Week 2 Discussions - Polynomial Division, Gröbner Bases, First Applications

MATH 221: SOLUTIONS TO SELECTED HOMEWORK PROBLEMS

CSL361 Problem set 4: Basic linear algebra

Chapter 2 Notes, Linear Algebra 5e Lay

Essentials of Intermediate Algebra

Linear Algebra. Carleton DeTar February 27, 2017

18.06 Quiz 2 April 7, 2010 Professor Strang

Math 416, Spring 2010 The algebra of determinants March 16, 2010 THE ALGEBRA OF DETERMINANTS. 1. Determinants

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

Math 4242 Fall 2016 (Darij Grinberg): homework set 8 due: Wed, 14 Dec b a. Here is the algorithm for diagonalizing a matrix we did in class:

Lecture 3: Special Matrices

1.2 Finite Precision Arithmetic

Differential Equations

22.4. Numerical Determination of Eigenvalues and Eigenvectors. Introduction. Prerequisites. Learning Outcomes

1 Matrices and Systems of Linear Equations. a 1n a 2n

Math 205, Summer I, Week 3a (continued): Chapter 4, Sections 5 and 6. Week 3b. Chapter 4, [Sections 7], 8 and 9

Third Midterm Exam Name: Practice Problems November 11, Find a basis for the subspace spanned by the following vectors.

Chapter 3: Theory Review: Solutions Math 308 F Spring 2015

Announcements Wednesday, November 01

Transcription:

1. Method MATLAB Project 2: MATH240, Spring 2013 This page is more information which can be helpful for your MATLAB work, including some new commands. You re responsible for knowing what s been done before. The project starts on the next page. The previous guidelines on format still hold. 2. New Commands (a) Powers of matrices can be done in the obvious way. If A is a matrix then we can do: >> A^2 or: >> A^17 You cannot however do the inverse of a matrix this way: >> A^-1 This will not work. (b) Matrix multiplication can be done with: >> A*B This also takes care of matrices times vectors. For example if >> A=[1 2 3;4 5 6;7 8 9] >> v=[-2 ; 1 ; 3] then we can do the product A v with >> A*v (c) The determinant of a matrix is done with the det command. This can be done either on a given matrix: >> A=[1 2 3;4 5 6;7 8 9] >> det(a) or inline: >> det([1 2 3;4 5 6;7 8 9]) (d) The inverse of a matrix can be done with the inv command: >> inv(a) or inline as with det. 3. Combining Functions MATLAB allows you to combine commands easily. For example, suppose we wish to solve the system 2x 1 + x 2 = 0.5 3x 1 5x 2 = 10 We can do this with a single MATLAB command line entry with an inverse matrix: >> inv([2 1;-3-5])*[0.5;10]

MATH 240 Spring 2013 MATLAB Project 2 Directions: A paper (not emailed) version of the completed project should be handed in to your TA when due (or earlier). This can be a printout of the command window of a clean final session, as in the format guidelines described for Project 1. ALSO ALLOWED: you can build up your mfile, and produce the final document by publishing it in MATLAB. Any question marked with a star requires an answer which is not explicitly a MATLAB result. Answer in a comment using % (as in Project 1). You can work in groups of 1,2 or 3, with anyone in the course. List all members of your group at the beginning of your project. Everyone in a group should type up the project individually, and hand it in to his/her TA.. You can t learn MATLAB without typing. Ideally you work together, working on your own laptops. Unless TAs choose otherwise, one project from a group will be graded and everyone in the group will get that grade. More details: 1. Before each question, type clear to clear out the memory. 2. Do questions 1-4 in format rat (do format rat). 3. In questions 5,6,7 work in format long or format rat as appropriate. long exhibits more digits of precision. rat gives you rational expressions (fractions) rather than decimals. rat can be better for seeing identities and fractions, long may be better for seeing precision. 4. To return to the standard format from (say) format rat, enter format short. On to the project problems: 1. Recall, an indexed set of vectors v 1,..., v k is linearly dependent iff one of the vectors can be written as a linear combination of other vectors in the set. Unless the first vector v 1 is the zero vector, the indexed set is linearly dependent iff one of the vectors can be written as a linear combination of previous vectors in the set. To do this for the following set S = {v 1, v 2, v 3, v 4, v 5 } of vectors, 2 8 0 24 59 S = 2 6, 4 24, 6 8, 10 96, 14 128, 10 16 48 0 70 proceed as follows. (The following MATLAB might be useful: if A is a matrix, then e.g. A(:, 3) denotes the column vector which is column 3 of the matrix.) (a) Define an appropriate matrix A. (b) Compute R = rref(a). (c) By inspection from R: state the largest k such that v k is a linear combination of the vectors v i with i < k, v k = c 1 v 1 + + c k 1 v k 1. Also by inspection, type in a column vector c = [c 1 ; c 2 ; ; c k 1 ] which gives that linear combination. (d) (i) Doublecheck by computing the linear combination you gave. (ii) Also compute the vector Ad, where d is the vector whose first k 1 entries are those of c, and whose other entries are zero. (iii) Explain the relationship of the results of the computations for (i) and (ii).

2. Suppose a linear transformation T has the property that T (7, 5) = (6.4, 3) and T (8, 5) = (1, 5/2). (Recall e.g. (6.4, 3) is Lay s notation for a column vector, written [6.4; 3] in MATLAB.) Let A denote the matrix such that T (x) = Ax for all x. (a) The data tell you there are matrices B and C such that A B = C. Define B and C. (b) Using inv(b), C and matrix multiplication, compute A. (c) Check that you have the correct A by computing in MATLAB A [7; 5] and A [8, 5]. 3. (a) Define A = 1 2 3 4 5 6 2 1 2 (b) Display the inverse using inv. Use the format which displays entries as fractions (not decimals). (c) (Now we let MATLAB do the work for the row reduction algorithm described in the text for finding A 1.) (i) Define the 3 6 matrix B which is [ A I ]. (ii) Define C = rref(b). (The left half of C is I and the right half of C is A 1 ) (iii) Exhibit A 1 with the command C(:, 4 : 6) (this is the submatrix of C in columns 4 through 6, which MATLAB will exhibit). 4. (a) Use MATLAB to compute the determinants of the following two matrices. 5 90 89 2 1 2 0 2 A = 0 1 0 18 0 0 5 17 B = 3 1 2 1 0 1 0 1 0 0 0 1 2 0 1 1 (b) Use MATLAB to compute the matrix C = AB and also det(c). (c) What is the general fact for which these computations give an example? 5. Consider the set of functions { 1, cos t, cos 2 t, cos 3 t }. We would like to show that this is a linearly independent set of functions. This means that the equation x 1 (1) + x 2 cos t + x 3 cos 2 t + x 4 cos 3 t = 0 has only the trivial solution: it is only true when each of the x i is the number zero. The thing to keep in mind is that this equality is functional: for the equation to be true for a given set of numbers x 1,..., x 4, it must be true for all values of t. (This kind of independence is important for understanding solutions of differential equations, e.g. in MATH 246.) (a) Each substitution of a number for t in the displayed equation produces a numerical equation. Using t = 0, 0.1, 0.2 and 0.3, you get four equations. Define the coefficient matrix A for this system, for MATLAB to display. (If for example you type cos(.1) into a matrix, MATLAB will know how to compute it as a number.) (b) If A is invertible, then Ax = 0 has no nontrivial solution. This implies the equation (*) has no nontrivial solution (because there is no nontrivial solution which works for t = 0, 0.1, 0.2, 0.3, let alone for all the other inputs). Compute rref(a). Compute det(a). (c) Very briefly explain why each of the last two computations show A is invertible. (d) It is reasonable to be suspicious of the very small value of det(a) in the last step could this be roundoff error, with the actual det(a) being zero? Do a check by repeating the computation with the more spread out inputs t = 0,.2,.5, 1, to see det(a) large enough to eliminate that suspicion. ( )

6. Often a functional relation which holds at some fairly random inputs will hold at all inputs, and such a relation can be discovered numerically, and then verified with a proof. (Proofs are a lot easier when you are almost certain the claim you are proving is correct.) We ll start with an easy example. We consider whether the set of functions { 1, cos 2 t, sin 2 t } is a linearly independent set, that is, whether there are numbers x 1, x 2, x 3 such that for all t, x 1 (1) + x 2 cos 2 t + x 3 sin 2 t = 0. (a) Use an approach with MATLAB similar to the above, defining a coefficient matrix A at inputs t = 0, 0.1, 0.2 for a corresponding system of equations. (b) Exhibit R = rref(a). (c) Write down a nontrivial solution x to Rx = 0 (and hence to Ax = 0) obtained from the last step. Here x = [x 1 ; x 2 ; x 3 ] such that x 1 (1) + x 2 cos 2 t + x 3 sin 2 t = 0 if t is 0, 0.1 or 0.2. Choose your solution x with integer entries. (d) For the numerical vector x you discovered above, see if it holds (perhaps up to a tiny error from roundoff) for the random number 1.7392. (e) Quote a basic trig identity which explains why your linear combination vanishes at every t. 7. Now, a more interesting example. We investigate whether the set of functions {sin(t), sin(3t), sin 3 (t)} is linearly independent. (a) Proceeding as before, define a suitable matrix A and B = rref(a) to find a nontrivial linear relation for the set of functions sin(3t), sin(t), sin 3 (t) which holds for the inputs 0, 0.2, 0.4. (b) Write down integers c 1, c 2, c 3 such that c 1 sin(3t) + c 2 sin(t) + c 3 sin 3 (t) = 0 at the inputs t = 0, 0.2, 0.4 (perhaps up to a tiny roundoff error). Compute the value of your linear combination at another random input (say t = 5.621) and see if it vanishes there. Switch to format long to see the size. Try another inputs of your choice. (c) Is it reasonable to suspect your nonzero values, being so small at several inputs, are roundoff error? (d) (Purely optional for those interested. This is not for grading.) To be sure the identity holds for all inputs t, you can give a proof. Remember Euler s identity for complex numbers: e iθ = cos(θ) + i sin(θ). So, e i3t = cos(3t) + i sin(3t). Next, compute e i3t in another way. Using the formula (a + b) 3 = a 3 + 3a 2 b + 3ab 2 + b 3, we find e i3t = (e it ) 3 = ( ) 3 cos(t) + i sin(t) = [cos(t)] 3 + 3[cos 2 (t)][i sin(t)] + 3[cos(t)][i sin(t)] 2 + [i sin(t)] 3 ( ) ( ) = cos 3 (t) 3(cos(t))(sin 2 (t)) + i 3 cos 2 (t) sin(t) sin 3 (t). The real and imaginary parts of the two ways of computing e i3t must match. There is one more step: you can replace the cos 2 (3t) with 1 sin 2 (3t) and simplify.

8. (You will want to be back in format short.) (a) Symbolically define the variables a through i, using the command syms a b c d e f g h i (b) Define matrices [ ] a b A = c d Find the determinants of A k and B k for k = 1, 2, 3, 6., B = a b c d e f. g h i (c) Record how long MATLAB takes to compute det(b 10 ) (note start and end times and subtract). Record second monomial in the polynomial MATLAB computes to be det(b 10 ). (DO NOT execute this command in the output you turn in save the trees. The point of this computation and the next is to emphasize that determinant computations from the definition can easily become very slow and unwieldy.) (d) (This is a discussion explaining the next part nothing to turn in.) Let us see why MATLAB is slow when it is commanded to compute det(b 10 ) above symbolically ( symbolically means exact computation of the polynomial no numerical simplifications). The determinant of a 3 3 matrix is a polynomial function of the entries, a sum of six monomials. Each of these six determinant monomials is a product of three entries of the matrix. For the 3 3 matrix B k, a matrix entry is a sum of 3 k 1 monomials. Plugging these into the determinant polynomial we have a sum of six polynomials, each being a sum of (3 k 1 )(3 k 1 )(3 k 1 ) = 3 3k 3 monomials. So, for the symbolic det(b k ), poor MATLAB has to compute 6(3 3k 3 ) monomials. (e) Have MATLAB compute the value of 6(3 3k 3 ) for k = 1, 2, 5, 10. 2 2 1 (f) Let C = 0 20 5. Compute det(c). 1 2 1/2 (g) For this matrix C and a positive integer n, what is the correct value of det(c n )? (h) For n = 5, 6, 8, 10, 12, execute the MATLAB command det(c n ) (1/10) n. (These matrices C n get quite large as n increases. Computations are much faster than for the symbolic case, but, still, one must be careful about computations on large matrices. With accumulated error, they can go wrong, as you see.)