17. SVD - Singular Value Decomposition example
( Enter your problem )
|
- Example `[[4,0],[3,-5]]`
- Example `[[1,0,1,0],[0,1,0,1]]`
- Example `[[1,1,1],[-1,-3,-3],[2,4,4]]`
- Example `[[2,3],[4,10]]`
|
Other related methods
- Transforming matrix to Row Echelon Form
- Transforming matrix to Reduced Row Echelon Form
- Rank of matrix
- Characteristic polynomial of matrix
- Eigenvalues
- Eigenvectors (Eigenspace)
- Triangular Matrix
- LU decomposition using Gauss Elimination method of matrix
- LU decomposition using Doolittle's method of matrix
- LU decomposition using Crout's method of matrix
- Diagonal Matrix
- Cholesky Decomposition
- QR Decomposition (Gram Schmidt Method)
- QR Decomposition (Householder Method)
- LQ Decomposition
- Pivots
- Singular Value Decomposition (SVD)
- Moore-Penrose Pseudoinverse
- Power Method for dominant eigenvalue
- determinants using Sarrus Rule
- determinants using properties of determinants
- Row Space
- Column Space
- Null Space
|
|
1. Example `[[4,0],[3,-5]]` (Previous example) | 3. Example `[[1,1,1],[-1,-3,-3],[2,4,4]]` (Next example) |
2. Example `[[1,0,1,0],[0,1,0,1]]`
Find Singular Value Decomposition (SVD) of a Matrix ... `[[1,0,1,0],[0,1,0,1]]`
Solution:
`A * A'`= | | `1×1+0×0+1×1+0×0` | `1×0+0×1+1×0+0×1` | | | `0×1+1×0+0×1+1×0` | `0×0+1×1+0×0+1×1` | |
|
= | | `1+0+1+0` | `0+0+0+0` | | | `0+0+0+0` | `0+1+0+1` | |
|
Find Eigen vector for `A * A'`
`|A * A'-lamdaI|=0`
| `(2-lamda)` | `0` | | | `0` | `(2-lamda)` | |
| = 0 |
`:.(2-lamda) × (2-lamda) - 0 × 0=0`
`:.(4-4lamda+lamda^2)-0=0`
`:.(lamda^2-4lamda+4)=0`
`:.(lamda-2)(lamda-2)=0`
`:.(lamda-2)=0 or(lamda-2)=0 `
`:.` The eigenvalues of the matrix A are given by `lamda=2,2`,
1. Eigenvectors for `lamda=2`
1. Eigenvectors for `lamda=2` Now, reduce this matrix The system associated with the eigenvalue `lamda=2` `=>` `:.` eigenvectors corresponding to the eigenvalue `lamda=2` is Let `x_1=1,x_2=0` Let `x_1=0,x_2=1` For Eigenvector-1 `(1,0)`, Length L = `sqrt(1^2+0^2)=1`
So, normalizing gives `u_1=(1/1,0/1)=(1,0)`
For Eigenvector-2 `(0,1)`, Length L = `sqrt(0^2+1^2)=1`
So, normalizing gives `u_2=(0/1,1/1)=(0,1)`
`A' * A`= | | `1×1+0×0` | `1×0+0×1` | `1×1+0×0` | `1×0+0×1` | | | `0×1+1×0` | `0×0+1×1` | `0×1+1×0` | `0×0+1×1` | | | `1×1+0×0` | `1×0+0×1` | `1×1+0×0` | `1×0+0×1` | | | `0×1+1×0` | `0×0+1×1` | `0×1+1×0` | `0×0+1×1` | |
|
= | | `1+0` | `0+0` | `1+0` | `0+0` | | | `0+0` | `0+1` | `0+0` | `0+1` | | | `1+0` | `0+0` | `1+0` | `0+0` | | | `0+0` | `0+1` | `0+0` | `0+1` | |
|
= | | `1` | `0` | `1` | `0` | | | `0` | `1` | `0` | `1` | | | `1` | `0` | `1` | `0` | | | `0` | `1` | `0` | `1` | |
|
`:. A' * A = ` | | `1` | `0` | `1` | `0` | | | `0` | `1` | `0` | `1` | | | `1` | `0` | `1` | `0` | | | `0` | `1` | `0` | `1` | |
|
Find Eigen vector for `A' * A`
`|A' * A-lamdaI|=0`
| `(1-lamda)` | `0` | `1` | `0` | | | `0` | `(1-lamda)` | `0` | `1` | | | `1` | `0` | `(1-lamda)` | `0` | | | `0` | `1` | `0` | `(1-lamda)` | |
| = 0 |
`:.(1-lamda) × |[(1-lamda),0,1],[0,(1-lamda),0],[1,0,(1-lamda)]|+0 × |[0,0,1],[1,(1-lamda),0],[0,0,(1-lamda)]|+1 × |[0,(1-lamda),1],[1,0,0],[0,1,(1-lamda)]|+0 × |[0,(1-lamda),0],[1,0,(1-lamda)],[0,1,0]|=0`
`:.(1-lamda) × (-2lamda+3lamda^2-lamda^3)+0 × (0)+1 × (2lamda-lamda^2)+0 × (0)=0`
`:.(-2lamda+5lamda^2-4lamda^3+lamda^4)+0+(2lamda-lamda^2)+0=0`
`:.(lamda^4-4lamda^3+4lamda^2)=0`
`:.lamda^2(lamda-2)(lamda-2)=0`
`:.lamda^2=0 or(lamda-2)=0 or(lamda-2)=0 `
`:.` The eigenvalues of the matrix A are given by `lamda=0,0,2,2`,
1. Eigenvectors for `lamda=2`
1. Eigenvectors for `lamda=2` = | | `-1` | `0` | `1` | `0` | | | `0` | `-1` | `0` | `1` | | | `1` | `0` | `-1` | `0` | | | `0` | `1` | `0` | `-1` | |
|
Now, reduce this matrix `R_1 larr R_1-:-1` = | | `1` `1=-1-:-1` `R_1 larr R_1-:-1` | `0` `0=0-:-1` `R_1 larr R_1-:-1` | `-1` `-1=1-:-1` `R_1 larr R_1-:-1` | `0` `0=0-:-1` `R_1 larr R_1-:-1` | | | `0` | `-1` | `0` | `1` | | | `1` | `0` | `-1` | `0` | | | `0` | `1` | `0` | `-1` | |
|
`R_3 larr R_3- R_1` = | | `1` | `0` | `-1` | `0` | | | `0` | `-1` | `0` | `1` | | | `0` `0=1-1` `R_3 larr R_3- R_1` | `0` `0=0-0` `R_3 larr R_3- R_1` | `0` `0=-1--1` `R_3 larr R_3- R_1` | `0` `0=0-0` `R_3 larr R_3- R_1` | | | `0` | `1` | `0` | `-1` | |
|
`R_2 larr R_2-:-1` = | | `1` | `0` | `-1` | `0` | | | `0` `0=0-:-1` `R_2 larr R_2-:-1` | `1` `1=-1-:-1` `R_2 larr R_2-:-1` | `0` `0=0-:-1` `R_2 larr R_2-:-1` | `-1` `-1=1-:-1` `R_2 larr R_2-:-1` | | | `0` | `0` | `0` | `0` | | | `0` | `1` | `0` | `-1` | |
|
`R_4 larr R_4- R_2` = | | `1` | `0` | `-1` | `0` | | | `0` | `1` | `0` | `-1` | | | `0` | `0` | `0` | `0` | | | `0` `0=0-0` `R_4 larr R_4- R_2` | `0` `0=1-1` `R_4 larr R_4- R_2` | `0` `0=0-0` `R_4 larr R_4- R_2` | `0` `0=-1--1` `R_4 larr R_4- R_2` | |
|
The system associated with the eigenvalue `lamda=2` `(A' * A-2I)` | | = | | `1` | `0` | `-1` | `0` | | | `0` | `1` | `0` | `-1` | | | `0` | `0` | `0` | `0` | | | `0` | `0` | `0` | `0` | |
| | | = | |
`=>x_1-x_3=0,x_2-x_4=0` `=>x_1=x_3,x_2=x_4` `:.` eigenvectors corresponding to the eigenvalue `lamda=2` is Let `x_3=1,x_4=0` Let `x_3=0,x_4=1`
3. Eigenvectors for `lamda=0`
3. Eigenvectors for `lamda=0` = | | `1` | `0` | `1` | `0` | | | `0` | `1` | `0` | `1` | | | `1` | `0` | `1` | `0` | | | `0` | `1` | `0` | `1` | |
|
Now, reduce this matrix `R_3 larr R_3- R_1` = | | `1` | `0` | `1` | `0` | | | `0` | `1` | `0` | `1` | | | `0` `0=1-1` `R_3 larr R_3- R_1` | `0` `0=0-0` `R_3 larr R_3- R_1` | `0` `0=1-1` `R_3 larr R_3- R_1` | `0` `0=0-0` `R_3 larr R_3- R_1` | | | `0` | `1` | `0` | `1` | |
|
`R_4 larr R_4- R_2` = | | `1` | `0` | `1` | `0` | | | `0` | `1` | `0` | `1` | | | `0` | `0` | `0` | `0` | | | `0` `0=0-0` `R_4 larr R_4- R_2` | `0` `0=1-1` `R_4 larr R_4- R_2` | `0` `0=0-0` `R_4 larr R_4- R_2` | `0` `0=1-1` `R_4 larr R_4- R_2` | |
|
The system associated with the eigenvalue `lamda=0` `(A' * A-0I)` | | = | | `1` | `0` | `1` | `0` | | | `0` | `1` | `0` | `1` | | | `0` | `0` | `0` | `0` | | | `0` | `0` | `0` | `0` | |
| | | = | |
`=>x_1+x_3=0,x_2+x_4=0` `=>x_1=-x_3,x_2=-x_4` `:.` eigenvectors corresponding to the eigenvalue `lamda=0` is Let `x_3=1,x_4=0` Let `x_3=0,x_4=1` For Eigenvector-1 `(1,0,1,0)`, Length L = `sqrt(1^2+0^2+1^2+0^2)=1.41421`
So, normalizing gives `v_1=(1/1.41421,0/1.41421,1/1.41421,0/1.41421)=(0.7071,0,0.7071,0)`
For Eigenvector-2 `(0,1,0,1)`, Length L = `sqrt(0^2+1^2+0^2+1^2)=1.41421`
So, normalizing gives `v_2=(0/1.41421,1/1.41421,0/1.41421,1/1.41421)=(0,0.7071,0,0.7071)`
For Eigenvector-3 `(-1,0,1,0)`, Length L = `sqrt((-1)^2+0^2+1^2+0^2)=1.41421`
So, normalizing gives `v_3=((-1)/1.41421,0/1.41421,1/1.41421,0/1.41421)=(-0.7071,0,0.7071,0)`
For Eigenvector-4 `(0,-1,0,1)`, Length L = `sqrt(0^2+(-1)^2+0^2+1^2)=1.41421`
So, normalizing gives `v_4=(0/1.41421,(-1)/1.41421,0/1.41421,1/1.41421)=(0,-0.7071,0,0.7071)`
`1^"st"` Solution
`:. Sigma = ` | | `sqrt(2)` | `0` | `0` | `0` | | | `0` | `sqrt(2)` | `0` | `0` | |
| `=` | | `1.41421` | `0` | `0` | `0` | | | `0` | `1.41421` | `0` | `0` | |
|
`V` is found using formula `v_i=1/sigma_i A^T*u_i`
`:. V = ` | | `0.70711` | `0` | `-0.70711` | `0` | | | `0` | `0.70711` | `0` | `-0.70711` | | | `0.70711` | `0` | `0.70711` | `0` | | | `0` | `0.70711` | `0` | `0.70711` | |
|
Or `2^"nd"` Solution
`:. Sigma = ` | | `sqrt(2)` | `0` | `0` | `0` | | | `0` | `sqrt(2)` | `0` | `0` | |
| `=` | | `1.41421` | `0` | `0` | `0` | | | `0` | `1.41421` | `0` | `0` | |
|
`:. V = ` | `[v_1,v_2,v_3,v_4]` | `=` | | `0.70711` | `0` | `-0.70711` | `0` | | | `0` | `0.70711` | `0` | `-0.70711` | | | `0.70711` | `0` | `0.70711` | `0` | | | `0` | `0.70711` | `0` | `0.70711` | |
|
`U` is found using formula `u_i=1/sigma_i A*v_i`
Verify `1^"st"` Solution `A = U Sigma V^T``U×Sigma` | = | | × | | `1.4142` | `0` | `0` | `0` | | | `0` | `1.4142` | `0` | `0` | |
|
= | | `1×1.4142+0×0` | `1×0+0×1.4142` | `1×0+0×0` | `1×0+0×0` | | | `0×1.4142+1×0` | `0×0+1×1.4142` | `0×0+1×0` | `0×0+1×0` | |
|
= | | `1.4142+0` | `0+0` | `0+0` | `0+0` | | | `0+0` | `0+1.4142` | `0+0` | `0+0` | |
|
= | | `1.4142` | `0` | `0` | `0` | | | `0` | `1.4142` | `0` | `0` | |
|
`(U × Sigma)×(V^T)` | = | | `1.4142` | `0` | `0` | `0` | | | `0` | `1.4142` | `0` | `0` | |
| × | | `0.7071` | `0` | `0.7071` | `0` | | | `0` | `0.7071` | `0` | `0.7071` | | | `-0.7071` | `0` | `0.7071` | `0` | | | `0` | `-0.7071` | `0` | `0.7071` | |
|
= | | `1.4142×0.7071+0×0+0×-0.7071+0×0` | `1.4142×0+0×0.7071+0×0+0×-0.7071` | `1.4142×0.7071+0×0+0×0.7071+0×0` | `1.4142×0+0×0.7071+0×0+0×0.7071` | | | `0×0.7071+1.4142×0+0×-0.7071+0×0` | `0×0+1.4142×0.7071+0×0+0×-0.7071` | `0×0.7071+1.4142×0+0×0.7071+0×0` | `0×0+1.4142×0.7071+0×0+0×0.7071` | |
|
= | | `1+0+0+0` | `0+0+0+0` | `1+0+0+0` | `0+0+0+0` | | | `0+0+0+0` | `0+1+0+0` | `0+0+0+0` | `0+1+0+0` | |
|
Verify `2^"nd"` Solution `A = U Sigma V^T``U×Sigma` | = | | × | | `1.4142` | `0` | `0` | `0` | | | `0` | `1.4142` | `0` | `0` | |
|
= | | `1×1.4142+0×0` | `1×0+0×1.4142` | `1×0+0×0` | `1×0+0×0` | | | `0×1.4142+1×0` | `0×0+1×1.4142` | `0×0+1×0` | `0×0+1×0` | |
|
= | | `1.4142+0` | `0+0` | `0+0` | `0+0` | | | `0+0` | `0+1.4142` | `0+0` | `0+0` | |
|
= | | `1.4142` | `0` | `0` | `0` | | | `0` | `1.4142` | `0` | `0` | |
|
`(U × Sigma)×(V^T)` | = | | `1.4142` | `0` | `0` | `0` | | | `0` | `1.4142` | `0` | `0` | |
| × | | `0.7071` | `0` | `0.7071` | `0` | | | `0` | `0.7071` | `0` | `0.7071` | | | `-0.7071` | `0` | `0.7071` | `0` | | | `0` | `-0.7071` | `0` | `0.7071` | |
|
= | | `1.4142×0.7071+0×0+0×-0.7071+0×0` | `1.4142×0+0×0.7071+0×0+0×-0.7071` | `1.4142×0.7071+0×0+0×0.7071+0×0` | `1.4142×0+0×0.7071+0×0+0×0.7071` | | | `0×0.7071+1.4142×0+0×-0.7071+0×0` | `0×0+1.4142×0.7071+0×0+0×-0.7071` | `0×0.7071+1.4142×0+0×0.7071+0×0` | `0×0+1.4142×0.7071+0×0+0×0.7071` | |
|
= | | `1+0+0+0` | `0+0+0+0` | `1+0+0+0` | `0+0+0+0` | | | `0+0+0+0` | `0+1+0+0` | `0+0+0+0` | `0+1+0+0` | |
|
This material is intended as a summary. Use your textbook for detail explanation. Any bug, improvement, feedback then
1. Example `[[4,0],[3,-5]]` (Previous example) | 3. Example `[[1,1,1],[-1,-3,-3],[2,4,4]]` (Next example) |
|
|
|