Jephian Lin
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 矩陣對角化 Diagonalization ![Creative Commons License](https://i.creativecommons.org/l/by/4.0/88x31.png) This work by Jephian Lin is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/). $\newcommand{\trans}{^\top} \newcommand{\adj}{^{\rm adj}} \newcommand{\cof}{^{\rm cof}} \newcommand{\inp}[2]{\left\langle#1,#2\right\rangle} \newcommand{\dunion}{\mathbin{\dot\cup}} \newcommand{\bzero}{\mathbf{0}} \newcommand{\bone}{\mathbf{1}} \newcommand{\ba}{\mathbf{a}} \newcommand{\bb}{\mathbf{b}} \newcommand{\bc}{\mathbf{c}} \newcommand{\bd}{\mathbf{d}} \newcommand{\be}{\mathbf{e}} \newcommand{\bh}{\mathbf{h}} \newcommand{\bp}{\mathbf{p}} \newcommand{\bq}{\mathbf{q}} \newcommand{\br}{\mathbf{r}} \newcommand{\bx}{\mathbf{x}} \newcommand{\by}{\mathbf{y}} \newcommand{\bz}{\mathbf{z}} \newcommand{\bu}{\mathbf{u}} \newcommand{\bv}{\mathbf{v}} \newcommand{\bw}{\mathbf{w}} \newcommand{\tr}{\operatorname{tr}} \newcommand{\nul}{\operatorname{null}} \newcommand{\rank}{\operatorname{rank}} %\newcommand{\ker}{\operatorname{ker}} \newcommand{\range}{\operatorname{range}} \newcommand{\Col}{\operatorname{Col}} \newcommand{\Row}{\operatorname{Row}} \newcommand{\spec}{\operatorname{spec}} \newcommand{\vspan}{\operatorname{span}} \newcommand{\Vol}{\operatorname{Vol}} \newcommand{\sgn}{\operatorname{sgn}} \newcommand{\idmap}{\operatorname{id}} \newcommand{\am}{\operatorname{am}} \newcommand{\gm}{\operatorname{gm}} \newcommand{\mult}{\operatorname{mult}} \newcommand{\iner}{\operatorname{iner}}$ ```python from lingeo import random_int_list, random_good_matrix ``` ## Main idea We know that an $n\times n$ matrix is diagonalizable if and only if there is a basis of $\mathbb{R}^n$ composed of eigenvectors. We also know how to find the eigenvalues through the characteristic polynomial. Indeed, that is all we need to perform the diagonalization of a matrix. Let $A$ be an $n\times n$ matrix. Here are the steps for its diagonalization: 1. Calculate the characteristic polynomial $p_A(x) = \det(A - xI)$ and solve the roots for $\spec(A)$. 2. For each $\lambda\in\spec(A)$, find a basis $\beta_\lambda$ for $\ker(A - \lambda I)$. 3. Let $\beta$ be the union of all such $\beta_\lambda$. 4. If $\beta$ is a basis of $\mathbb{R}^n$, then $A$ can be diagonalized through $\beta$. That is, $[f_A]_\beta^\beta = D$ is a diagonal matrix. Equivalently, $D = Q^{-1}AQ$, where $Q$ is the matrix whose columns are the vectors in $\beta$. ##### Remark If $\beta = \{\bv_1, \ldots, \bv_n\}$ is a basis of $\mathbb{R}^n$ such $\bv_i$ is an eigenvector of $A$ with respect to $\lambda_i$ for all $i$. Then the equalities $A\bv_i = \lambda_i\bv_i$ is equivalent to $$ AQ = A\begin{bmatrix} | & ~ & | \\ {\bf v}_1 & \cdots & {\bf v}_n \\ | & ~ & | \end{bmatrix} = \begin{bmatrix} | & ~ & | \\ \lambda_1{\bf v}_1 & \cdots & \lambda_n{\bf v}_n \\ | & ~ & | \end{bmatrix} = \begin{bmatrix} | & ~ & | \\ {\bf v}_1 & \cdots & {\bf v}_n \\ | & ~ & | \end{bmatrix} \begin{bmatrix} \lambda_1 & ~ & ~ \\ ~ & \ddots & ~ \\ ~ & ~ & \lambda_n \end{bmatrix} = QD. $$ ##### Remark The above process might not able to finish for a few different reasons: - The root of $p_A(x)$ might not be real. If we instite the basis should be using real vectors, then it cannot be done. - It is possible that $\beta_\lambda$ does not provide enough independent eigenvectors, so $\beta$ is not a bsis of $\mathbb{R}^n$. Here is an example of diagonalizing $$ A = \begin{bmatrix} 2 & 3 \\ 3 & 2 \end{bmatrix}. $$ _Solve for the eigenvalues_: The characteristic polynomial of $A$ is $$ p_A(x) = \det\begin{bmatrix} 2 - x & 3 \\ 3 & 2 - x \end{bmatrix} = x^2 - 4x - 5, $$ which as roots $-1, 5$. _Solve for the eigenvectors_: For $\lambda = 5$, calculate the basis of $\ker(A - 5I)$ and get $$ \ker(A - 5I) = \ker \begin{bmatrix} -3 & 3 \\ 3 & -3 \end{bmatrix} = \vspan\left\{\begin{bmatrix} 1 \\ 1 \end{bmatrix}\right\}. $$ For $\lambda = -1$, calculate the basis of $\ker(A + I)$ and get $$ \ker(A + I) = \ker \begin{bmatrix} 3 & 3 \\ 3 & 3 \end{bmatrix} = \vspan\left\{\begin{bmatrix} 1 \\ -1 \end{bmatrix}\right\}. $$ By setting $$ \beta = \left\{ \begin{bmatrix} 1 \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ -1 \end{bmatrix}\right\} \text{ and } Q = \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}, $$ we get $$ [f_A]_\beta^\beta = Q^{-1}AQ = \begin{bmatrix} 5 & 0 \\ 0 & -1 \end{bmatrix}. $$ ## Side stories - Jordan block - discrete Fourier transform ## Experiments ##### Exercise 1 執行以下程式碼。 <!-- eng start --> Run the code below. <!-- eng end --> ```python ### code set_random_seed(0) print_ans = False n = 3 spec = random_int_list(n, 3) D = diagonal_matrix(spec) Q = random_good_matrix(n,n,n,2) A = Q * D * Q.inverse() pretty_print(LatexExpr("A ="), A) pA = (-1)^n * A.charpoly() print("characteristic polyomial =", pA) print(" =", factor(pA)) if print_ans: print("eigenvalues are:" + ", ".join("%s"%val for val in spec)) print("corresponding eigenvectors are:") for i in range(n): pretty_print(LatexExpr(r"\lambda ="), spec[i], ", eigenvector =", Q[:,i]) pretty_print(LatexExpr("Q ="), Q) ``` ##### Exercise 1(a) 求出 $A$ 的所有特徵值。 <!-- eng start --> Find all the eigenvalues of $A$. <!-- eng end --> ##### Exercise 1(b) 對每個特徵值,求出對應的特徵向量。 <!-- eng start --> For each of the eigenvalues, find the corresponding eigenvector. <!-- eng end --> ##### Exercise 1(c) 求出 $Q$ 使得 $D = Q^{-1}AQ$ 是一個對角矩陣。 <!-- eng start --> Find a matrix $Q$ such that $D = Q^{-1}AQ$ is a diagonal matrix. <!-- eng end --> :::info What do the experiments try to tell you? (open answer) ... ::: ## Exercises ##### Exercise 2 將以下矩陣 $A$ 對角化。 (求出可逆矩陣 $Q$ 和對角矩陣 $D$ 使得 $D = Q^{-1}AQ$。) <!-- eng start --> Diagonalize the following matrices $A$. (That is, find an invertible matrix $Q$ and a diagonal matrix $D$ such that $D = Q^{-1}AQ$.) <!-- eng end --> ##### Exercise 2(a) $$ A = \begin{bmatrix} 0 & 1 \\ -6 & 5 \end{bmatrix}. $$ ##### Exercise 2(b) $$ A = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}. $$ ##### Exercise 3 將以下矩陣 $A$ 對角化。 (求出可逆矩陣 $Q$ 和對角矩陣 $D$ 使得 $D = Q^{-1}AQ$。) <!-- eng start --> Diagonalize the following matrices $A$. (That is, find an invertible matrix $Q$ and a diagonal matrix $D$ such that $D = Q^{-1}AQ$.) <!-- eng end --> ##### Exercise 3(a) $$ A = \begin{bmatrix} 4 & 0 & -1 \\ 0 & 4 & -1 \\ -1 & -1 & 5 \end{bmatrix}. $$ ##### Exercise 3(b) $$ A = \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 6 & -11 & 6 \end{bmatrix}. $$ ##### Exercise 3(c) $$ A = \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 1 & 0 & 0 \end{bmatrix}. $$ ##### Exercise 4 將以下矩陣 $A$ 對角化, 並說明 $f_A$ 的作用。 <!-- eng start --> Diagonalize the following matrices $A$ and describe the effect of $f_A$. <!-- eng end --> ##### Exercise 4(a) $$ A = \begin{bmatrix} \frac{2}{3} & -\frac{1}{3} & -\frac{1}{3} \\ -\frac{1}{3} & \frac{2}{3} & -\frac{1}{3} \\ -\frac{1}{3} & -\frac{1}{3} & \frac{2}{3} \end{bmatrix}. $$ ##### Exercise 4(b) $$ A = \begin{bmatrix} \frac{1}{3} & -\frac{2}{3} & -\frac{2}{3} \\ -\frac{2}{3} & \frac{1}{3} & -\frac{2}{3} \\ -\frac{2}{3} & -\frac{2}{3} & \frac{1}{3} \end{bmatrix}. $$ ##### Exercise 5 令 $$ A = \begin{bmatrix} 3 & 1 & 0 \\ 0 & 3 & 1 \\ 0 & 0 & 3 \end{bmatrix}. $$ 說明 $A$ 矩陣只有一個特徵值 $3$(重根三次), 但 $\ker(A - 3I)$ 的維度只有 $1$, 找不到足夠的特徵向量將 $A$ 對角化。 <!-- eng start --> Let $$ A = \begin{bmatrix} 3 & 1 & 0 \\ 0 & 3 & 1 \\ 0 & 0 & 3 \end{bmatrix}. $$ Show that $A$ only has one eigenvalue $3$ (repeated three times), but $\ker(A - 3I)$ has dimension $1$ and we do not have enough independent eigenvectors to diagonalize $A$. <!-- eng end --> ##### Exercise 6 令 $$ A = \begin{bmatrix} 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ 1 & 0 & 0 & 0 & 0 \end{bmatrix} $$ 並令 $\zeta = e^{\frac{2\pi}{5}i}$ 為 $1$ 的五次方根。 這個練習告訴我們,如果運氣很好有找到所有的特徵向量,則不見得要解特徵多項式也可以找得到 $\spec(A)$。 <!-- eng start --> Let $$ A = \begin{bmatrix} 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \\ 1 & 0 & 0 & 0 & 0 \end{bmatrix} $$ and let $\zeta = e^{\frac{2\pi}{5}i}$ be the fifth roots of $1$. Through the following exercises, we will see that $\spec(A)$ can also be found by the eigenvectors (if we know them by luck) rather than the characteristic polynomial. <!-- eng end --> ##### Exercise 6(a) 令 $$ Q = \begin{bmatrix} 1 & 1 & 1 & 1 & 1 \\ 1 & \zeta & \zeta^2 & \zeta^3 & \zeta^4 \\ 1 & \zeta^2 & \zeta^4 & \zeta^6 & \zeta^8 \\ 1 & \zeta^3 & \zeta^6 & \zeta^9 & \zeta^{12} \\ 1 & \zeta^4 & \zeta^8 & \zeta^{12} & \zeta^{16} \\ \end{bmatrix}. $$ 驗證 $Q^*Q = 5I_5$, 因此 $Q$ 可逆且其行向量集合是一組 $\mathbb{C}^5$ 的基底。 (這裡 $Q^*$ 的意思是將 $Q$ 轉置後再逐項取共軛。) <!-- eng start --> Let $$ Q = \begin{bmatrix} 1 & 1 & 1 & 1 & 1 \\ 1 & \zeta & \zeta^2 & \zeta^3 & \zeta^4 \\ 1 & \zeta^2 & \zeta^4 & \zeta^6 & \zeta^8 \\ 1 & \zeta^3 & \zeta^6 & \zeta^9 & \zeta^{12} \\ 1 & \zeta^4 & \zeta^8 & \zeta^{12} & \zeta^{16} \\ \end{bmatrix}. $$ Verify that $Q^*Q = 5I_5$. Therefore, $Q$ is invertible and it columns form a basis of $\mathbb{C}^5$. (Here $Q^*$ is the conjugate transpose of $Q$.) <!-- eng end --> ##### Exercise 6(b) 說明 $Q$ 的每個行向量都是 $A$ 的特徵向量,並找出對應的特徵值。 利用這點將 $A$ 對角化。 <!-- eng start --> Show that each column of $Q$ is an eigenvector of $A$ and find the corresponding eigenvalue. Use them to diagonalize $A$. <!-- eng end -->

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully