![Page 1: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/1.jpg)
Lecture 28: Mathematical Insight and Engineering
![Page 2: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/2.jpg)
Matrices
Matrices are commonly used in engineering computations.A matrix generally has more than one row and more than one column.Scalar multiplication and matrix addition and subtraction are performed element by element.
![Page 3: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/3.jpg)
Matrix Operations
TransposeMultiplicationExponentiationInverseDeterminantsLeft division
![Page 4: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/4.jpg)
Transpose
In mathematics texts you will often see the transpose indicated with superscript T AT
The MATLAB syntax for the transpose is A'
![Page 5: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/5.jpg)
The transpose switches the rows and columns
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
=
121110
987
654
321
A⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡=
12963
11852
10741TA
![Page 6: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/6.jpg)
The dot product is sometimes called the scalar productThe sum of the results when you multiply two vectors together, element by element.
Dot Products
![Page 7: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/7.jpg)
*||
*||
*||
+ +
Equivalent statements
![Page 8: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/8.jpg)
Matrix Multiplication
Matrix multiplication results in an array where each element is a dot product. In general, the results are found by taking the dot product of each row in matrix A with each column in Matrix B
![Page 9: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/9.jpg)
A: m x nB: n x p
€
C(i, j) = A(i,k) *B(k, j)k=1
n
∑
![Page 10: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/10.jpg)
Because matrix multiplication is a series of dot products the number of columns in
matrix A must equal the number of rows in matrix B
For an mxn matrix multiplied by an nxp matrix
m x n n x p
These dimensions must match
The resulting matrix will have these dimensions
![Page 11: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/11.jpg)
Matrix Powers
Raising a matrix to a power is equivalent to multiplying itself the requisite number of times A2 is the same as A*A A3 is the same as A*A*A Raising a matrix to a power requires it to have the same number of rows and columns
![Page 12: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/12.jpg)
Matrix Inverse
MATLAB offers two approaches The matrix inverse function
inv(A) Raising a matrix to the -1 power
A-1
![Page 13: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/13.jpg)
A matrix times its inverse is the identity matrix
Equivalent approaches to finding the inverse of a matrix
![Page 14: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/14.jpg)
Not all matrices have an inverse
Called Singular Ill-conditioned matrices
Attempting to take the inverse of a singular matrix results in an error statement
![Page 15: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/15.jpg)
Determinants
Related to the matrix inverseIf the determinant is equal to 0, the matrix does not have an inverseThe MATLAB function to find a determinant is det(A)
![Page 16: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/16.jpg)
|A| = A(1, 1)*A(2, 2)
- A(1, 2)*A(2, 1)
|A| = A(1,1)*A(2,2)*A(3,3)
+ A(1, 2)*A(2,3)*A(3,1)
+ A(1,3)*A(2,1)*a(3,2)
- A(3,1)*A(2,2)*A(1,3)
- A(3,2)*A(2,3)*A(1,1) - A(3,3)*A(2,1)*A(1,2)
![Page 17: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/17.jpg)
Solutions to Systems of Linear Equations
3 2 10
3 2 5
1
x y z
x y z
x y z
+ − =− + + =
− − = −
![Page 18: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/18.jpg)
Using Matrix Nomenclature
⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−−−
−=
111
231
123
A⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡=
z
y
x
X⎥⎥⎥
⎦
⎤
⎢⎢⎢
⎣
⎡
−=
1
5
10
B
and
AX=B
![Page 19: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/19.jpg)
We can solve this problem using the matrix inverse approach
This approach is easy to understand, but its not the more efficient computationally
![Page 20: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/20.jpg)
Matrix left division uses Gaussian elimination, which is much more efficient, and less prone to round-off error
![Page 21: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/21.jpg)
Q. What is the output of the following code fragment? int j; for (j = 0 ; j < 4; j++) { printf(“%d ”, j); j++; } A) 0 1 2 3 B) 0 2 C) 1 3 D) 1 2 3
Practice QuestionS
olu
tion
: B
![Page 22: Lecture 28: Mathematical Insight and Engineering](https://reader031.vdocuments.mx/reader031/viewer/2022032709/56649ecd5503460f94bda527/html5/thumbnails/22.jpg)
Q. What is the output of the following program? #include <stdio.h> int myFunc(int a, int *b); int main( void ) { int a = 4; int b = 5; myFunc(a, &b); printf ("a + b = %d\n", a + b); } int myFunc(int a, int *b) { a = a + 2; *b = *b - 1;
return a; }
A) a + b = 9 B) a + b = 8 C) a + b = 11 D) a + b = 10
Practice Question
Solu
tion
: B