%matplotlib inline
from IPython.external.mathjax import install_mathjax
install_mathjax()
Downloading mathjax source from https://github.com/mathjax/MathJax/archive/2.4.0.tar.gz Extracting to /Users/dyanos/.ipython/nbextensions/mathjax
0
Scalar
Vector
Matrices
Tensors
Adding
Multiplying Matrices and Vectors
more explicitly:
a1,1x1+a1,2x2+⋯+a1,nxn=b1a2,1x1+a2,2x2+⋯+a2,nxn=b2…am,1x1+am,2x2+⋯+am,nxn=bmIn general, this kind of operation is called a linear combination.
The span of a set of vectors is the set of all points obtainable by linear combination of the original vectors.
Determining whether AxAx=bb has a solution thus amounts to testing whether bb is in the span of the columns of AA. This particular span is known as the column space or the range of AA.
In order for the system AxAx=bb to have a solution for all values of bb∈Rm, we therefore require that the column space of AA be all of Rm.
Having n≤m is only a necessary condition for every point to have a solution. However, It's not a sufficient condition, because it's possible for some of the columns to be redundant, A 2×2 matrix where both of the columns are equal to each other.
Formally, this kind of redundancy is known as linear dependence. A set of vectors is linearly independent if no vector in the set is a linear combination of the other vectors.
for p∈R, p≥1
The L2 norm, with p=2, is known as the Euclidean norm. It is simply the Euclidean distance from the origin to the point identified by xx.
Also, the L1 norm is commonly used in machine learning when the difference between zero and nonzero elements is very important.
The l∞ norm, also knwon as the max norm,
Diagonal matrix DD is when di,j=0 for all i≠j. For example, the identity matrix.
diag(vv) : to denote a square diagonal matrix whose diagonal entries are given by the entries of the vector vv.
A symmetric matrix is any matrix that is equal to its own transpose:
A vector xx and a vector yy are orthogonal to each other if xxTyy=0.
If the vectors are not only orthogonal but also have unit norm, we call them orthonormal.
An orthogonal matrix is a square matrix whose rows are mutually orthonormal and whose columns are mutually orthonormal:
This implies that
AA−1=AATso orthogonal matrices are of interest because their inverse is very cheap to compute.
Eigendecomposition : a kinds of matrix decomposition, in which we decompose a matrix into a set of eigenvectors and eigenvalues.
Eigenvector : An eigenvector of a square matrix AA is a non-zero vector v such that multiplication by AA alters only the scale of vv:
The scalar λ is known as the *eigenvalue corresponding to this eigenvector.
If eigenvectors {vv(1),…,vv(n)} and corresponding eigenvalues {λ1,…,λn} by concatenating the eigenvectors into a matrix VV=[vv(1),…,vv(n)] (i.e. one column per eigenvector), and concatenating the eigenvalues into a vector λ, then the matrix
has the desired eigenvalues and eigenvectors.
where QQ is an orthogonal matrix composed of eigenvectors of AA, and AA is a diagonal matrix, with λi,i being the eigenvalue corresponding to QQ:,i.
The singular value decomposition (SVD) provides another way to factorize a matrix, into singular vectors and singular values.
Every real matrix has a singular value decomposition, but the same is not true of the eigenvalue decomposition.
If a matrix is not square, the eigendecomposition is not defined, and we must use a singular value decomposition instead.
Suppose that AA is an m×n matrix. Then UU is defined to be an m×m matrix, DD to be an m×n matrix, and WW to be an n×n matrix.
The matrices UU and VV are both defined to be orthogonal matrices. The matrix DD is defined to be a diagonal matrix. Note that DD is not necessarily square.
The elements along the diagonal of DD are known as the singular values of the matrix AA. The columns of UU are known as the left-singular vectors. The columns of VV are known as the right-singular vectors.
We can actually interpret the singular value decomposition of AA in terms of the eigendecomposition of functions of AA.
The left-singular vectors of AA are the eigenvectors of AAAAT.
The right-singular vectors of AA are the eigenvectors of AATAA.
The non-zero singular values of AA are the square roots of the eigenvalues of AATAA.
Matrix inversion is not defined for matrices that are not square.
Suppose we want to make a left-inverse BB of a matrix AA, so that we can solve a linear equation
by left-multiplying each side to obtain
xx=ByBywhere UU, DD, and VV are the singular value decomposition of AA, and the pseudoinverse DD+ of a diagonal matrix DD is obtained by taking the reciprocal of all of its non-zero elements.
When AA has more rows than columns, then solving a linear equation using pseudoinverse provides one of the many possible solutions.
Specifically, it provides the solution xx=AA+yy with minimal Euclidean norm ||xx||2 among all possible solutions.
When AA has more columns than rows, it is possible for there to be no solution. In this case, using the pseudoinverse gives us the xx for which AxAx is as close as possible to yy in terms of Euclidean norm ||AxAx−yy||2.
Frobenius norm of a matrix:
The trace of a square matrix composed of many factors is also invariant to moving the last factor into the first position:
or more generally,
Tr(n∏i=1FF(i))=Tr(FF(n)n−1∏i=1FF(i))The determinant of a square matrix, denoted det(AA) is a function mapping matrices to real scalars.
The determinant is equal to the product of all the matrix's eigenvalues.
The absolute value of the determinant can be thought of as a measure of how much multiplication by the matrix expands or contracts space.
If the determinant is 0, then space is contracted completely along at least on dimension, causing it to lose all of its volume.
If the determinant is 1, then the transformation is volume-preserving.