Download Matrices

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Basis (linear algebra) wikipedia , lookup

Capelli's identity wikipedia , lookup

Quadratic form wikipedia , lookup

Tensor operator wikipedia , lookup

Bra–ket notation wikipedia , lookup

Cartesian tensor wikipedia , lookup

Linear algebra wikipedia , lookup

Linear least squares (mathematics) wikipedia , lookup

Eigenvalues and eigenvectors wikipedia , lookup

Jordan normal form wikipedia , lookup

Matrix (mathematics) wikipedia , lookup

Determinant wikipedia , lookup

System of linear equations wikipedia , lookup

Four-vector wikipedia , lookup

Perron–Frobenius theorem wikipedia , lookup

Singular-value decomposition wikipedia , lookup

Non-negative matrix factorization wikipedia , lookup

Cayley–Hamilton theorem wikipedia , lookup

Matrix calculus wikipedia , lookup

Matrix multiplication wikipedia , lookup

Transcript
Matrices
An m x n matrix is defined as having m rows and n columns. For example:
A3 x 2
 a11 a12 
  a21 a22  ,
 a31 a32 
A 3 x 2
An m x 1 matrix is defined as a column vector, and a 1 x n matrix is a row vector:
 c1 
cmx1    , r1xn   r1  rn  ,
cm 
c m , r n
To add matrices, they must be of the same size:
 1 3 5 9   6 12 
 2 7   1 2.5   1 9.5

 
 

For matrix additions, A  B  C , and cij  aij  bij . Math additions are associative:
A  (B  C)  ( A  B)  C  X
Scalar Multiplication: Multiply some scalar number to a matrix:  A
   a11   a12 

   a21   a22 
A 
Matrix Multiplication: A  B  C
Note: For Matrix Multiplication, inner matrix dimensions must be compatible:
Aab  Bcd  Cad , if b  c
For Matrix Multiplication, Associative Property Holds, Commutative Property does not.
( A  B)  C  A  (B  C)
AB  B A
Matrix Multiplication:
Matrix multiplication is a systematic process. A step-by-step procedure is given
for clarity for A  B  C :
1. Loop through all rows of matrix A.
a. Loop through all columns of matrix B.
i. Step through each value of A multiplying it by each value in the
column of B, and sum them all up to get the value for C:
N
cij   arnbnj , where N is the inner dimensions of the matrix
n 1
ii. Place resulting summed value in the ith row and jth column of C.
Example:
1 2 3 9 8  
 4 5 6  7 6   


 
7 8 9  5 4  




9 
1 2 3 7   1 9  2  7  3  5  9  14  15  38, c11  38
 5 
8 
1 2 3 6   1 8  2  6  3  4  8  12  12  32, c12  32
 4 
1 2 3 9 8  38 32
 4 5 6  7 6   



 

7 8 9  5 4 

9 
 4 5 6 7   4  9  5  7  6  5  36  35  30  101, c21  101
 5 
8 
 4 5 6 6   4  8  5  6  6  4  32  30  24  86, c22  86
 4 
1 2 3 9 8   38 32 
 4 5 6  7 6   101 86 


 

7 8 9  5 4 

And so forth. These steps are called “inner products” or “dot products” because a row
vector multiplied by a corresponding column vector gives a scalar: a1n  bn1  c11  c
The Identity Matrix:
1 0 0 
I   0 1 0 
 0 0 1 
The identity matrix can be any size (square typically) but right or left multiplied against
some matrix A gives the original matrix A back.
An invertible or non-singular matrix A multiplied by its inverse A-1 is the identity matrix.
A matrix is singular if its determinant is 0. det( A)  0  A is singular. The determinant
of A is not a measure of how singular a matrix is, it either is or isn’t singular when testing
with the determinant.
Another test of a matrix is the condition number, which is a ratio of the largest to the
smallest singular value of A.
A Matrix Transpose is a flip over the matrix diagonal. If A is a 3x2 matrix, AT = 2x3:
 a1 a 2
 a1 a3 a5
A   a3 a 4 , AT  

 a 2 a 4 a6 
 a5 a6 
For complex numbers this is different (complex conjugate). We will not be using
complex matrix math in NE301 in the near future.
A System of Equations:
4x  3y  1
1x  2 y  3
 4 3   x  1 
 1 2   y    3 

   
Ax  b
A 1Ax  A 1b
Ix  A 1b
x  A 1b
Note: det(A) = -11, and cond(A) = 2.29 or on the order of 100
Remembering back, a system of equations can have one solution, infinite solutions, or no
solutions. If a system is over-determined (more equations than unknowns) the system has
no exact solution. The least squares fit attempts to fit a model through a data to give the
minimum error or best solution through all of the data points.
Example:
50 Students perform an experiment to determine the original quantities of three
radionuclides in a radioactive sample. Using their laboratory procedure, each student
comes up with a row of data as follows:
a
b c | d  , of the form ax  by  cz  d , where x, y, and z are the unknown
quantities for three different radionuclides. (50 equations, 3 unknowns, overdetermined).
Linear Least Squares
Linear Least Squares is a best fit model that is not always numerically stable. If a matrix
is near-singular, or the condition number is of the order of machine precision, numerical
catastrophe may ensue. Always verify the results make physical sense.
Rectangular matrices cannot be inverted. So the basic solution given previously is
insufficient.
General Model for LLS: Ax  b , A mn , m  n
First we need to make A square. Left multiply both equations by AT:
AT Ax  AT b
The quantity, AT A is now invertible (assuming the matrix is not near-singular)
( AT A) 1 ( AT A) x  ( AT A) 1 AT b
( AT A) 1 ( AT A)  I
Ix  ( AT A ) 1 AT b
x  ( AT A ) 1 AT b
The solution is similar to the system of equations prior, with a few extra steps. The vector
x now includes the solutions to the system of equations that is a best fit through the data
points of the experiment.
Computer Examples…
Matlab Commands:
End command with semicolon and it doesn’t show output.
When assigning matrices, a comma moves to the next column slot, and a semicolon
moves to the next row:
A = [ 1, 2, 3];
Row vector 1 2 3
A = [ 1, 2; 3, 4];
1 2
2x2 Matrix 

3 4 
α*A
A*B
C = A*B
A is multiplied by some scalar
B is left multiplied by A / A is right multiplied by B
Store A*B in C
inv(A)
Inverse of Matrix A
A’
Take the transpose of matrix A
det(A)
Determinant of A
cond(A)
Condition number of A