Matrix Operations: Addition, Multiplication, Transposition, and Inverse, Slides of Aeronautical Engineering

Pseudo-code and pre-conditions for performing matrix operations, including addition, multiplication, transposition, and finding the inverse of a 3x3 matrix. The concept of cofactors and the determinant in the context of finding the inverse.

Typology: Slides

2011/2012

Uploaded on 07/20/2012

savitha_48
savitha_48 🇮🇳

3

(1)

109 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Matrix Primer
Add two 3x3 matrices
Pre-conditions: two non-empty 3x3 matrices of integer/ real / complex type
Post-conditions: a new 3x3 matrix of the same type with the elements added
Pseudo-code:
1. Let the matrices A, B be the input matrices
2. Let the matrix holding the sum be called Sum.
3. For I in 1.. 3 loop
i. For J in 1.. 3 loop
1. Sum(I,J) := A(I,J) + B(I,J)
4. Return matrix Sum
Multiply two 3x3 matrices
Suppose that A and B are two matrices and that A is an m x n matrix (m rows and n
columns) and that B is a p x q matrix. To be able to multiply A and B together, A must
have the same number of columns as B has rows (i.e., n=p). The product will be a matrix
with m rows and q columns. To find the entry in row r and column c of the new matrix
we take the "dot product" of row r of matrix A and column c of matrix B (pair up the
elements of row r with column c, multiply these pairs together individually, and then add
their products).
Mathematically,
n
C(I,J) = A(I,K) B(K,J)
K=1
Where
I ranges from 1.. m
J ranges from 1.. q
K ranges from 1.. n = p
Pre-conditions: two non-empty 3x3 matrices of integer/ real / complex type
Post-conditions: a new 3x3 matrix of the same type with the product of the matrices
Pseudo-code:
1. Let the matrices A, B be the input matrices
2. Let the matrix holding the product be called Product.
3. Use a local variable sum to store the intermediate value of product.
4. For I in 1.. 3 loop
docsity.com
pf3
pf4

Partial preview of the text

Download Matrix Operations: Addition, Multiplication, Transposition, and Inverse and more Slides Aeronautical Engineering in PDF only on Docsity!

Matrix Primer

Add two 3x3 matrices

Pre-conditions: two non-empty 3x3 matrices of integer/ real / complex type Post-conditions: a new 3x3 matrix of the same type with the elements added

Pseudo-code:

  1. Let the matrices A, B be the input matrices
  2. Let the matrix holding the sum be called Sum.
  3. For I in 1.. 3 loop i. For J in 1.. 3 loop 1. Sum(I,J) := A(I,J) + B(I,J)
  4. Return matrix Sum

Multiply two 3x3 matrices

Suppose that A and B are two matrices and that A is an m x n matrix (m rows and n columns) and that B is a p x q matrix. To be able to multiply A and B together, A must have the same number of columns as B has rows (i.e., n=p). The product will be a matrix with m rows and q columns. To find the entry in row r and column c of the new matrix we take the "dot product" of row r of matrix A and column c of matrix B (pair up the elements of row r with column c, multiply these pairs together individually, and then add their products).

Mathematically, n C(I,J) = ∑ A(I,K) B(K,J) K=

Where ƒ I ranges from 1.. m ƒ J ranges from 1.. q ƒ K ranges from 1.. n = p

Pre-conditions: two non-empty 3x3 matrices of integer/ real / complex type Post-conditions: a new 3x3 matrix of the same type with the product of the matrices

Pseudo-code:

  1. Let the matrices A, B be the input matrices
  2. Let the matrix holding the product be called Product.
  3. Use a local variable sum to store the intermediate value of product.
  4. For I in 1.. 3 loop

i. For J in 1.. 3 loop

  1. Sum := 0;
  2. For K in 1 .. 3 loop a. Sum := Sum + A(I,K) * B(K,J);
  3. End K loop
  4. Product(I,J) := Sum; ii. End J loop
  5. End I loop
  6. Return matrix Product

Transpose a 3x3 matrix

Pre-conditions: A non-empty 3x3 matrix Post-conditions: A new 3x3 matrix of the same type with the elements in rows and columns exchanged

Pseudo-code:

  1. Let the input matrix be A
  2. Let the matrix holding the transpose be called Transpose.
  3. For I in 1 .. 3 loop i. For J in 1.. 3 loop 1. Transpose(I,J) := A(J,I)
  4. Return matrix Transpose

Inverse of a 3x3 matrix

The inverse of a 3×3 matrix is given by:

We use cofactors to determine the adjoint of a matrix.

The cofactor of an element in a matrix is the value obtained by evaluating the determinant formed by the elements not in that particular row or column.

We find the adjoint matrix by replacing each element in the matrix with its cofactor and applying a + or - sign as follows:

  1. Compute determinant as Determinant := A(1,1)Cofactor(1,1) + A(1,2)Cofactor (1,2)+ A(1,3)*Cofactor (1,3)
  2. Compute the transpose of the Cofactor matrix
  3. For I in 1.. 3 a. For J in 1.. i. Inverse(I,J) := Cofactor(I,J) / Determinant
  4. Return Inverse

Note: The method for computing the cofactor automatically generates the required signs in the cofactor matrix.