SQCS教育工作室
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
    • 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 No publishing access yet

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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
    • Make a copy
    • Transfer ownership
    • Delete this note
    • 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 Help
Menu
Options
Make a copy 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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
  • 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 量子邏輯閘(單 Qubit) 在上一節中,我們介紹如何用矩陣描述單一個 qubit 的量子態,與經典電腦相似,我們可以使用邏輯閘改變 qubit 的狀態。在量子計算中,這些邏輯閘稱作「量子閘」(quantum gate 或 quantum logical gate)。在這一節,我們先著重在只能改變一個 qubit 狀態的 quantum gate。 <div style="text-align: center;"> <img src="https://hackmd.io/_uploads/H1ffNCuvA.svg" alt="single qubit quantum gate" width="70%"/> <br> <p> </p> </div> ## 常見的單 qubit 量子閘(single qubit quantum gate) ### Identity gate(I gate) <div style="text-align: center;"> <img src="https://hackmd.io/_uploads/BJuEmY4hC.svg" alt="I gate" width="40%"/> <br> <p>I gate 的符號 </p> </div> I gate 使用符號 $I$ 表示,類似經典電腦中的 identity gate,輸入什麼就輸出什麼: \begin{split} I|0\rangle=|0\rangle \\ I|1\rangle=|1\rangle \end{split} 以矩陣表示 \begin{split} I= \begin{bmatrix} 1 & 0\\ 0 & 1 \end{bmatrix} \end{split} 可以做個簡單的驗證 \begin{split} I|0\rangle= \begin{bmatrix} 1 & 0\\ 0 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix}= \begin{bmatrix} 1 \\ 0 \end{bmatrix}\\ I|1\rangle= \begin{bmatrix} 1 & 0\\ 0 & 1 \end{bmatrix} \begin{bmatrix} 0 \\ 1 \end{bmatrix}= \begin{bmatrix} 0 \\ 1 \end{bmatrix} \end{split} ### X gate X gate 相當於經典邏輯閘中的 NOT gate,符號為 $X$: <div style="text-align: center;"> <img src="https://hackmd.io/_uploads/H1QEzVP2A.svg" alt="X gate" width="40%"/> <br> <p>以上這兩個都是 X gate 的符號 </p> </div> 以矩陣表示: \begin{split} X= \begin{bmatrix} 0 & 1\\ 1 & 0 \end{bmatrix} \end{split} X gate 會將 $|0\rangle$ 變成 $|1\rangle$,將 $|1\rangle$ 變成 $|0\rangle$ \begin{split} X|0\rangle = |1\rangle\\ X|1\rangle = |0\rangle \end{split} 對處於疊加態的 qubit $|\psi\rangle$ 做 X 操作會是: \begin{split} X|\psi\rangle &= X(\alpha|0\rangle+\beta|1\rangle)\\ &=\alpha X|0\rangle+\beta X|1\rangle\\ &=\alpha|1\rangle+\beta|0\rangle \\ &=\beta|0\rangle + \alpha|1\rangle \end{split} 有時候會把 X gate 寫成這樣 \begin{split} X=|0\rangle \langle 1|+|1\rangle \langle 0| \end{split} 做個簡單的驗證 \begin{split} X|0\rangle &= (|0\rangle \langle 1|+|1\rangle \langle 0|)|0\rangle \\ &=|0\rangle \langle 1|0\rangle+|1\rangle \langle 0|0\rangle \\ &=|0\rangle 0+|1\rangle1 \\ &=|1\rangle \end{split} 很明顯地,連續做兩個 X gate 操作,qubit 狀態會變回原本的狀態,因為 \begin{split} XX|\psi\rangle&= \begin{bmatrix} 0 & 1\\ 1 & 0 \end{bmatrix} \begin{bmatrix} 0 & 1\\ 1 & 0 \end{bmatrix} |\psi\rangle \\ &=I|\psi\rangle \\ &=|\psi\rangle \end{split} ### Y gate <div style="text-align: center;"> <img src="https://hackmd.io/_uploads/HJTj7YVnR.svg" alt="Y gate" width="40%"/> <br> <p>Y gate 的符號 </p> </div> Y gate 的矩陣為: \begin{split} Y= \begin{bmatrix} 0 & -i\\ i & 0 \end{bmatrix}=i \begin{bmatrix} 0 & -1\\ 1 & 0 \end{bmatrix} \end{split} 也可以寫成這樣 \begin{split} Y=i(|1\rangle \langle 0|-|0\rangle \langle 1|) \end{split} Y gate 將 qubit 從 $|0\rangle$ 變成 $i|1\rangle$,將 $|1\rangle$ 變成 $-i|0\rangle$: \begin{split} Y|0\rangle &= i|1\rangle\\ Y|1\rangle &= -i|0\rangle \end{split} 對一個處於疊加態的 qubit $|\psi\rangle$ 做 Y 操作後: \begin{split} Y|\psi\rangle &= Y(\alpha|0\rangle+\beta|1\rangle)\\ &=i\alpha|1\rangle-i\beta|0\rangle \\ &=-i\beta|0\rangle+i\alpha|1\rangle \end{split} 我們把機率幅做絕對值平方後做加總,看總機率會是多少 \begin{split} |-i\beta|^2+|i\alpha|^2&=(-i\beta)^* (-i\beta)+(i\alpha)^* (i\alpha)\\ &=(i\beta^* ) (-i\beta)+(-i\alpha^*) (i\alpha) \\ &=\beta^* \beta+\alpha^* \alpha \\ &=|\beta|^2+|\alpha|^2 \\ &=1 \end{split} 總機率仍然會是 100%。 ### Z gate <div style="text-align: center;"> <img src="https://hackmd.io/_uploads/B17lEK42R.svg" alt="Z gate" width="40%"/> <br> <p>Z gate 的符號 </p> </div> 以矩陣表示 \begin{split} Z= \begin{bmatrix} 1 & 0\\ 0 & -1 \end{bmatrix} \end{split} 也可以寫成這樣 \begin{split} Z=(|0\rangle \langle 0|-|1\rangle \langle 1|) \end{split} 它對 qubit 的影響 \begin{split} Z|0\rangle &= |0\rangle\\ Z|1\rangle &= -|1\rangle \end{split} 對一個處於疊加態的 qubit $|\psi\rangle$ 做 Z 操作會是 \begin{split} Z|\psi\rangle &= Z(\alpha|0\rangle+\beta|1\rangle)\\ &=\alpha|0\rangle-\beta|1\rangle \end{split} ## Pauli gate 以上 X, Y, Z gate(有些人會算把 I gate 也算進來)統稱為 Pauli gate,這是因為這三個矩陣剛好對應量子力學中 $SU(2)$ 群的 generator。 <blockquote> 不了解 SU(2) 與 generator 並不影響往後的閱讀,這已經到量子場論程度,有興趣的讀者可以參看 Lie algebra </blockquote> 以下是這三個 gate 的關係 \begin{split} X^2&=Y^2=Z^2=I \\ Y&=iXZ \\ XY&=-YX \\ ZY&=-YZ \\ XYX&=iZX=-Y \end{split} <blockquote> 可以自己在紙上,用矩陣做證明 </blockquote> \begin{split} XZ&=-ZX \\ ZXZ&=-X \\ ZYZ&= -Y \\ ZZZ&=Z \end{split} ## Hadamard gate (H gate) Hadamard gate 是量子計算中最常用到的 gate 之一,常常會是電路中第一個用到的 gate。 <div style="text-align: center;"> <img src="https://hackmd.io/_uploads/SJXMVYVhR.svg" alt="H gate" width="40%"/> <br> <p>H gate 的符號 </p> </div> H gate 以矩陣表示 \begin{split} H=\frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1\\ 1 & -1 \end{bmatrix}= \begin{bmatrix} \frac{\sqrt{2}}{2} & \frac{\sqrt{2}}{2}\\ \frac{\sqrt{2}}{2} & -\frac{\sqrt{2}}{2} \end{bmatrix} =\frac{1}{\sqrt 2}(X+Z) \end{split} 也可以寫成這樣 \begin{split} H&=\frac{1}{\sqrt{2}}(|0\rangle\langle 0|+|1\rangle\langle 0|+|0\rangle\langle 1|-|1\rangle\langle 1|)\\ &= \frac{1}{\sqrt 2} \sum_{x,y\in \left\{ 0,1 \right\}} (-1)^{x\cdot y}|x\rangle\langle y| \end{split} <blockquote> 最後一條式子看不懂的話,可以將 x 與 y 一個一個代入 0 或 1 </blockquote> H gate 會將 qubit 從 $|0\rangle$ 或 $|1\rangle$ 變成疊加態: \begin{split} H|0\rangle = \frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)=|+\rangle\\ H|1\rangle = \frac{1}{\sqrt{2}}(|0\rangle-|1\rangle)=|-\rangle \end{split} H gate 會將 qubit 從 $|0\rangle$ 或 $|1\rangle$ 進入疊加態。上式還可以簡寫成: \begin{split} H|u\rangle=\frac{1}{\sqrt{2}}(|0\rangle+(-1)^u|1\rangle) \qquad \text{where}\quad u\in\{0,1\} \end{split} 可以將 $u$ 代 $0$ 或 $1$ 進上式驗證看看。當對疊加態(如 $|+\rangle$ 和 $|-\rangle$)做 H gate 操作時,會: \begin{split} H|+\rangle&=H\frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)\\ &=\frac{1}{\sqrt{2}}(H|0\rangle+H|1\rangle) \\ &=\frac{1}{\sqrt{2}}[\frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)+\frac{1}{\sqrt{2}}(|0\rangle-|1\rangle)] \\ &=\frac{1}{2}(|0\rangle+|1\rangle+|0\rangle-|1\rangle)\\ &= |0\rangle \end{split} 這是因為 \begin{split} H|+\rangle&=HH|0\rangle \\ &=I|0\rangle \\ &=|0\rangle \end{split} 同理 \begin{split} H|-\rangle&=HH|1\rangle\\ &= |1\rangle \end{split} 另外 \begin{split} H^2&=I \\ HXH&=Z \\ HYH&= -Y \\ HZH&=X \end{split} ## Phase shift gate 下面要介紹的兩個 gate,與 Z gate 合稱為 phase shift gate。因為他們不會影響 qubit 的量子態本身,只會改變量子態的相位(機率幅的負數或虛數) ### S gate 又稱為 phase gate,連續做兩個 S gate 就是 Z gate <div style="text-align: center;"> <img src="https://hackmd.io/_uploads/rJtV4YEh0.svg" alt="S gate" width="40%"/> <br> <p>S gate 的符號 </p> </div> \begin{split} S&= \begin{bmatrix} 1 & 0\\ 0 & i \end{bmatrix}= \sqrt{Z} \\ &= e^{\frac{\pi}{4}} \begin{bmatrix} e^{-i\frac{\pi}{4}} & 0\\ 0 & e^{i\frac{\pi}{4}} \end{bmatrix} \end{split} 因此又稱為 $R^Z_{\frac{\pi}{2}}$ gate,或 $\frac{\pi}{4}$ gate。它對 qubit 的影響: \begin{split} S|0\rangle = |0\rangle\\ S|1\rangle = i|1\rangle \end{split} 其中 \begin{split} SXS^{\dagger}=Y \\ SYS^{\dagger}=-X \\ SZS^{\dagger}=Z \end{split} ### T gate <div style="text-align: center;"> <img src="https://hackmd.io/_uploads/SkT44KN3R.svg" alt="T gate" width="40%"/> <br> <p>T gate 的符號 </p> </div> 又稱為 $\frac{\pi}{8}$ gate,連續做兩個 T gate 就是 S gate \begin{split} T&= \begin{bmatrix} 1 & 0\\ 0 & e^{i\frac{\pi}{4}} \end{bmatrix}= \sqrt{S} \\ &= e^{\frac{\pi}{8}} \begin{bmatrix} e^{-i\frac{\pi}{8}} & 0\\ 0 & e^{i\frac{\pi}{8}} \end{bmatrix} \end{split} 它對 qubit 的影響: \begin{split} T|0\rangle = |0\rangle\\ T|1\rangle = e^{i\frac{\pi}{4}}|1\rangle \end{split}

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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