Loading [MathJax]/jax/output/HTML-CSS/jax.js
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

33.1: Matrix Decomposition

( \newcommand{\kernel}{\mathrm{null}\,}\)

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

%matplotlib inline
import matplotlib.pylab as plt
import numpy as np
import sympy as sym
sym.init_printing(use_unicode=True)
%matplotlib inline
import matplotlib.pylab as plt
import numpy as np
import sympy as sym
sym.init_printing(use_unicode=True)
Do This

Watch the following video and answer the questions below.

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

from IPython.display import YouTubeVideo
YouTubeVideo("-_2he4J6Xxw",width=640,height=360, cc_load_policy=True)
from IPython.display import YouTubeVideo
YouTubeVideo("-_2he4J6Xxw",width=640,height=360, cc_load_policy=True)

Consider the following code to calculate the A=QΛQ1 eivendecomposition.

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

# Here is our input matrix
A = np.matrix([[15,7,-7],[-1,1,1],[13,7,-5]])
sym.Matrix(A)
# Here is our input matrix
A = np.matrix([[15,7,-7],[-1,1,1],[13,7,-5]])
sym.Matrix(A)

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

# Calculate eigenvalues and vectors using Numpy
e, Q = np.linalg.eig(A)
print(e)
sym.Matrix(Q)
# Calculate eigenvalues and vectors using Numpy
e, Q = np.linalg.eig(A)
print(e)
sym.Matrix(Q)

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

#Turn eigenvalues into a diagonal matrix  (there is even a function for that!)
L = np.diag(e)
sym.Matrix(L)
#Turn eigenvalues into a diagonal matrix  (there is even a function for that!)
L = np.diag(e)
sym.Matrix(L)

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

# Calculate A again from Q and L

A2 = Q*L*np.linalg.inv(Q)

sym.Matrix(A2)
# Calculate A again from Q and L

A2 = Q*L*np.linalg.inv(Q)

sym.Matrix(A2)
Do This

Using code, verify that A2 is the same as A.

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

# Put your answer here
# Put your answer here
Do This

Turn the above code into a function called eigendecomp which takes in a matrix A and returns Q and L.

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

# Put your code here
# Put your code here
Question

What other decompositions have we covered in the class so far? Make a list and write down a short description on why we use each decomposition.


This page titled 33.1: Matrix Decomposition is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform.

Support Center

How can we help?