Question: Matrix Operations 4 0 Points / 1 0 per Part In this exercise, you will first use for loops or while loops to create a

Matrix Operations 40 Points /10 per Part
In this exercise, you will first use for loops or while loops to create a matrix, and then you will practice some matrix operations and verify some properties for matrices. You may need the following commands for this exercise.
The command inv(A)returns the inverse of A when A is invertible.
The command A' returns the transpose of A when all entries in A are real numbers.
You also need to be familiar with both for loops and while loops.
for loop
The for loop executes a group of statements in a loop for a specified number of
times.
for index = initial_val:end_val
statements
end
for index = initial_val:step:end_val
statements
end
Note: The first for loop has an implicit step of 1.
while loop
The while loop executes an expression and repeats the execution of a group of statements in a loop while the expression is true (see the example in the handout).
while expression
statements
end
Compare for loop (i) and for loop (ii) in the template file.
Do you have the same output for matrix A?
For an n x n matrix A, calculate the number of FLOPs (additions) used in each for loop. Express the number of FLOPs in terms of n for each for loop. Be sure to show your work for for loop (ii) and simplify your final answer.
Which for loop uses fewer FLOPs?
Practice while loops: Rewrite both for loop (i) and for loop (ii) using while loops only. (You should get the same output as part A. If not, check your code in while loops.)
Note: DO NOT forget to put semi-colons in commands in loops (causes excessive printing)!
Check some properties for matrix multiplications and do the following operations using matrix A from 3A:
Create a matrix B with size n x (n-2) whose entries are random integers between -2 and 10.
Try A*B and B*A by setting them to ABBA.
Note: Only one command will work. Leave the one that works and give a reason why the other does not work.
Create a matrix C with size n x n whose entries are random integers between -2 and 10.
Calculate A*C and C*A and set them to AC and CA, respectively. Are they the same? Why or why not?
Calculate A*eye(n) and eye(n)*A and set to AI and IA. Are they the same? Why or why not?
Check some properties involving the inverse and transpose of a matrix.
Use matrix A from 3A and find the inverse of A, inverse_A, using inv(A). Is A invertible?
Let
. Create matrix D and find the inverse of D using
inv(D), and
RREF of D -- Write the code with exactly two lines using rref to calculate the inverse of D.
Calculate the following in MATLAB.
inv(inv(D)), does it equal to D? Generalize your observation.
Create matrix
.
inv(D*E), inv(D)*inv(E), inv(E)*inv(D), which two give you the same result? Finish the generalization.
inv(D'),(inv(D))', are they the same? Finish the generalization.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!