Starting from:

$24.99

MATH461 Project 2 Solution

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.
1. 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 Av¯ 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 command eye(n) will produce the n × n identity matrix In. If A is a 3 × 3 matrix that we have already entered, then we can type
>> M = [A eye(3)]
to produce the 3 × 6 matrix as in the algorithm for computing A−1. (Aside: if b is a column vector, you can also create augmented matrices by typing [A b]) We could then do N = rref(M), followed by
>> X = N(:,4:6)
to extract the inverse from N. This command is extracting the submatrix which consists of all rows, but only columns 4 through 6. However, MATLAB has a command to compute an inverse all at once. The inverse of A can be done with the inv command:
>> inv(A) or inline as with det.
2. Combining Functions
MATLAB allows you to combine commands easily. For example, suppose we wish to solve the system
2x1 + x2 = 0.5
−3x1− 5x2 = 10
We can do this with a single MATLAB command line entry with an inverse matrix:
>> inv([2 1;-3 -5])*[0.5;10]

%% Problem 1 followed by all your commands for Problem 1 (then the same for Problem 2 and so on).
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).
1. Before each question, type clear to clear out all variables. There is also a button in MATLAB to do this.
2. Each problem specifies whether to use format rat (fractions) or format short (decimals). Format rat is good if you are actually working with rational numbers. But if you have irrational numbers, it will√

give rational approximations for them. For example, in format rat, π = 355/113 and 2 = 1393/985.
Approximations like this can be a bit misleading, so it is sometimes better to work with decimals.
On to the project problems:

1. (Use format rat) Let
.
(a) Follow the instructions in the introduction on how to enter the augmented matrix , put it in reduced row echelon form, and then extract the inverse matrix A−1.
(b) Now let MATLAB compute the inverse of A directly using the inv command. Make sure your answer coincides with the previous part.
2. (Use format rat)
(a) Use MATLAB to compute the determinants of the following two matrices.

(b) ⋆ The determinant of A could have been computed easily without MATLAB. What general fact could have been used to do this?
(c) Use MATLAB to compute the matrix C = AB and also det(C).
(d) ⋆ The determinant of C could have been determined without having MATLAB compute det(C). What general fact could have been used to do this?
3. (Use format rat) Let .
(a) Compute detA.
(b) ⋆ Consider the following matrices obtained from A by elementary row operations:
i. B is obtained from A by adding 11 times row 1 to row 3. ii. C is obtained from A by swapping row 1 with row 2. iii. D is obtained from A by multiplying row 2 by 1/7.
Without doing any computations, determine the values of detB, detC, and detD.
(d) Compute the determinants of B, C, and D in MATLAB, and verify that they are the same as the values you predicted.
4. (a) Symbolically define the variables a through d, using the command syms a b c d
Then enter the matrix .
(b) Use the inv command to compute A−1. This is what the formula for the inverse of a 2×2 matrix looks like.
(c) Define more symbolic variables and the matrix .
(d) Compute B−1 to see the formula for the inverse of a 3 × 3 matrix. It is a bit messy because each term is divided by detB. Compute adj(B) to simplify what you are looking at.
5. (Use format short, except when specified otherwise) Recall that a counterclockwise rotation about the origin by angle θ defines a linear transformation from R2 to R2. As discussed in the textbook, the standard matrix of this transformation is
.
(a) Enter A = Rθ for θ = π/7 in MATLAB. (Note: you can type things like cos(pi/7) in MATLAB.)
Then use it to rotate the vector v counter-clockwise by an angle of π/7.
(b) Let B = Rθ for θ = π/11. Use MATLAB to determine if AB = BA.
(c) ⋆ What does the previous result say about how these two different rotation operations interact with each other?
(d) Switch back to format short. The inverse of Rθ is R−θ. Verify this in MATLAB for θ = π/7 by comparing inv(A) with R−π/7.
(e) Reflection about a line through the origin in R2 is also a linear transformation. Let Lθ denote the standard matrix for the reflection about the line through the origin which makes an angle of θ with the positive x1-axis. For example, L0 is just reflection about the x1-axis, and is given by
.
It can be shown that the matrix Lθ is given by
Lθ = RθL0R−θ.
Compute the matrix Lθ for θ = π/7.
(f) Determine if Lπ/7L0 = L0Lπ/7.
6. (Use format short) Consider the set of functions
.
We would like to show that this is a linearly independent set of functions. This means that if x1,x2,x3,x4 are scalars such that
(∗) x1(1) + x2 cost + x3 cos2 t + x4 cos3 t = 0 (for all t),
then we must have x1 = 0,x2 = 0,x3 = 0,x4 = 0. Essentially we are trying to disprove the existence of a linear relation relating these four functions to each other. More concretely, we are trying to prove that no identity such as

could possibly exist.
(a) Each substitution of a number for t in the equation (∗) produces a SINGLE linear equation in the four variables x1,x2,x3,x4. Plug in t = 0,0.1,0.2 and 0.3 to get a system of four linear equations in the four unknowns. Define the coefficient matrix A for this linear system in MATLAB.
(b) Note that a nontrivial solution x to (∗) is automatically a nontrivial solution to Ax = 0. However, if A is invertible, then Ax = 0 has no nontrivial solutions. This implies that the equation (∗) has no nontrivial solutions. Compute rref(A) and 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 if det(A) is large enough to eliminate that suspicion.
7. (Use format short) We shall apply the ideas of the previous problem on the set of functions
.
That is, we shall determine if there exist nontrivial scalars x1,x2,x3 such that
(∗) x1(1) + x2 cos2 t + x3 sin2 t = 0 (for all t).
(a) Use an approach similar to the previous problem. Plug in t = 0,0.1,0.2 to obtain three equations in the three unknowns. Let A be the coefficient matrix of the corresponding linear system Ax = 0. Note that any nontrivial solution x to (∗) will be a nontrivial solution to Ax = 0. So if one exists, we can find it by solving Ax = 0. Enter A into MATLAB and compute R = rref(A).
(b) ⋆ Give a nontrivial solution x to Ax = 0. Choose your solution x so that it has integer entries.
(c) For the solution x you discovered above, see if the equation (∗) holds (perhaps up to a tiny error from roundoff) for the “random” number t = 1.7392. This is mounting evidence that we have discovered an actual linear identity relating the three functions 1,cos2 t, and sin2 t.
(d) ⋆ What is the basic trig identity which explains why (∗) holds for every t (for your x)?

More products