Ya-Wen Jeng
    • 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
      • Invitee
    • 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
    • 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 Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync 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
Invitee
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
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Shor's Algorithm - factor a number ### Fourier Transform - classical Fourier transform - input: $x_0,x_1...,x_{n-1}$ - output: $y_0,y_1...,y_{n-1}$ - Definition: $$y_k=\frac{1}{\sqrt{N}}\sum_{j=0}^{N-1}x_j e^{2\pi i j\cdot k/N}=\frac{1}{\sqrt{N}}\sum_{j=0}^{N-1} \omega_N^{jk}x_j$$ - cost? - naive: $O(N^2)$ for $N$-vector - more efficient: Fast Fourier Transform (FFT): $O(n\log n)$ - Quantum Fourier transform (QFT) - acts on **orthonormal basis** $|0\rangle,|1\rangle,...,|N-1\rangle$ $$|y_k\rangle=\frac{1}{\sqrt{N}}\sum_{k=0}^{N-1}e^{2\pi i j\cdot k/N}|k\rangle$$ - If start at a basis state, **no entanglement** will be created (results in a product state) - Resources of $n$-qubit QFT gate: - $O(n)$ hadamard gates - $O(n^2)$ single qubit rotation gates (2 CNOT each) - at most $n/2$ swap gate: $O(n)$ (3 CNOT each) > $O(n^2)$ Quantum Algorithm - classical FFT: $O(n2^n)$ - QFT provdes an **exponential** speed up > QFT is <ins>not</ins> an algorithm to speed up classical transformation > **Problem:** No way known to **access the amplitude** in quantum computer. > No way known to **prepare efficiently original state** to be transformed. > *an ingredient of other quantum algorithm* ### Phase Estimation - make use of QFT - Setting: - $U$: unitary - eigenvector $|u\rangle$ with eigenvalues $e^{2\pi i\varphi}$, where $\varphi$ is unknown - **Goal:** to estimate $\varphi, \varphi\in[0,1]$ - Assumption: - can prepare $|u\rangle$ - can perform controlled-$U^{2^j}$ - **Algorithm:** 1. 1-st register prepare $t$ qubits $|0\rangle$, where $t$ depends on - precision - success probability 2-nd register begin in $|u\rangle$, contains as many qubits as needed to store $|u\rangle$ $$|0\rangle|u\rangle$$ 2. Hadamard gates to 1-st register $$|0\rangle|u\rangle\xrightarrow[]{H}\frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)|u\rangle$$ 3. Controlled-$U^{2^j}$ on 2-nd register $$\begin{aligned}\frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)|u\rangle\xrightarrow[]{c-U^{2^j}}&\frac{1}{\sqrt{2}}|0\rangle|u\rangle+\frac{1}{\sqrt{2}}U^{2^j}|1\rangle|u\rangle\\ =&\frac{1}{\sqrt{2}}|0\rangle|u\rangle+\frac{1}{\sqrt{2}}e^{2\pi i 2^j\varphi}|1\rangle|u\rangle\\ =& \frac{1}{\sqrt{2}}(|0\rangle+e^{2\pi i 2^j\varphi}|1\rangle)|u\rangle \end{aligned}$$ - $t$-qubit $$\frac{1}{\sqrt{2^t}}\sum_{k=0}^{2^t-1}e^{2\pi i\varphi k}|k\rangle$$ - suppose $\varphi=0.\varphi_1...\varphi_t$ $$\frac{1}{\sqrt{2^t}}(|0\rangle+e^{2\pi i\cdot 0.\varphi_t}|1\rangle)(|0\rangle+e^{2\pi i\cdot 0.\varphi_t\varphi_{t-1}}|1\rangle)...(|0\rangle+e^{2\pi i\cdot 0.\varphi_t...\varphi_1}|1\rangle)$$ The Fourier transform of $|\varphi\rangle=|\varphi_1\rangle|\varphi_2\rangle...|\varphi_t\rangle$ 4. apply inverse QFT to the 1-st register $$\frac{1}{\sqrt{2^t}}\sum_{k=0}^{2^t-1}e^{2\pi i\varphi k}|k\rangle|u\rangle\xrightarrow[]{FT^\dagger}|e\rangle|u\rangle$$ 5. measure the qubits of first register in computational basis - **Discuss:** - To achieve accuracy $2^{-n}$ with probability $(1-\varepsilon)$ $$t=n+\lceil\log(2+\frac{1}{2\varepsilon})\rceil$$ - What if we cannot prepare the eigenstates $|u\rangle$? $$|\psi\rangle=\sum_u C_u|u\rangle$$ After the estimation, we get $$\sum_u C_u |\tilde{\varphi_u}\rangle|u\rangle$$ where $\tilde{\varphi_u}$ is a good approximation to the eigenvalue $\varphi_u$ with probability $|C_u|^2$ we get $\tilde{\varphi_u}$ If we do it many times, we can avoid the requirement of preparing $|u\rangle$ ### Order Finding - output $r$ where $x^r=1\text{ mod }N$ - is a hard problem in classical computer (no polynomial time algorithm) - in quantum computer, it is the phase estimation algorithm applied to the unitary $$U|y\rangle=|xy\ (\text{ mod }N)\rangle$$ $y$ is an $b$-qubit state - construct $$|u_s\rangle=\frac{1}{\sqrt{r}}\sum_{k=0}^r\text{exp}(-\frac{2\pi i s k}{r})|x^k\text{ mod }N\rangle$$ For integer $s$, $|u_s\rangle$ are eigenstates of $U$. $$U|u_s\rangle=\text{exp}(\frac{2\pi i s}{r})|u_s\rangle$$ so $\text{exp}(\frac{2\pi i s}{r})$ is the eigenvalue of $|u_s\rangle$ This allows us to estimate $\frac{s}{r}=\varphi$ $\Rightarrow$ with the addition work to access order $r$ - **Problem:** not allowed to use $r$, we cannot prepare $|u_s\rangle$ - $\Rightarrow$ $$\frac{1}{\sqrt{r}}\sum_{s=0}^{r-1}|u_s\rangle=|x^0(\text{ mod }N)\rangle=|1\rangle$$ $|1\rangle$ is trivial to prepare - **Algorithm:** 1. prepare 1-st register with $t$ qubits $|0\rangle$ prepare 2-nd regester with $|1\rangle$ 2. run phase estimation 3. measuring the first registers - for each $s$ in the range of $1$ to $r$, this will lead to an estimation of the phase $\varphi=s/r$ - accuracy: $2L+1$ bits - probability $(1-\varepsilon)/r$ - "$/r$" because don't know which $|u_s\rangle$ $$\frac{1}{\sqrt{r}}\sum_{s=0}^{r-1}|u_s\rangle$$ entangled with the second register when measuring. - **moduler exponentiation** - speed up exponentiation $|z\rangle|x^z\rangle$ - use the third temporary registers - <ins>reversible computing</ins> - $O(L)$ spanning operations $O(L^2)$ standard multiplication for each operation $\Rightarrow$ total $O(L^3)$ operations - How to get $r$ from the output $\varphi$ 4. run continued function algorithm (on a classical computer) - **Continued Fraction Algorithm** - a rational number $s/r$ such that $$\left|\frac{s}{r}-\varphi\right|\leq\frac{1}{2r^2}$$ then $s/r$ is a convergence of the continued fraction for $\varphi$, and can be calculated in $O(L^3)$ steps - idea: express the number as $$[a_0,a_1,...,a_M]=a_0+\frac{1}{a_1+\frac{1}{a_2+\frac{1}{...+\frac{1}{a_M}}}}$$ - check $[a_0],[a_0,a_1],...[a_0,...a_M]$ which satisfies $s/r$ - the algorithm provides efficiently $s'/r'$ - **complexity** - Hadamard gates: $O(L)$ - Inverse FT: $O(L^2)$ - Modular exponentiation: $O(L^3)$ - classical continued fraction algorithm: $O(L^3)$ - If order finding fails, one has to repeat only for a *constant* number to obtain $r$ with high probability: $O(1)$ $\Rightarrow$ overall cost: $O(L^3)$ > can be reduced to almost $O(L^2)$ by square-and-multiply ### Shor's Algorithm - Factoring $N$ to two prime numbers - reduce factoring to order finding - If we have $$y^2=1\text{ mod }N\\ (y-1)(y+1)=0\text{ mod }N=k\cdot N$$ If $y\neq \pm1\text{ mod }N$, then $$\text{gcd}(y+1,N)\\\text{gcd}(y-1,N)$$ must each be a proper divisor of $N$, i.e. prime factors. - How can we find a non-trivial square root $y$? 1. choose a random $1< x\leq N-1$ 2. run the order finding algorithm to find $r$, $x^r=1\text{ mod }N$ - If $r$ is even: $$\begin{aligned} x^r&=1\text{ mod }N\\ (x^{r/2}+1)(x^{r/2}-1)&=0\text{ mod }N=k\cdot N \end{aligned}$$ then $y=x^{r/2}$ is a square root of $1$ and if $x^{r/2}\neq \pm 1$, then compute gcd > success probability to find a "good" $x$? > "good": order $r$ is even and $x^{r/2}\neq1$ > **Theorem:** If $N$ is divisible by $l$ distinct odd primes, then at least $$1-\frac{1}{2^{l-1}}$$ elements are "good". > $l=2\Rightarrow 1/2$ probability to have "good" $x$ > $O(1)$ trials - If $r$ is not even: - **Complexity:** - $O(1)$ for order finding - overall: $O(L^3)$ - classical factoring: $\text{exp}(O(L^{1/3}))$ - <ins>exponential speedup</ins> ### RSA Algorithm 1. pick random two primes $p,q$, and $n=p\cdot q$ 2. pick random public key by $e\in\phi(n)$, where $\phi(n)=(p-1)(q-1)$ 3. choose private key $d$ such that $e\cdot d=1\text{ mod }\phi(n)$ 4. public key: $(n,e)$ private key: $(n,d)$ - Encryption: $E(m) = m^e\text{ mod }n$ - Decryption: $D(c)=c^d\text{ mod }n=m^{e\cdot d}\text{ mod }n=m^{1\text{ mod }\phi(n)}\text{ mod }n= m \text{ mod }n$ > Shor's Algorithm allows us to factor efficiently on a quantum computer > RSA public key scheme is broken, as soon as sufficiently **large** quantum computer exists.

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