代写 EE 285 – Problem Solving Methods and Tools
100%原创包过,高质代写&免费提供Turnitin报告--24小时客服QQ&微信:120591129
EE 285 – Problem Solving Methods and Tools for Electrical Engineering
HOMEWORK 7
Spring 2016
Iowa State University
100 Points
Show all steps for full credit
Submission – Submit through Blackboard by Mar 21, 2016 11:59 pm
ONLY 2 SUBMISSION ATTEMPTS ALLOWED IN BLACKBOARD
Zybook – Complete Zybook activities on the E-book itself by Mar 21, 2016 11:59 pm
In this homework, the concept of using and manipulating two dimensional arrays to represent
matrices will be used.
Develop a C program to read a 3X3 matrix of integers and output the inverse of the matrix.
1. The sample input to the inverse matrix program is a 3X3 matrix as follows :
3 4 5
−2 1 9
8 −4 7
Declare a two dimensional array to store the above matrix in the main function.
Each line of the input (each line is a row in the 3X3 matrix) should be read using one
scanf statement directly into the proper matrix elements in the row. 10 points
2. Create a function which takes a 3X3 matrix as input parameter and returns the
determinant DET of the input matrix.
If the DET = 0, then print “Matrix is not invertible” and exit the program.
Matrix =
? ? ?
? ? ?
? ? ?
DET = ? (? ? − ? ?) − ? (? ? − ? ?) + ? (? ? − ? ?) 10 points
3. Determine the minor Matrix – M (i,j) for each element (i,j) of the input matrix.
There are 9 elements in the 3X3 input matrix. Hence, there will be 9 minor matrices
generated in this step. The dimension of each minor matrix is 2X2.
Minor matrix of element (i,j) – Delete row i and column j from the original matrix. The
remaining elements form the minor Matrix of element (i,j).
For example,
Element (0,0) is 3. Minor matrix of element (0,0) – Delete row 0 and column 0.
Minor matrix – M(0,0)
? 4 5
−2 1 9
8 −4 7
1 9
−4 7
Element (1,1) is 1. Minor matrix of element (1,1) – Delete row 1 and column 1.
Minor matrix – M(1,1)
3 4 5
−2 ? 9
8 −4 7
3
5
8 7
Note that the row and column of the original input matrix need not be actually deleted.
Only keep track of which elements have to be copied into the 2X2 minor matrix from the
original input matrix based on the element indices (i, j).
Declare one 2x2 matrix to store the minor matrix in the main function. Use this matrix
for each of the 9 minor matrices in this step.
Create a function definition which will take the 3X3 original input matrix, element indices
(i,j), and a 2X2 minor matrix as parameters. The function copies the appropriate elements
from the 3x3 matrix into the 2x2 matrix for a given element index (i, j) of the input matrix.
20 points
4. Determinant of minor matrix – D(i,j)
For each of the minor matrix in step 3, M(i,j), find the determinant D(i,j) as follows.
M(i,j) = ?
?
? ?
D(i, j) = ? ? − ? ?
Element (1,1) is 1. Minor matrix of element (1,1) – Delete row 1 and column 1.
Minor matrix – M(1,1)
3 4 5
−2 ? 9
8 −4 7
3
5
8 7
D(1,1) = 3 x 7 – 5 x 8 = -19
Create a function definition which will take the 2X2 minor matrix as a parameter. This
function computes the determinant of the 2x2 matrix and returns the determinant value.
10 points
5. Declare a 3X3 inverse matrix in main function and populate the elements of the inverse
matrix as follows.
?(0,0) −?(1,0) ?(2,0)
−?(0,1) ?(1,1) −?(2,1)
?(0,2) −?(1,2) ?(2,2)
The functions in step 3 and 4 should be called in a for loop to populate the above matrix.
Print the inverse matrix in the main function. 10 points
6. Verify that the inverse matrix is correct by multiplying the inverse matrix with the original
input matrix to generate a 3X3 product matrix. Divide each element of product matrix by
DET.
Print the resulting 3X3 identity matrix as a proof of correct matrix inversion.
Create a function which takes the 3X3 input matrix and the 3X3 inverse matrix in step 5
as input parameters. The function computes the product of the input matrices and prints
the resulting 3X3 identity matrix. 10 points
7. Textbook (Zybook) activity 30 points
Chapter 5 – Challenge activity 5.5.1, 5.5.2, 5.7.1, 5.7.2, 5.7.3, 5.7.4, 5.9.1
Chapter 2 – Challenge activity 2.11.1
Chapter 3 – Challenge activity 3.7.1, 3.7.2
What to submit in BB: 1) Source code for the inverse matrix program