diff --git a/_book/Introduction-to-Quantum-Computing.epub b/_book/Introduction-to-Quantum-Computing.epub
index 63c60101141d13f5ba273a135b93c0b04de8eb91..0fd605026909d362cdb0844417fd8feb51f08571 100644
Binary files a/_book/Introduction-to-Quantum-Computing.epub and b/_book/Introduction-to-Quantum-Computing.epub differ
diff --git a/_book/Introduction-to-Quantum-Computing.pdf b/_book/Introduction-to-Quantum-Computing.pdf
index 2281941bb415c535f482868b87aa548499ebaf21..624c75b16525a6d7acc4c446016d0e236d3c1aa0 100644
Binary files a/_book/Introduction-to-Quantum-Computing.pdf and b/_book/Introduction-to-Quantum-Computing.pdf differ
diff --git a/_book/index.html b/_book/index.html
index 17ca23168a5fe75d751cde3f8449fe862b61feac..f1230b96d2fc466eeb69cad2ce3c9fe9ee63e0dc 100644
--- a/_book/index.html
+++ b/_book/index.html
@@ -8,7 +8,7 @@
 
 <meta name="author" content="Jannik Hellenkamp">
 <meta name="author" content="Dominique Unruh">
-<meta name="dcterms.date" content="2024-06-01">
+<meta name="dcterms.date" content="2024-06-11">
 
 <title>Introduction to Quantum Computing</title>
 <style>
@@ -251,7 +251,7 @@ ul.task-list li input[type="checkbox"] {
     <div>
     <div class="quarto-title-meta-heading">Published</div>
     <div class="quarto-title-meta-contents">
-      <p class="date">June 1, 2024</p>
+      <p class="date">June 11, 2024</p>
     </div>
   </div>
   
@@ -271,6 +271,15 @@ ul.task-list li input[type="checkbox"] {
 <p>These lecture notes are released under the CC BY-NC 4.0 license, which can be found <a href="https://creativecommons.org/licenses/by-nc/4.0/">here</a>.</p>
 <section id="changelog" class="level2 unnumbered">
 <h2 class="unnumbered anchored" data-anchor-id="changelog">Changelog</h2>
+<section id="version-0.1.3-11.06.2024" class="level4">
+<h4 class="anchored" data-anchor-id="version-0.1.3-11.06.2024">Version 0.1.3 (11.06.2024)</h4>
+<ul>
+<li>added/extended 9.4 + 9.5 (Post processing and Beginning of DFT circuit)</li>
+<li>updated 9.3</li>
+<li>added chapter 3 (Quantum systems)</li>
+<li>error correction in chapter 9</li>
+</ul>
+</section>
 <section id="version-0.1.2-31.05.2024" class="level4">
 <h4 class="anchored" data-anchor-id="version-0.1.2-31.05.2024">Version 0.1.2 (31.05.2024)</h4>
 <ul>
diff --git a/_book/observingSystems.html b/_book/observingSystems.html
index e9b9fe0af9b3625af216d4c3e2c1de48ede54204..3f35bbc829d056face7d863dd44692b4d0d63f6c 100644
--- a/_book/observingSystems.html
+++ b/_book/observingSystems.html
@@ -261,7 +261,7 @@ When observing a probabilistic system, the observation is just a passive process
 
 ## Example: Random 1-bit number
 
-We usa a the random 1-bit number example to the random 2-bit example from @sec-prob.
+We usa a the random 1-bit number example similar to the random 2-bit example from @sec-prob.
 We have a distribution $d_{\text{1-bit}} = \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \end{pmatrix}$ which represents the probability distribution of generating a 1-bit number with equal probability. We also have a process $A_{\text{flip}} = \begin{pmatrix} \frac{2}{3} &  \frac{1}{3} \\ \frac{1}{3} &  \frac{2}{3} \end{pmatrix}$ which flips the bit with a probability of $\frac{1}{3}$. 
 
 We look at two different cases: For the first case, we observe only the final distribution and for the second case we observe after the generation of the 1-bit number and we also observe the final distribution. 
@@ -272,11 +272,13 @@ From @sec-prob-apply we know that the final distribution $d$ is
 $$
 d = A_{\text{flip}} \cdot d_{\text{1-bit}} = \begin{pmatrix} \frac{2}{3} &  \frac{1}{3} \\ \frac{1}{3} &  \frac{2}{3} \end{pmatrix} \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \end{pmatrix} = \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \end{pmatrix}
 $$
-We observe this distribution and will get outcome $0$ and the new distribution $d = e_0 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ with a probability of $d_0 = \frac{1}{2}$ and the outcome $1$ and the new distribution $d = e_1 = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ with a probability of $d_1 = \frac{1}{2}$.
+We observe this distribution and will get outcome $0$ and the new distribution $d = e_0 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ with a probability of $\Pr[0] = d_0 = \frac{1}{2}$ and the outcome $1$ and the new distribution $d = e_1 = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ with a probability of $\Pr[1] = d_1 = \frac{1}{2}$.
 
 ##### Observing after generation {.unnumbered}
 
-We now observe the system after the generation of the 1-bit number and also observe the final distribution
+We now observe the system after the generation of the 1-bit number and also observe the final distribution. After the generation, we will get outcome $0$ and the new distribution $d = e_0 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ with a probability of $\Pr[0] = d_0 = \frac{1}{2}$ and the outcome $1$ and the new distribution $d = e_1 = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ with a probability of $\Pr[1] = d_1 = \frac{1}{2}$. 
+
+We now apply in each case the matrix $A_\text{flip}$. This will give us the outcome $A_\text{flip} \cdot \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$
 
 :::
 
@@ -310,7 +312,18 @@ $$
 H\psi = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix} =  \begin{pmatrix} 1 \\ 0 \end{pmatrix}
 $$
 
-Measuring this state will get the outcome $0$ with probability $|\psi_0|^2 = 1$ and have the post measurement state $\begin{pmatrix} 1 \\ 0 \end{pmatrix}$.
+Measuring this state will get the outcome $0$ with probability $\Pr[0] = |\psi_0|^2 = 1$ and have the post measurement state $\begin{pmatrix} 1 \\ 0 \end{pmatrix}$.
+
+##### Measure the initial and the final state {.unnumbered}
+
+Measuring $\psi$ with no further unitary matrices applied can have the outcome $0$ or $1$. We will look at the final measurement for each case:
+
+
+The first measurement will have outcome $0$ with probability $\Pr[0] = |\psi_0|^2 = \frac{1}{2}$ and the post measurement state will be $\begin{pmatrix} 1 \\ 0 \end{pmatrix}$. $H$ applied to this post measurement state will be $H\begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix}$. When measuring this state, we will get the outcome $0$ with probability $\Pr[0] = |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2}$ and outcome $1$ with with probability $\Pr[1] = |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2}$.
+
+The outcome $1$ will appear at the initial state with probability $\Pr[1] = |\psi_1|^2 = \frac{1}{2}$ and the post measurement state will be $\begin{pmatrix} 0 \\ 1 \end{pmatrix}$. $H$ applied to this post measurement state will be $H\begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} \end{pmatrix}$. When measuring this state, we will get the outcome $0$ with probability $\Pr[0] = |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2}$ and outcome $1$ with with probability $\Pr[1] = |-\frac{1}{\sqrt{2}}|^2 = \frac{1}{2}$.
+
+So no independent of the outcome of the first measurement, at the second measurement the outcome $0$ and $1$ have a probability of $\frac{1}{2}$. This shows, that when measuring before applying $H$, we will receive different probabilities, then when measuring only at the end. This proves, that measurements can change the system.
 
 
 :::
diff --git a/_book/quantumSystems.html b/_book/quantumSystems.html
index 0cb5b29e8ea0070f6398c16b505aaca48944efe8..6cbdc2460ae3c6851049b5e9e7200a4cdc73d2f7 100644
--- a/_book/quantumSystems.html
+++ b/_book/quantumSystems.html
@@ -69,6 +69,35 @@ ul.task-list li input[type="checkbox"] {
   }
 }</script>
 
+  <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
+  <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>
+
+<script type="text/javascript">
+const typesetMath = (el) => {
+  if (window.MathJax) {
+    // MathJax Typeset
+    window.MathJax.typeset([el]);
+  } else if (window.katex) {
+    // KaTeX Render
+    var mathElements = el.getElementsByClassName("math");
+    var macros = [];
+    for (var i = 0; i < mathElements.length; i++) {
+      var texText = mathElements[i].firstChild;
+      if (mathElements[i].tagName == "SPAN") {
+        window.katex.render(texText.data, mathElements[i], {
+          displayMode: mathElements[i].classList.contains('display'),
+          throwOnError: false,
+          macros: macros,
+          fleqn: false
+        });
+      }
+    }
+  }
+}
+window.Quarto = {
+  typesetMath
+};
+</script>
 
 </head>
 
@@ -214,7 +243,14 @@ ul.task-list li input[type="checkbox"] {
 <div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
 <!-- margin-sidebar -->
     <div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
-        
+        <nav id="TOC" role="doc-toc" class="toc-active">
+    <h2 id="toc-title">Table of contents</h2>
+   
+  <ul>
+  <li><a href="#quantum-states" id="toc-quantum-states" class="nav-link active" data-scroll-target="#quantum-states"><span class="header-section-number">3.1</span> Quantum states</a></li>
+  <li><a href="#unitary-transformation" id="toc-unitary-transformation" class="nav-link" data-scroll-target="#unitary-transformation"><span class="header-section-number">3.2</span> Unitary transformation</a></li>
+  </ul>
+</nav>
     </div>
 <!-- main -->
 <main class="content" id="quarto-document-content">
@@ -238,94 +274,126 @@ ul.task-list li input[type="checkbox"] {
 </header>
 
 
-<!--
-With the basics for a probabilistic system defined, we now look into describing a quantum computer mathematically. In the following table you can see the analogy from the quantum world to the probabilistic world. 
-
-| Probabilistic world           | Quantum world              |
-| ---------                     | -----------                |
-| Probability distributions     | Quantum states             |
-| Probabilities                 | Amplitudes                 |
-| Deterministic possibilities   | Classical possibilities    |
-| Stochastic matrix as process  | Unitary matrix as process  |
-
-## Quantum states
-One of the most important element of the quantum world is a quantum state. A quantum state describes the state of a quantum system as a vector. Each entry of the vector represents a *classical* possibility (similar to the deterministic possibilities in a probability distribution). The entries of a quantum state called *amplitude*. In contrast to a probabilistic system, these entries can be negative and are also complex numbers. 
-
-These amplitudes correlate to the probability of the quantum state being in the corresponding classical probability. To calculate the probabilities from the amplitude, we can take the square of the absolute value of the amplitude.
-
-This means, that for the classical possibility $x$ and a quantum state $\psi$ the probability for $x$ is $\Pr[x] = |\psi|^2$. To have valid probabilities, the sum of all probabilities need to sum up to $1$. From this we get the formal definition of a quantum state:
-
-::: {.callout-note appearance="minimal" icon=false}
-::: {.definition #def-quantum-state}
-
-## Quantum State
-
-A quantum state is a vector $\psi \in \mathbb{C}^n$ with $\sqrt{\sum |\psi|^2} = 1$.
-:::
-:::
-
-::: {.callout-tip icon=false}
-
-## Example: Some Quantum states
-The following vectors are valid quantum states with the classical possibilities $0$ and $1$:
-$$
-\ket{0} = \begin{pmatrix} 1 \\ 0 \end{pmatrix}\quad
-\ket{1} = \begin{pmatrix} 0 \\ 1 \end{pmatrix}\quad
-\ket{+} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix}\quad
-\ket{-} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} \end{pmatrix}
-$$
-Note that the symbol $\ket{}$ is not yet introduced, so just understand it as some label at this point. The probabilities for each state can be calculated as follows:
-$$
+<p>With the basics for a probabilistic system defined, we now look into describing a quantum computer mathematically. In the following table you can see the analogy from the quantum world to the probabilistic world.</p>
+<table class="table">
+<thead>
+<tr class="header">
+<th>Probabilistic world</th>
+<th>Quantum world</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td>Probability distributions</td>
+<td>Quantum states</td>
+</tr>
+<tr class="even">
+<td>Probabilities</td>
+<td>Amplitudes</td>
+</tr>
+<tr class="odd">
+<td>Deterministic possibilities</td>
+<td>Classical possibilities</td>
+</tr>
+<tr class="even">
+<td>Stochastic matrix as process</td>
+<td>Unitary matrix as process</td>
+</tr>
+</tbody>
+</table>
+<section id="quantum-states" class="level2" data-number="3.1">
+<h2 data-number="3.1" class="anchored" data-anchor-id="quantum-states"><span class="header-section-number">3.1</span> Quantum states</h2>
+<p>One of the most important element of the quantum world is a quantum state. A quantum state describes the state of a quantum system as a vector. Each entry of the vector represents a <em>classical</em> possibility (similar to the deterministic possibilities in a probability distribution). The entries of a quantum state are called <em>amplitude</em>. In contrast to a probabilistic system, these entries can be negative and are also complex numbers.</p>
+<p>These amplitudes tell us the probability of the quantum state being in the corresponding classical possibility. To calculate the probabilities from the amplitude, we can take the square of the absolute value of the amplitude.</p>
+<p>This means, that for the classical possibility <span class="math inline">\(x\)</span> and a quantum state <span class="math inline">\(\psi\)</span> the probability for <span class="math inline">\(x\)</span> is <span class="math inline">\(\Pr[x] = |\psi|^2\)</span>. To have valid probabilities, the sum of all probabilities need to sum up to <span class="math inline">\(1\)</span>. From this we get the formal definition of a quantum state:</p>
+<div class="callout callout-style-simple callout-note no-icon">
+<div class="callout-body d-flex">
+<div class="callout-icon-container">
+<i class="callout-icon no-icon"></i>
+</div>
+<div class="callout-body-container">
+<div id="def-quantum-state" class="definition theorem">
+<p><span class="theorem-title"><strong>Definition 3.1 (Quantum State)</strong></span> A quantum state is a vector <span class="math inline">\(\psi \in \mathbb{C}^n\)</span> with <span class="math inline">\(\sqrt{\sum |\psi|^2} = 1\)</span>.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="callout callout-style-simple callout-tip no-icon callout-titled">
+<div class="callout-header d-flex align-content-center">
+<div class="callout-icon-container">
+<i class="callout-icon no-icon"></i>
+</div>
+<div class="callout-title-container flex-fill">
+Example: Some Quantum states
+</div>
+</div>
+<div class="callout-body-container callout-body">
+<p>The following vectors are valid quantum states with the classical possibilities <span class="math inline">\(0\)</span> and <span class="math inline">\(1\)</span>: <span class="math display">\[
+\ket{0} := \begin{pmatrix} 1 \\ 0 \end{pmatrix}\quad
+\ket{1} := \begin{pmatrix} 0 \\ 1 \end{pmatrix}\quad
+\ket{+} := \begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix}\quad
+\ket{-} := \begin{pmatrix} \frac{1}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} \end{pmatrix}
+\]</span> Note that the symbol <span class="math inline">\(\ket{}\)</span> is not yet introduced, so just understand it as some label at this point. The probabilities for each state can be calculated as follows: <span class="math display">\[
 \begin{aligned}
-\ket{0}: \Pr[0] &= |1|^2 = 1 \quad &&\Pr[1] = |0|^2 = 0 \\
-\ket{1}: \Pr[0] &= |0|^2 = 0 \quad &&\Pr[1] = |1|^2 = 1 \\
-\ket{+}: \Pr[0] &= |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2} &&\Pr[1] = |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2} \\
-\ket{-}: \Pr[0] &= |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2} &&\Pr[1] = |\frac{-1}{\sqrt{2}}|^2 = \frac{1}{2}
+\ket{0}:&amp;&amp; \Pr[0] &amp;= |1|^2 = 1 \quad &amp;&amp;\Pr[1] = |0|^2 = 0 \\
+\ket{1}:&amp;&amp; \Pr[0] &amp;= |0|^2 = 0 \quad &amp;&amp;\Pr[1] = |1|^2 = 1 \\
+\ket{+}:&amp;&amp; \Pr[0] &amp;= \lvert\tfrac{1}{\sqrt{2}}\rvert^2 = \tfrac{1}{2} &amp;&amp;\Pr[1] = \lvert\tfrac{1}{\sqrt{2}}\rvert^2 = \tfrac{1}{2} \\
+\ket{-}:&amp;&amp; \Pr[0] &amp;= \lvert\tfrac{1}{\sqrt{2}}\rvert^2 = \tfrac{1}{2} &amp;&amp;\Pr[1] = \lvert\tfrac{-1}{\sqrt{2}}\rvert^2 = \tfrac{1}{2}
 \end{aligned}
-$$
-We can see here, that two different quantum states ($\ket{+}$ and $\ket{-}$) can have the same probabilities for all classical possibilities. 
-:::
-
-## Unitary transformation
-We now have defined quantum states and need a way to describe  some processes, which we want to apply on the quantum states. In the probabilistic world, we have stochastic matrices for this, but unfortunately we can not use these matrices on quantum states, since the output of applying these on a quantum state is not guaranteed to be a quantum state again. We therefore make a new addition to our quantum toolbox called a *unitary transformation*. 
-
-::: {.callout-note appearance="minimal" icon=false}
-::: {.definition #def-unitary-transformation}
-
-## Unitary transformation
-Given a quantum state $\psi \in \mathbb{C}^n$ and a unitary matrix $U \in \mathbb{C}^{n\times n}$, the state after the transformation is $U\psi$.
-:::
-:::
-
-::: {.callout-note appearance="minimal" icon=false}
-::: {.lemma #lem-unitary-matrix}
-
-## Unitary matrix
-A matrix $U \in \mathbb{C}^{n\times n}$ is called *unitary* iff $U^\dagger U = I$ where $I$ is the identity matrix and $U^\dagger$ is the complex conjugate transpose of $U$.
-:::
-:::
-
-A unitary transformation is by definition invertible, therefore we can undo all unitary transformations by applying $U^\dagger$. 
-
-::: {.callout-tip icon=false}
-
-## Example: Some Unitary transformations
-The following matrices are  examples for unitary transformations:
-$$
-X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \quad Y =  \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix} \quad Z =  \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}  
-$$
-These matrices are called Pauli-matrices, we will get to know them later on. 
-
-As an example for applying a unitary on a quantum state, we apply the Pauli $X$ matrix on the quantum state $\ket{0}$:
-
-$$
-X\ket{0} = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \cdot \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \ket{1}
-$$
-:::
-
--->
+\]</span> We can see here, that two different quantum states (<span class="math inline">\(\ket{+}\)</span> and <span class="math inline">\(\ket{-}\)</span>) can have the same probabilities for all classical possibilities.</p>
+</div>
+</div>
+</section>
+<section id="unitary-transformation" class="level2" data-number="3.2">
+<h2 data-number="3.2" class="anchored" data-anchor-id="unitary-transformation"><span class="header-section-number">3.2</span> Unitary transformation</h2>
+<p>We now have defined quantum states and need a way to describe some processes, which we want to apply on the quantum states. In the probabilistic world, we have stochastic matrices for this, but unfortunately we can not use these matrices on quantum states, since the output of applying these on a quantum state is not guaranteed to be a quantum state again. We therefore look for a different property of a matrix for which the outcome of applying that matrix is guaranteed to be a quantum state. We get this property with <em>unitary</em> matrices.</p>
+<div class="callout callout-style-simple callout-note no-icon">
+<div class="callout-body d-flex">
+<div class="callout-icon-container">
+<i class="callout-icon no-icon"></i>
+</div>
+<div class="callout-body-container">
+<div id="def-unitary-transformation" class="definition theorem">
+<p><span class="theorem-title"><strong>Definition 3.2 (Unitary transformation)</strong></span> Given a quantum state <span class="math inline">\(\psi \in \mathbb{C}^n\)</span> and a unitary matrix <span class="math inline">\(U \in \mathbb{C}^{n\times n}\)</span>, the state after the transformation is a quantum state <span class="math inline">\(U\psi\)</span>.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="callout callout-style-simple callout-note no-icon">
+<div class="callout-body d-flex">
+<div class="callout-icon-container">
+<i class="callout-icon no-icon"></i>
+</div>
+<div class="callout-body-container">
+<div id="lem-unitary-matrix" class="lemma theorem">
+<p><span class="theorem-title"><strong>Lemma 3.1 (Unitary matrix)</strong></span> A matrix <span class="math inline">\(U \in \mathbb{C}^{n\times n}\)</span> is called <em>unitary</em> iff <span class="math inline">\(U^\dagger U = I\)</span> where <span class="math inline">\(I\)</span> is the identity matrix and <span class="math inline">\(U^\dagger\)</span> is the complex conjugate transpose of <span class="math inline">\(U\)</span>.</p>
+</div>
+</div>
+</div>
+</div>
+<p>A unitary matrix is by this lemma invertible, therefore we can undo all unitary transformations by applying <span class="math inline">\(U^\dagger\)</span>.</p>
+<div class="callout callout-style-simple callout-tip no-icon callout-titled">
+<div class="callout-header d-flex align-content-center">
+<div class="callout-icon-container">
+<i class="callout-icon no-icon"></i>
+</div>
+<div class="callout-title-container flex-fill">
+Example: Some Unitary transformations
+</div>
+</div>
+<div class="callout-body-container callout-body">
+<p>The following matrices are examples for unitary transformations: <span class="math display">\[
+X = \begin{pmatrix} 0 &amp; 1 \\ 1 &amp; 0 \end{pmatrix} \quad Y =  \begin{pmatrix} 0 &amp; -i \\ i &amp; 0 \end{pmatrix} \quad Z =  \begin{pmatrix} 1 &amp; 0 \\ 0 &amp; -1 \end{pmatrix}  
+\]</span> These matrices are called Pauli-matrices, we will get to know them later on.</p>
+<p>As an example for applying a unitary on a quantum state, we apply the Pauli <span class="math inline">\(X\)</span> matrix on the quantum state <span class="math inline">\(\ket{0}\)</span>:</p>
+<p><span class="math display">\[
+X\ket{0} = \begin{pmatrix} 0 &amp; 1 \\ 1 &amp; 0 \end{pmatrix} \cdot \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \ket{1}
+\]</span></p>
+</div>
+</div>
 
 
+</section>
 
 </main> <!-- /main -->
 <script id="quarto-html-after-body" type="application/javascript">
diff --git a/_book/search.json b/_book/search.json
index 6e466e26350e59ac4f229371c9a56c533afd78a0..568eb4baf19ce3bffd709c404aff5c00f2335130 100644
--- a/_book/search.json
+++ b/_book/search.json
@@ -14,7 +14,7 @@
     "href": "index.html#changelog",
     "title": "Introduction to Quantum Computing",
     "section": "Changelog",
-    "text": "Changelog\n\nVersion 0.1.2 (31.05.2024)\n\nminor changes to chapter 2\nadded chapter 9\n\n\n\nVersion 0.1.1 (16.05.2024)\n\nStarted the lecture notes.",
+    "text": "Changelog\n\nVersion 0.1.3 (11.06.2024)\n\nadded/extended 9.4 + 9.5 (Post processing and Beginning of DFT circuit)\nupdated 9.3\nadded chapter 3 (Quantum systems)\nerror correction in chapter 9\n\n\n\nVersion 0.1.2 (31.05.2024)\n\nminor changes to chapter 2\nadded chapter 9\n\n\n\nVersion 0.1.1 (16.05.2024)\n\nStarted the lecture notes.",
     "crumbs": [
       "Welcome"
     ]
@@ -85,6 +85,39 @@
       "<span class='chapter-number'>2</span>  <span class='chapter-title'>Probabilistic systems</span>"
     ]
   },
+  {
+    "objectID": "quantumSystems.html",
+    "href": "quantumSystems.html",
+    "title": "3  Quantum systems",
+    "section": "",
+    "text": "3.1 Quantum states\nOne of the most important element of the quantum world is a quantum state. A quantum state describes the state of a quantum system as a vector. Each entry of the vector represents a classical possibility (similar to the deterministic possibilities in a probability distribution). The entries of a quantum state are called amplitude. In contrast to a probabilistic system, these entries can be negative and are also complex numbers.\nThese amplitudes tell us the probability of the quantum state being in the corresponding classical possibility. To calculate the probabilities from the amplitude, we can take the square of the absolute value of the amplitude.\nThis means, that for the classical possibility \\(x\\) and a quantum state \\(\\psi\\) the probability for \\(x\\) is \\(\\Pr[x] = |\\psi|^2\\). To have valid probabilities, the sum of all probabilities need to sum up to \\(1\\). From this we get the formal definition of a quantum state:",
+    "crumbs": [
+      "Quantum Basics",
+      "<span class='chapter-number'>3</span>  <span class='chapter-title'>Quantum systems</span>"
+    ]
+  },
+  {
+    "objectID": "quantumSystems.html#quantum-states",
+    "href": "quantumSystems.html#quantum-states",
+    "title": "3  Quantum systems",
+    "section": "",
+    "text": "Definition 3.1 (Quantum State) A quantum state is a vector \\(\\psi \\in \\mathbb{C}^n\\) with \\(\\sqrt{\\sum |\\psi|^2} = 1\\).\n\n\n\n\n\n\n\n\n\n\nExample: Some Quantum states\n\n\n\nThe following vectors are valid quantum states with the classical possibilities \\(0\\) and \\(1\\): \\[\n\\ket{0} := \\begin{pmatrix} 1 \\\\ 0 \\end{pmatrix}\\quad\n\\ket{1} := \\begin{pmatrix} 0 \\\\ 1 \\end{pmatrix}\\quad\n\\ket{+} := \\begin{pmatrix} \\frac{1}{\\sqrt{2}} \\\\ \\frac{1}{\\sqrt{2}} \\end{pmatrix}\\quad\n\\ket{-} := \\begin{pmatrix} \\frac{1}{\\sqrt{2}} \\\\ -\\frac{1}{\\sqrt{2}} \\end{pmatrix}\n\\] Note that the symbol \\(\\ket{}\\) is not yet introduced, so just understand it as some label at this point. The probabilities for each state can be calculated as follows: \\[\n\\begin{aligned}\n\\ket{0}:&& \\Pr[0] &= |1|^2 = 1 \\quad &&\\Pr[1] = |0|^2 = 0 \\\\\n\\ket{1}:&& \\Pr[0] &= |0|^2 = 0 \\quad &&\\Pr[1] = |1|^2 = 1 \\\\\n\\ket{+}:&& \\Pr[0] &= \\lvert\\tfrac{1}{\\sqrt{2}}\\rvert^2 = \\tfrac{1}{2} &&\\Pr[1] = \\lvert\\tfrac{1}{\\sqrt{2}}\\rvert^2 = \\tfrac{1}{2} \\\\\n\\ket{-}:&& \\Pr[0] &= \\lvert\\tfrac{1}{\\sqrt{2}}\\rvert^2 = \\tfrac{1}{2} &&\\Pr[1] = \\lvert\\tfrac{-1}{\\sqrt{2}}\\rvert^2 = \\tfrac{1}{2}\n\\end{aligned}\n\\] We can see here, that two different quantum states (\\(\\ket{+}\\) and \\(\\ket{-}\\)) can have the same probabilities for all classical possibilities.",
+    "crumbs": [
+      "Quantum Basics",
+      "<span class='chapter-number'>3</span>  <span class='chapter-title'>Quantum systems</span>"
+    ]
+  },
+  {
+    "objectID": "quantumSystems.html#unitary-transformation",
+    "href": "quantumSystems.html#unitary-transformation",
+    "title": "3  Quantum systems",
+    "section": "3.2 Unitary transformation",
+    "text": "3.2 Unitary transformation\nWe now have defined quantum states and need a way to describe some processes, which we want to apply on the quantum states. In the probabilistic world, we have stochastic matrices for this, but unfortunately we can not use these matrices on quantum states, since the output of applying these on a quantum state is not guaranteed to be a quantum state again. We therefore look for a different property of a matrix for which the outcome of applying that matrix is guaranteed to be a quantum state. We get this property with unitary matrices.\n\n\n\n\n\n\n\nDefinition 3.2 (Unitary transformation) Given a quantum state \\(\\psi \\in \\mathbb{C}^n\\) and a unitary matrix \\(U \\in \\mathbb{C}^{n\\times n}\\), the state after the transformation is a quantum state \\(U\\psi\\).\n\n\n\n\n\n\n\n\n\n\n\nLemma 3.1 (Unitary matrix) A matrix \\(U \\in \\mathbb{C}^{n\\times n}\\) is called unitary iff \\(U^\\dagger U = I\\) where \\(I\\) is the identity matrix and \\(U^\\dagger\\) is the complex conjugate transpose of \\(U\\).\n\n\n\n\nA unitary matrix is by this lemma invertible, therefore we can undo all unitary transformations by applying \\(U^\\dagger\\).\n\n\n\n\n\n\nExample: Some Unitary transformations\n\n\n\nThe following matrices are examples for unitary transformations: \\[\nX = \\begin{pmatrix} 0 & 1 \\\\ 1 & 0 \\end{pmatrix} \\quad Y =  \\begin{pmatrix} 0 & -i \\\\ i & 0 \\end{pmatrix} \\quad Z =  \\begin{pmatrix} 1 & 0 \\\\ 0 & -1 \\end{pmatrix}  \n\\] These matrices are called Pauli-matrices, we will get to know them later on.\nAs an example for applying a unitary on a quantum state, we apply the Pauli \\(X\\) matrix on the quantum state \\(\\ket{0}\\):\n\\[\nX\\ket{0} = \\begin{pmatrix} 0 & 1 \\\\ 1 & 0 \\end{pmatrix} \\cdot \\begin{pmatrix} 1 \\\\ 0 \\end{pmatrix} = \\begin{pmatrix} 0 \\\\ 1 \\end{pmatrix} = \\ket{1}\n\\]",
+    "crumbs": [
+      "Quantum Basics",
+      "<span class='chapter-number'>3</span>  <span class='chapter-title'>Quantum systems</span>"
+    ]
+  },
   {
     "objectID": "quantumCircutsKetNotation.html",
     "href": "quantumCircutsKetNotation.html",
@@ -112,7 +145,7 @@
     "href": "shorsAlgorithm.html#discrete-fourier-transformation",
     "title": "9  Shor’s Algorithm",
     "section": "",
-    "text": "Definition 9.1 (Discrete Fourier Transformation (DFT)) The discrete Fourier transform (DFT) is a linear transformation on \\(\\mathbb{C}^N\\) represented by the matrix \\[\n\\operatorname{DFT}_N = \\frac{1}{\\sqrt{N}} (\\omega^{kl})_{kl} \\in \\mathbb{C}^{N\\times N}\n\\] with \\(\\omega = e^{2i\\pi/N}\\), which is the \\(N\\)-th root of unity.\n\n\n\n\n\n\n\n\n\n\n\n\nTheorem 9.1 (Properties of the DFT) Here are some properties of the DFT which can be used without further proof.\n\nThe DFT is unitary.\n\\(\\omega^t = \\omega^{t\\mod N}\\) for all \\(t \\in \\mathbb{Z}\\).\nGiven a quantum state \\(\\psi \\in \\mathbb{C}^N\\) which is \\(r\\)-periodic and where \\(r\\mid N\\), \\(\\operatorname{DFT}_N \\psi\\) will compute a quantum state \\(\\phi \\in \\mathbb{C}^N\\), which has non-zero values on the multiples of \\(\\frac{N}{r}\\). Note that \\(\\frac{N}{r}\\) intuitively represents the frequency of \\(\\psi\\). This means, that \\[\n|\\phi_i| = \\begin{cases} \\frac{1}{\\sqrt{t}}, & \\text{if}\\ \\frac{N}{t}\\mid i \\\\ 0, & \\text{otherwise} \\end{cases}\n\\]",
+    "text": "Definition 9.1 (Discrete Fourier Transformation (DFT)) The discrete Fourier transform (DFT) is a linear transformation on \\(\\mathbb{C}^M\\) represented by the matrix \\[\n\\operatorname{DFT}_M = \\frac{1}{\\sqrt{M}} (\\omega^{kl})_{kl} \\in \\mathbb{C}^{M\\times M}\n\\] with \\(\\omega = e^{2i\\pi/M}\\), which is the \\(M\\)-th root of unity.\n\n\n\n\n\n\n\n\n\n\n\n\nTheorem 9.1 (Properties of the DFT) Here are some properties of the DFT which can be used without further proof.\n\nThe DFT is unitary.\n\\(\\omega^t = \\omega^{t\\mod M}\\) for all \\(t \\in \\mathbb{Z}\\).\nGiven a quantum state \\(\\psi \\in \\mathbb{C}^M\\) which is \\(r\\)-periodic and where \\(r\\mid M\\), \\(\\operatorname{DFT}_M \\psi\\) will compute a quantum state \\(\\phi \\in \\mathbb{C}^M\\), which has non-zero values on the multiples of \\(\\frac{M}{r}\\). Note that \\(\\frac{M}{r}\\) intuitively represents the frequency of \\(\\psi\\). This means, that \\[\n|\\phi_i| = \\begin{cases} \\frac{1}{\\sqrt{r}}, & \\text{if}\\ \\frac{M}{r}\\mid i \\\\ 0, & \\text{otherwise} \\end{cases}\n\\]",
     "crumbs": [
       "Quantum Algorithms",
       "<span class='chapter-number'>9</span>  <span class='chapter-title'>Shor's Algorithm</span>"
@@ -123,7 +156,7 @@
     "href": "shorsAlgorithm.html#reducing-factoring-to-period-finding",
     "title": "9  Shor’s Algorithm",
     "section": "9.2 Reducing factoring to period finding",
-    "text": "9.2 Reducing factoring to period finding\nWith the DFT, we have seen, that we can use a unitary to find the period of a quantum state. We now look into using period finding to factor integers. We first look at the definition of the two problems:\n\n\n\n\n\n\n\nDefinition 9.2 (Factoring problem) Given integer \\(N\\) with two prime factors \\(p,q\\) such that \\(pq=N\\) and \\(p \\neq q\\), find \\(p\\) and \\(q\\).\n\n\n\n\nNote that this definition of the factoring problem is a simplified version of the factoring problem, where \\(N\\) has only 2 prime factors.\n\n\n\n\n\n\n\nDefinition 9.3 (Period finding problem) Given \\(f: \\mathbb{Z} \\to X\\) with \\(f(x) = f(y)\\) iff \\(x \\equiv y \\bmod r\\) for some fixed secret \\(r\\). \\(r\\) is called the period of \\(f\\). Find \\(r\\).\n\n\n\n\nTo start the reduction, we need a special case of the period finding problem called order finding:\n\n\n\n\n\n\n\nDefinition 9.4 (Order finding problem) For known \\(a\\) and \\(N\\) which are relatively prime, find the period \\(r\\) of \\(f(i) = a^i \\bmod n\\). We call \\(r\\) the order of \\(a\\) written \\(r = \\text{ ord } a\\). (This is similar to finding the smallest \\(i &gt; 0\\) with \\(f(i) = 1\\)).\n\n\n\n\nSince the order finding problem is just the period finding problem for a specific \\(f(x)\\), we know that if we can solve the period finding problem within reasonable runtime, we can also solve the order finding problem within reasonable runtime. We now reduce the factoring problem to the order finding problem:\nWe have a integer \\(N\\) as an input for the factoring problem.\n\nPick an \\(a \\in \\{1,...,N-1\\}\\) with \\(a\\) relatively prime to \\(n\\).\nCompute the order of \\(a\\), so that \\(r = \\text{ ord } a\\) (using the solver for the order finding problem).\nIf the order \\(r\\) is odd, we abort.\nCalculate \\(x:= a^{\\frac{r}{2}}+1 \\bmod N\\) and \\(y:= a^{\\frac{r}{2}}-1 \\bmod N\\).\nIf \\(\\gcd(x,N) \\in \\{1,N\\}\\), we abort.\nWe compute \\(p = \\gcd(x,N)\\) and \\(q = \\gcd(y,N)\\).\n\nThe output of the reduction are \\(p,q\\), such that \\(pq = N\\). This holds, since \\[\nxy = (a^{\\frac{r}{2}}+1) (a^{\\frac{r}{2}}-1) = a^r - 1 \\equiv 1-1 = 0 \\pmod N\n\\]\n\n\n\n\n\n\n\nTheorem 9.2 (Probability of an abort) If \\(N\\) has at least two different prime factors and \\(N\\) is odd, then the probability to abort is \\(\\leq \\frac{1}{2}\\).\n\n\n\n\nAll in all this reduction shows, that if we have an oracle which can solve the period finding problem within reasonable runtime, we can also solve the factoring problem within reasonable runtime (since all other operations are classically fast to compute).",
+    "text": "9.2 Reducing factoring to period finding\nWith the DFT, we have seen, that we can use a unitary to find the period of a quantum state. We now look into using period finding to factor integers. We first look at the definition of the two problems:\n\n\n\n\n\n\n\nDefinition 9.2 (Factoring problem) Given integer \\(N\\) with two prime factors \\(p,q\\) such that \\(pq=N\\) and \\(p \\neq q\\), find \\(p\\) and \\(q\\).\n\n\n\n\nNote that this definition of the factoring problem is a simplified version of the factoring problem, where \\(N\\) has only 2 prime factors.\n\n\n\n\n\n\n\nDefinition 9.3 (Period finding problem) Given \\(f: \\mathbb{Z} \\to X\\) with \\(f(x) = f(y)\\) iff \\(x \\equiv y \\bmod r\\) for some fixed secret \\(r\\). \\(r\\) is called the period of \\(f\\). Find \\(r\\).\n\n\n\n\nTo start the reduction, we need a special case of the period finding problem called order finding:\n\n\n\n\n\n\n\nDefinition 9.4 (Order finding problem) For known \\(a\\) and \\(N\\) which are relatively prime, find the period \\(r\\) of \\(f(i) = a^i \\bmod N\\). We call \\(r\\) the order of \\(a\\) written \\(r = \\text{ ord } a\\). (This is similar to finding the smallest \\(i &gt; 0\\) with \\(f(i) = 1\\)).\n\n\n\n\nSince the order finding problem is just the period finding problem for a specific \\(f(x)\\), we know that if we can solve the period finding problem within reasonable runtime, we can also solve the order finding problem within reasonable runtime. We now reduce the factoring problem to the order finding problem:\nWe have a integer \\(N\\) as an input for the factoring problem.\n\nPick an \\(a \\in \\{1,\\dots,N-1\\}\\) with \\(a\\) relatively prime to \\(N\\).\nCompute the order of \\(a\\), so that \\(r = \\text{ ord } a\\) (using the solver for the order finding problem).\nIf the order \\(r\\) is odd, we abort.\nCalculate \\(x:= a^{\\frac{r}{2}}+1 \\bmod N\\) and \\(y:= a^{\\frac{r}{2}}-1 \\bmod N\\).\nIf \\(\\gcd(x,N) \\in \\{1,N\\}\\), we abort.\nWe compute \\(p = \\gcd(x,N)\\) and \\(q = \\gcd(y,N)\\).\n\nThe output of the reduction are \\(p,q\\), such that \\(pq = N\\). This holds, since \\[\nxy = (a^{\\frac{r}{2}}+1) (a^{\\frac{r}{2}}-1) = a^r - 1 \\equiv 1-1 = 0 \\pmod N\n\\]\n\n\n\n\n\n\n\nTheorem 9.2 (Probability of an abort) If \\(N\\) has at least two different prime factors and \\(N\\) is odd, then the probability to abort is \\(\\leq \\frac{1}{2}\\).\n\n\n\n\nAll in all this reduction shows, that if we have an oracle which can solve the period finding problem within reasonable runtime, we can also solve the factoring problem within reasonable runtime (since all other operations are classically fast to compute).",
     "crumbs": [
       "Quantum Algorithms",
       "<span class='chapter-number'>9</span>  <span class='chapter-title'>Shor's Algorithm</span>"
@@ -134,7 +167,7 @@
     "href": "shorsAlgorithm.html#sec-shor-algo",
     "title": "9  Shor’s Algorithm",
     "section": "9.3 The quantum algorithm for period finding",
-    "text": "9.3 The quantum algorithm for period finding\nWe now look into an quantum algorithm that solves the period finding problem within reasonable runtime. The quantum circuit for Shor’s algorithm requires a \\(f:\\{0,1\\}^n\\rightarrow\\{0,1\\}^m\\) which is \\(r\\)-periodic and is show in this figure:\n\n\n\nShor’s algorithm (quantum part)\n\n\nThe algorithm works as follows:\n\nWe start with a \\(\\ket{0}\\) entry on every wire.\nWe bring the top wire into the superposition over all entries. The quantum state is then \\(2^\\frac{-n}{2}\\sum_x \\ket{x} \\otimes \\ket{0^m}\\).\nWe apply \\(U_f\\), which is the unitary of \\(f:\\{0,1\\}^n\\rightarrow\\{0,1\\}^m\\). This calculates the superposition over all possible values \\(f(x)\\) on the bottom wire. The resulting quantum state is \\(\\frac{-n}{2}\\sum_x \\ket{x,f(x)}\\).\nTo understand the algorithm better, we measure the bottom wire at this point. This will give us one random value \\(f(x_0)\\) for some \\(x_0\\). The top wire will then contain a superposition over all values \\(x\\) where \\(f(x) = f(x_0)\\). Since \\(f\\) is know to be \\(r\\)-periodic, we know, that \\(f(x) = f(x_0)\\) iff \\(x \\equiv x_0 \\bmod r\\). This means, that on the resulting quantum state on the top wire is periodic and can be written as \\(\\frac{1}{\\sqrt{2^\\frac{n}{r}}} \\sum_{x\\equiv x_0 \\bmod r} \\ket{x} \\otimes \\ket{f(x_0)}\\).\nWe apply the Discrete Fourier Transform on the top wire. This will “analyze” the top wire for the period and output a vector with entries at multiples of \\(\\frac{2^n}{r}\\) as seen in Theorem 9.1. For simplicity we assume, that \\(r \\mid 2^n\\) holds.\nWe measure the top wire and get one random multiple of \\(\\frac{2^n}{r}\\), which we can denote as \\(a\\cdot\\frac{2^n}{r}\\)\n\nSince we get a multiple of \\(\\frac{2^n}{r}\\) on each run, we can simply run the algorithm multiple times to get different multiples and then compute \\(\\frac{2^n}{r}\\) by taking the gcd of those multiples. From that we compute \\(r\\).\nUnfortunately this only works because we assumed \\(r \\mid 2^n\\). Since this does usually not hold, we only get approximate multiples of \\(\\frac{2^n}{r}\\) (which is not even an integer) and thus post processing is a bit more complex.",
+    "text": "9.3 The quantum algorithm for period finding\nWe now look into an quantum algorithm that solves the period finding problem within reasonable runtime. The quantum circuit for Shor’s algorithm requires a \\(f:\\mathbb{Z}\\rightarrow X\\) which is \\(r\\)-periodic. We choose a number \\(m\\) which needs to be big enough to encode the values of \\(X\\) and choose a number \\(n\\) under the condition of \\(n\\geq 2 \\log_2(r)\\) for the post processing to work. Note that when using this algorithm for factoring, we choose \\(n\\) to be \\(n:=2\\lvert N \\rvert\\), since \\(r \\leq N\\). \\(\\lvert N\\rvert\\) denotes the number of bits needed to encode \\(N\\) here.\nThe quantum algorithm for period finding is shown in this figure:\n\n\n\nShor’s algorithm (quantum part)\n\n\nThe algorithm works as follows:\n\nWe start with a \\(\\ket{0}\\) entry on every wire.\nWe bring the top wire into the superposition over all entries. The quantum state is then \\(2^\\frac{-n}{2}\\sum_x \\ket{x} \\otimes \\ket{0^m}\\).\nWe apply \\(U_f\\), which is the unitary of \\(f:\\{0,1\\}^n\\rightarrow\\{0,1\\}^m\\). This calculates the superposition over all possible values \\(f(x)\\) on the bottom wire. The resulting quantum state is \\(2^\\frac{-n}{2}\\sum_x \\ket{x,f(x)}\\).\nTo understand the algorithm better, we measure the bottom wire at this point. This will give us one random value \\(f(x_0)\\) for some \\(x_0\\). The top wire will then contain a superposition over all values \\(x\\) where \\(f(x) = f(x_0)\\). Since \\(f\\) is know to be \\(r\\)-periodic, we know, that \\(f(x) = f(x_0)\\) iff \\(x \\equiv x_0 \\bmod r\\). This means, that on the resulting quantum state on the top wire is periodic and can be written as \\(\\frac{1}{\\sqrt{2^\\frac{n}{r}}} \\sum_{x\\equiv x_0 \\bmod r} \\ket{x} \\otimes \\ket{f(x_0)}\\).\nWe apply the Discrete Fourier Transform on the top wire. This will “analyze” the top wire for the period and output a vector with entries at multiples of \\(\\frac{2^n}{r}\\) as seen in Theorem 9.1. For simplicity we assume, that \\(r \\mid 2^n\\) holds.\nWe measure the top wire and get one random multiple of \\(\\frac{2^n}{r}\\), which we can denote as \\(a\\cdot\\frac{2^n}{r}\\)\n\nSince we get a multiple of \\(\\frac{2^n}{r}\\) on each run, we can simply run the algorithm multiple times to get different multiples and then compute \\(\\frac{2^n}{r}\\) by taking the gcd of those multiples. From that we compute \\(r\\). Unfortunately this only works because we assumed \\(r \\mid 2^n\\). Since this does usually not hold, we only get approximate multiples of \\(\\frac{2^n}{r}\\) (which is not even an integer) and thus post processing is a bit more complex.",
     "crumbs": [
       "Quantum Algorithms",
       "<span class='chapter-number'>9</span>  <span class='chapter-title'>Shor's Algorithm</span>"
@@ -145,7 +178,18 @@
     "href": "shorsAlgorithm.html#post-processing",
     "title": "9  Shor’s Algorithm",
     "section": "9.4 Post processing",
-    "text": "9.4 Post processing\nSo far we have seen the DFT to analyze the period of a quantum state, we have seen a way to reduce the factoring problem to the period finding and we have seen a quantum algorithm for finding an approximate multiple of such a period of a function. We just need one final step to find \\(r\\). For this we start with a theorem:\n\n\n\n\n\n\n\nTheorem 9.3 If \\(\\{0,1\\}^n \\rightarrow \\{0,1\\}^n\\) is \\(r\\)-periodic with probability \\(\\Omega(1/\\log\\log r)\\) the following holds: \\[\n\\frac{-r}{2} \\leq rc\\bmod 2^n \\leq \\frac{r}{2}\n\\] where \\(c\\) is the output of the second measurement of the quantum circuit described in Section 9.3.\n\n\n\n\nWe assume that the theorem holds for our outcome of the second measurement (If that is not the case, our result will be wrong and we can just run the quantum algorithm again to get a different outcome):\nThen exists a \\(d\\) such that: \\[\n\\begin{aligned}\n&\\lvert rc - d2^n\\rvert \\leq \\frac{r}{2} \\\\\n\\Leftrightarrow&\\lvert \\frac{c}{2^n} - \\frac{d}{r}\\rvert \\leq \\frac{1}{2^{n+1}}\n\\end{aligned}\n\\] The fraction \\(\\frac{c}{2^n}\\) is known, so the goal is to find a fraction \\(\\frac{d}{r}\\) that is \\(\\frac{1}{2^{n+1}}\\) close to \\(\\frac{c}{2^n}\\).\nThe rest of postprocessing will be updated after the next lecture.",
+    "text": "9.4 Post processing\nSo far we have seen the DFT to analyze the period of a quantum state, we have seen a way to reduce the factoring problem to the period finding and we have seen a quantum algorithm for finding an approximate multiple of such a period of a function. We just need one final step to find \\(r\\). For this we start with a theorem:\n\n\n\n\n\n\n\nTheorem 9.3 Iff \\(f: \\mathbb{Z} \\rightarrow X\\) is \\(r\\)-periodic, the following holds with probability \\(\\Omega(1/\\log\\log r)\\): \\[\n\\frac{-r}{2} \\leq rc\\bmod 2^n \\leq \\frac{r}{2}\n\\] where \\(c\\) is the output of the second measurement of the quantum circuit described in Section 9.3 and \\(n\\) is the number of qubits on the upper wire of the quantum circuit.\n\n\n\n\nWe assume that the theorem holds for our outcome \\(c\\) of the second measurement (if that is not the case, our result will be wrong and we can just run the quantum algorithm again to get a different outcome):\nThen exists an integer \\(d\\) such that: \\[\n\\begin{aligned}\n&\\lvert rc - d2^n\\rvert \\leq \\frac{r}{2} \\\\\n\\iff&\\lvert \\frac{c}{2^n} - \\frac{d}{r}\\rvert \\leq \\frac{1}{2^{n+1}} && |\\text{ division by } r\\cdot 2^n\n\\end{aligned}\n\\] The fraction \\(\\frac{c}{2^n}\\) is known, so the goal is to find a fraction \\(\\frac{d}{r}\\) that is \\(\\frac{1}{2^{n+1}}\\)-close to \\(\\frac{c}{2^n}\\).\nSince \\(n\\) is the number of qubits used in the quantum circuit and was chosen, such that \\(n \\geq 2\\log_2(r)\\) and thus \\(2^{n} \\geq 2 r^2\\) holds and from this we know that \\(\\frac{1}{2^{n+1}} \\leq \\frac{1}{2r^2}\\) holds as well.\nSo if Theorem 9.3 holds, we now \\(\\lvert \\frac{c}{2^n} - \\frac{d}{r} \\rvert \\leq \\frac{1}{2r^2}\\) also holds. Our task is now rewritten to find \\(\\frac{d}{r}\\) under this condition. For this we use another theorem:\n\n\n\n\n\n\n\nTheorem 9.4 For a given real number \\(\\varphi \\geq 0\\) and integer \\(q &gt; 0\\) there is at most one fraction \\(\\frac{d}{r}\\) with \\(r \\leq q\\) and \\(\\lvert \\varphi - \\frac{d}{r} \\rvert \\leq \\frac{1}{2q}\\). In this case, this \\(\\frac{d}{r}\\) is a convergent of the continued fraction expansion of \\(\\varphi\\).\n\n\n\n\nThis theorem uses the convergent of a continued fraction expansion. A continued fraction expansion of a number \\(t\\) is the number rewritten as a fraction in the form\n\\[\nt = a_0 + \\frac{1}{a_1 + \\frac{1}{a_2 + \\frac{1}{a_3 + \\dots}}}\n\\]\nwhere \\(a_i\\) always has to be the biggest possible integer. We call \\([a_0,a_1,a_2,a_3,\\dots]\\) the continued expansion of \\(t\\). The expansion is finite iff t is rational. For a given continued expansion, a prefix \\([a_0,\\dots,a_i]\\) is called a convergent. Writing this convergent as a normal fraction will give us an approximation of the number \\(t\\).\n\n\n\n\n\n\nExample: continued expansion of a fraction\n\n\n\nThe number \\(2.3\\) can be written as \\[\n2.3 = 2 + \\frac{1}{3 + \\frac{1}{3 + 0}}\n\\] and the continued fraction expansion of \\(2.3\\) is \\([2,3,3]\\). The expansions \\([2]\\) and \\([2,3]\\) are convergents of the expansion of \\(2.3\\) and written as a fraction will give us the approximations \\(2\\) and \\(2+\\frac{1}{3} = 2.\\bar{3}\\).\nThe number \\(0.99\\) can be written as\n\\[\n0.99 = 0 + \\frac{1}{1 + \\frac{1}{99 + 0}}\n\\] and the continued fraction expansion of \\(0.99\\) is \\([0,1,99]\\). The expansions \\([0]\\) and \\([0,1]\\) are convergents of the expansion of \\(0.99\\) and written as a fraction will give us the approximations \\(0\\) and \\(0+\\frac{1}{1} = 1\\).\n\n\nUsing Theorem 9.4 (with \\(\\varphi:= \\frac{c}{2^n}\\) and \\(q:=2^n\\)) we can find \\(\\frac{d}{r}\\) and from this \\(r\\) which is the period of our function using the following steps:\nFor each convergent \\(\\gamma\\) of \\(\\varphi\\) do the following:\n\nCompute \\(\\gamma\\) as fraction \\(\\frac{d}{r}\\).\nStop if \\(r \\leq 2^n\\) and \\(\\varphi\\) is \\(\\frac{1}{2^{n+1}}\\)-close to \\(\\frac{c}{2^n}\\) and return \\(r\\).\n\nNote: It can happen, that the resulting fraction does not have the right \\(r\\) in the denominator, because \\(\\frac{d}{r}\\) was simplified (if numerator and denominator shared a common factor). But the probability of this happening is sufficiently small and already included in the probability in Theorem 9.3.\nThis completes the postprocessing of Shor’s algorithm.",
+    "crumbs": [
+      "Quantum Algorithms",
+      "<span class='chapter-number'>9</span>  <span class='chapter-title'>Shor's Algorithm</span>"
+    ]
+  },
+  {
+    "objectID": "shorsAlgorithm.html#constructing-the-dft",
+    "href": "shorsAlgorithm.html#constructing-the-dft",
+    "title": "9  Shor’s Algorithm",
+    "section": "9.5 Constructing the DFT",
+    "text": "9.5 Constructing the DFT\nSo far we have described everything necessary for Shor’s algorithm, but only described the matrix representation of the \\(\\operatorname{DFT}_M\\). We will now take a closer look into implementing the \\(\\operatorname{DFT}_M\\) as a quantum circuit. Since we only use the \\(\\operatorname{DFT}_M\\) for Shor’s algorithm so far, we will only look at \\(M=2^n\\), which is the \\(\\operatorname{DFT}\\) applied on \\(n\\) qubits.\nTo start the circuit, we recall the definition of the \\(\\operatorname{DFT}_{2^n}\\) from Definition 9.1: \\(\\operatorname{DFT}_{2^n} := \\frac{1}{\\sqrt{{2^n}}} (\\omega^{kl})_{kl}\\) with \\(\\omega:= e^{2\\pi i / 2^n}\\). To apply the \\(\\operatorname{DFT}_{2^n}\\) to a quantum state \\(\\ket{j}\\) we calculate \\[\n\\operatorname{DFT}_{2^n}\\ket{j} = \\frac{1}{\\sqrt{{2^n}}} \\sum_k e^{2\\pi i j k 2^{-n}} \\ket{k}\n\\] We can rewrite this as follows: \\[\n\\begin{aligned}\n\\operatorname{DFT}_{2^n}\\ket{j} =& \\frac{1}{\\sqrt{{2^n}}} \\sum_k e^{2\\pi i j k 2^{-n}} \\ket{k}\\\\\n=& \\frac{1}{\\sqrt{{2^n}}} \\sum_{k_1} \\dots \\sum_{k_n} e^{2\\pi i j (\\sum_l k_l 2^{-l})} \\ket{k_1 \\dots k_n}\\\\\n=& \\frac{1}{\\sqrt{{2^n}}} \\sum_{k_1} \\dots \\sum_{k_n} \\bigotimes^n_{l=1} e^{2\\pi i j (k_l 2^{-l})} \\ket{k_l}\\\\\n=& \\frac{1}{\\sqrt{{2^n}}} \\bigotimes_{l=1}^n \\sum_{k_l} e^{2\\pi i j (k_l 2^{-l})} \\ket{k_l}\\\\\n=& \\frac{1}{\\sqrt{{2^n}}} \\bigotimes_{l=1}^n (\\ket{0} +  e^{2\\pi i j 2^{-l}} \\ket{1})\\\\\n=& \\frac{1}{\\sqrt{{2^n}}} \\bigotimes_{l=1}^n (\\ket{0} +  e^{2\\pi i 0.j_{n-(l-1)} \\dots j_{n}} \\ket{1})\\\\\n=& \\bigotimes_{l=1}^n \\frac{1}{\\sqrt{2}}(\\ket{0} +  e^{2\\pi i 0.j_{n-(l-1)} \\dots j_{n}} \\ket{1})\n\\end{aligned}\n\\] The expression \\(0.j\\) expresses a binary fraction (e.g. \\(0.101 = \\frac{1}{2} + \\frac{1}{8} = \\frac{5}{8}\\)).\nWith this we have shown, that we can write \\(\\operatorname{DFT}_{2^n}\\ket{j}\\) as the following tensor product of quantum states\n\\[\n\\frac{1}{\\sqrt{2}}(\\ket{0} +  e^{2\\pi i 0.j_n} \\ket{1}) \\otimes \\frac{1}{\\sqrt{2}}(\\ket{0} +  e^{2\\pi i 0.j_{n-1}j_n} \\ket{1}) \\otimes \\dots \\otimes \\frac{1}{\\sqrt{2}}(\\ket{0} +  e^{2\\pi i 0.j_1\\dots j_n} \\ket{1})\n\\]\nThe rest of this section will be updated after the next lecture.",
     "crumbs": [
       "Quantum Algorithms",
       "<span class='chapter-number'>9</span>  <span class='chapter-title'>Shor's Algorithm</span>"
diff --git a/_book/shorsAlgorithm.html b/_book/shorsAlgorithm.html
index 3e16d3cf4d3c48536b6b96c16d82969f67f994ab..eb5f3257de918f846d58ef8a29210136b3ba2439 100644
--- a/_book/shorsAlgorithm.html
+++ b/_book/shorsAlgorithm.html
@@ -250,6 +250,7 @@ window.Quarto = {
   <li><a href="#reducing-factoring-to-period-finding" id="toc-reducing-factoring-to-period-finding" class="nav-link" data-scroll-target="#reducing-factoring-to-period-finding"><span class="header-section-number">9.2</span> Reducing factoring to period finding</a></li>
   <li><a href="#sec-shor-algo" id="toc-sec-shor-algo" class="nav-link" data-scroll-target="#sec-shor-algo"><span class="header-section-number">9.3</span> The quantum algorithm for period finding</a></li>
   <li><a href="#post-processing" id="toc-post-processing" class="nav-link" data-scroll-target="#post-processing"><span class="header-section-number">9.4</span> Post processing</a></li>
+  <li><a href="#constructing-the-dft" id="toc-constructing-the-dft" class="nav-link" data-scroll-target="#constructing-the-dft"><span class="header-section-number">9.5</span> Constructing the DFT</a></li>
   </ul>
 </nav>
     </div>
@@ -287,9 +288,9 @@ window.Quarto = {
 </div>
 <div class="callout-body-container">
 <div id="def-shor-dft" class="definition theorem">
-<p><span class="theorem-title"><strong>Definition 9.1 (Discrete Fourier Transformation (DFT))</strong></span> The discrete Fourier transform (DFT) is a linear transformation on <span class="math inline">\(\mathbb{C}^N\)</span> represented by the matrix <span class="math display">\[
-\operatorname{DFT}_N = \frac{1}{\sqrt{N}} (\omega^{kl})_{kl} \in \mathbb{C}^{N\times N}
-\]</span> with <span class="math inline">\(\omega = e^{2i\pi/N}\)</span>, which is the <span class="math inline">\(N\)</span>-th root of unity.</p>
+<p><span class="theorem-title"><strong>Definition 9.1 (Discrete Fourier Transformation (DFT))</strong></span> The discrete Fourier transform (DFT) is a linear transformation on <span class="math inline">\(\mathbb{C}^M\)</span> represented by the matrix <span class="math display">\[
+\operatorname{DFT}_M = \frac{1}{\sqrt{M}} (\omega^{kl})_{kl} \in \mathbb{C}^{M\times M}
+\]</span> with <span class="math inline">\(\omega = e^{2i\pi/M}\)</span>, which is the <span class="math inline">\(M\)</span>-th root of unity.</p>
 </div>
 </div>
 </div>
@@ -305,9 +306,9 @@ window.Quarto = {
 <p><span class="theorem-title"><strong>Theorem 9.1 (Properties of the DFT)</strong></span> Here are some properties of the DFT which can be used without further proof.</p>
 <ol type="1">
 <li>The DFT is unitary.</li>
-<li><span class="math inline">\(\omega^t = \omega^{t\mod N}\)</span> for all <span class="math inline">\(t \in \mathbb{Z}\)</span>.</li>
-<li>Given a quantum state <span class="math inline">\(\psi \in \mathbb{C}^N\)</span> which is <span class="math inline">\(r\)</span>-periodic and where <span class="math inline">\(r\mid N\)</span>, <span class="math inline">\(\operatorname{DFT}_N \psi\)</span> will compute a quantum state <span class="math inline">\(\phi \in \mathbb{C}^N\)</span>, which has non-zero values on the multiples of <span class="math inline">\(\frac{N}{r}\)</span>. Note that <span class="math inline">\(\frac{N}{r}\)</span> intuitively represents the frequency of <span class="math inline">\(\psi\)</span>. This means, that <span class="math display">\[
-|\phi_i| = \begin{cases} \frac{1}{\sqrt{t}}, &amp; \text{if}\ \frac{N}{t}\mid i \\ 0, &amp; \text{otherwise} \end{cases}
+<li><span class="math inline">\(\omega^t = \omega^{t\mod M}\)</span> for all <span class="math inline">\(t \in \mathbb{Z}\)</span>.</li>
+<li>Given a quantum state <span class="math inline">\(\psi \in \mathbb{C}^M\)</span> which is <span class="math inline">\(r\)</span>-periodic and where <span class="math inline">\(r\mid M\)</span>, <span class="math inline">\(\operatorname{DFT}_M \psi\)</span> will compute a quantum state <span class="math inline">\(\phi \in \mathbb{C}^M\)</span>, which has non-zero values on the multiples of <span class="math inline">\(\frac{M}{r}\)</span>. Note that <span class="math inline">\(\frac{M}{r}\)</span> intuitively represents the frequency of <span class="math inline">\(\psi\)</span>. This means, that <span class="math display">\[
+|\phi_i| = \begin{cases} \frac{1}{\sqrt{r}}, &amp; \text{if}\ \frac{M}{r}\mid i \\ 0, &amp; \text{otherwise} \end{cases}
 \]</span></li>
 </ol>
 </div>
@@ -351,7 +352,7 @@ window.Quarto = {
 </div>
 <div class="callout-body-container">
 <div id="def-shor-order" class="definition theorem">
-<p><span class="theorem-title"><strong>Definition 9.4 (Order finding problem)</strong></span> For known <span class="math inline">\(a\)</span> and <span class="math inline">\(N\)</span> which are relatively prime, find the period <span class="math inline">\(r\)</span> of <span class="math inline">\(f(i) = a^i \bmod n\)</span>. We call <span class="math inline">\(r\)</span> the order of <span class="math inline">\(a\)</span> written <span class="math inline">\(r = \text{ ord } a\)</span>. (This is similar to finding the smallest <span class="math inline">\(i &gt; 0\)</span> with <span class="math inline">\(f(i) = 1\)</span>).</p>
+<p><span class="theorem-title"><strong>Definition 9.4 (Order finding problem)</strong></span> For known <span class="math inline">\(a\)</span> and <span class="math inline">\(N\)</span> which are relatively prime, find the period <span class="math inline">\(r\)</span> of <span class="math inline">\(f(i) = a^i \bmod N\)</span>. We call <span class="math inline">\(r\)</span> the order of <span class="math inline">\(a\)</span> written <span class="math inline">\(r = \text{ ord } a\)</span>. (This is similar to finding the smallest <span class="math inline">\(i &gt; 0\)</span> with <span class="math inline">\(f(i) = 1\)</span>).</p>
 </div>
 </div>
 </div>
@@ -359,7 +360,7 @@ window.Quarto = {
 <p>Since the order finding problem is just the period finding problem for a specific <span class="math inline">\(f(x)\)</span>, we know that if we can solve the period finding problem within reasonable runtime, we can also solve the order finding problem within reasonable runtime. We now reduce the factoring problem to the order finding problem:</p>
 <p>We have a integer <span class="math inline">\(N\)</span> as an input for the factoring problem.</p>
 <ol type="1">
-<li>Pick an <span class="math inline">\(a \in \{1,...,N-1\}\)</span> with <span class="math inline">\(a\)</span> relatively prime to <span class="math inline">\(n\)</span>.</li>
+<li>Pick an <span class="math inline">\(a \in \{1,\dots,N-1\}\)</span> with <span class="math inline">\(a\)</span> relatively prime to <span class="math inline">\(N\)</span>.</li>
 <li>Compute the order of <span class="math inline">\(a\)</span>, so that <span class="math inline">\(r = \text{ ord } a\)</span> (using the solver for the order finding problem).</li>
 <li>If the order <span class="math inline">\(r\)</span> is odd, we abort.</li>
 <li>Calculate <span class="math inline">\(x:= a^{\frac{r}{2}}+1 \bmod N\)</span> and <span class="math inline">\(y:= a^{\frac{r}{2}}-1 \bmod N\)</span>.</li>
@@ -385,7 +386,8 @@ xy = (a^{\frac{r}{2}}+1) (a^{\frac{r}{2}}-1) = a^r - 1 \equiv 1-1 = 0 \pmod N
 </section>
 <section id="sec-shor-algo" class="level2" data-number="9.3">
 <h2 data-number="9.3" class="anchored" data-anchor-id="sec-shor-algo"><span class="header-section-number">9.3</span> The quantum algorithm for period finding</h2>
-<p>We now look into an quantum algorithm that solves the period finding problem within reasonable runtime. The quantum circuit for Shor’s algorithm requires a <span class="math inline">\(f:\{0,1\}^n\rightarrow\{0,1\}^m\)</span> which is <span class="math inline">\(r\)</span>-periodic and is show in this figure:</p>
+<p>We now look into an quantum algorithm that solves the period finding problem within reasonable runtime. The quantum circuit for Shor’s algorithm requires a <span class="math inline">\(f:\mathbb{Z}\rightarrow X\)</span> which is <span class="math inline">\(r\)</span>-periodic. We choose a number <span class="math inline">\(m\)</span> which needs to be big enough to encode the values of <span class="math inline">\(X\)</span> and choose a number <span class="math inline">\(n\)</span> under the condition of <span class="math inline">\(n\geq 2 \log_2(r)\)</span> for the post processing to work. Note that when using this algorithm for factoring, we choose <span class="math inline">\(n\)</span> to be <span class="math inline">\(n:=2\lvert N \rvert\)</span>, since <span class="math inline">\(r \leq N\)</span>. <span class="math inline">\(\lvert N\rvert\)</span> denotes the number of bits needed to encode <span class="math inline">\(N\)</span> here.</p>
+<p>The quantum algorithm for period finding is shown in this figure:</p>
 <div class="quarto-figure quarto-figure-center">
 <figure class="figure">
 <p><img src="shor.svg" class="img-fluid figure-img" style="width:100.0%"></p>
@@ -396,13 +398,12 @@ xy = (a^{\frac{r}{2}}+1) (a^{\frac{r}{2}}-1) = a^r - 1 \equiv 1-1 = 0 \pmod N
 <ol type="1">
 <li>We start with a <span class="math inline">\(\ket{0}\)</span> entry on every wire.</li>
 <li>We bring the top wire into the superposition over all entries. The quantum state is then <span class="math inline">\(2^\frac{-n}{2}\sum_x \ket{x} \otimes \ket{0^m}\)</span>.</li>
-<li>We apply <span class="math inline">\(U_f\)</span>, which is the unitary of <span class="math inline">\(f:\{0,1\}^n\rightarrow\{0,1\}^m\)</span>. This calculates the superposition over all possible values <span class="math inline">\(f(x)\)</span> on the bottom wire. The resulting quantum state is <span class="math inline">\(\frac{-n}{2}\sum_x \ket{x,f(x)}\)</span>.</li>
+<li>We apply <span class="math inline">\(U_f\)</span>, which is the unitary of <span class="math inline">\(f:\{0,1\}^n\rightarrow\{0,1\}^m\)</span>. This calculates the superposition over all possible values <span class="math inline">\(f(x)\)</span> on the bottom wire. The resulting quantum state is <span class="math inline">\(2^\frac{-n}{2}\sum_x \ket{x,f(x)}\)</span>.</li>
 <li>To understand the algorithm better, we measure the bottom wire at this point. This will give us one random value <span class="math inline">\(f(x_0)\)</span> for some <span class="math inline">\(x_0\)</span>. The top wire will then contain a superposition over all values <span class="math inline">\(x\)</span> where <span class="math inline">\(f(x) = f(x_0)\)</span>. Since <span class="math inline">\(f\)</span> is know to be <span class="math inline">\(r\)</span>-periodic, we know, that <span class="math inline">\(f(x) = f(x_0)\)</span> iff <span class="math inline">\(x \equiv x_0 \bmod r\)</span>. This means, that on the resulting quantum state on the top wire is periodic and can be written as <span class="math inline">\(\frac{1}{\sqrt{2^\frac{n}{r}}} \sum_{x\equiv x_0 \bmod r} \ket{x} \otimes \ket{f(x_0)}\)</span>.</li>
 <li>We apply the Discrete Fourier Transform on the top wire. This will “analyze” the top wire for the period and output a vector with entries at multiples of <span class="math inline">\(\frac{2^n}{r}\)</span> as seen in <a href="#thm-dft-properties" class="quarto-xref">Theorem&nbsp;<span>9.1</span></a>. For simplicity we assume, that <span class="math inline">\(r \mid 2^n\)</span> holds.</li>
 <li>We measure the top wire and get one random multiple of <span class="math inline">\(\frac{2^n}{r}\)</span>, which we can denote as <span class="math inline">\(a\cdot\frac{2^n}{r}\)</span></li>
 </ol>
-<p>Since we get a multiple of <span class="math inline">\(\frac{2^n}{r}\)</span> on each run, we can simply run the algorithm multiple times to get different multiples and then compute <span class="math inline">\(\frac{2^n}{r}\)</span> by taking the gcd of those multiples. From that we compute <span class="math inline">\(r\)</span>.</p>
-<p>Unfortunately this only works because we assumed <span class="math inline">\(r \mid 2^n\)</span>. Since this does usually not hold, we only get approximate multiples of <span class="math inline">\(\frac{2^n}{r}\)</span> (which is not even an integer) and thus post processing is a bit more complex.</p>
+<p>Since we get a multiple of <span class="math inline">\(\frac{2^n}{r}\)</span> on each run, we can simply run the algorithm multiple times to get different multiples and then compute <span class="math inline">\(\frac{2^n}{r}\)</span> by taking the gcd of those multiples. From that we compute <span class="math inline">\(r\)</span>. Unfortunately this only works because we assumed <span class="math inline">\(r \mid 2^n\)</span>. Since this does usually not hold, we only get approximate multiples of <span class="math inline">\(\frac{2^n}{r}\)</span> (which is not even an integer) and thus post processing is a bit more complex.</p>
 </section>
 <section id="post-processing" class="level2" data-number="9.4">
 <h2 data-number="9.4" class="anchored" data-anchor-id="post-processing"><span class="header-section-number">9.4</span> Post processing</h2>
@@ -414,21 +415,88 @@ xy = (a^{\frac{r}{2}}+1) (a^{\frac{r}{2}}-1) = a^r - 1 \equiv 1-1 = 0 \pmod N
 </div>
 <div class="callout-body-container">
 <div id="thm-shor-post-process" class="therorem theorem">
-<p><span class="theorem-title"><strong>Theorem 9.3</strong></span> If <span class="math inline">\(\{0,1\}^n \rightarrow \{0,1\}^n\)</span> is <span class="math inline">\(r\)</span>-periodic with probability <span class="math inline">\(\Omega(1/\log\log r)\)</span> the following holds: <span class="math display">\[
+<p><span class="theorem-title"><strong>Theorem 9.3</strong></span> Iff <span class="math inline">\(f: \mathbb{Z} \rightarrow X\)</span> is <span class="math inline">\(r\)</span>-periodic, the following holds with probability <span class="math inline">\(\Omega(1/\log\log r)\)</span>: <span class="math display">\[
 \frac{-r}{2} \leq rc\bmod 2^n \leq \frac{r}{2}
-\]</span> where <span class="math inline">\(c\)</span> is the output of the second measurement of the quantum circuit described in <a href="#sec-shor-algo" class="quarto-xref"><span>Section 9.3</span></a>.</p>
+\]</span> where <span class="math inline">\(c\)</span> is the output of the second measurement of the quantum circuit described in <a href="#sec-shor-algo" class="quarto-xref"><span>Section 9.3</span></a> and <span class="math inline">\(n\)</span> is the number of qubits on the upper wire of the quantum circuit.</p>
 </div>
 </div>
 </div>
 </div>
-<p>We assume that the theorem holds for our outcome of the second measurement (If that is not the case, our result will be wrong and we can just run the quantum algorithm again to get a different outcome):</p>
-<p>Then exists a <span class="math inline">\(d\)</span> such that: <span class="math display">\[
+<p>We assume that the theorem holds for our outcome <span class="math inline">\(c\)</span> of the second measurement (if that is not the case, our result will be wrong and we can just run the quantum algorithm again to get a different outcome):</p>
+<p>Then exists an integer <span class="math inline">\(d\)</span> such that: <span class="math display">\[
 \begin{aligned}
 &amp;\lvert rc - d2^n\rvert \leq \frac{r}{2} \\
-\Leftrightarrow&amp;\lvert \frac{c}{2^n} - \frac{d}{r}\rvert \leq \frac{1}{2^{n+1}}
+\iff&amp;\lvert \frac{c}{2^n} - \frac{d}{r}\rvert \leq \frac{1}{2^{n+1}} &amp;&amp; |\text{ division by } r\cdot 2^n
 \end{aligned}
-\]</span> The fraction <span class="math inline">\(\frac{c}{2^n}\)</span> is known, so the goal is to find a fraction <span class="math inline">\(\frac{d}{r}\)</span> that is <span class="math inline">\(\frac{1}{2^{n+1}}\)</span> close to <span class="math inline">\(\frac{c}{2^n}\)</span>.</p>
-<p>The rest of postprocessing will be updated after the next lecture.</p>
+\]</span> The fraction <span class="math inline">\(\frac{c}{2^n}\)</span> is known, so the goal is to find a fraction <span class="math inline">\(\frac{d}{r}\)</span> that is <span class="math inline">\(\frac{1}{2^{n+1}}\)</span>-close to <span class="math inline">\(\frac{c}{2^n}\)</span>.</p>
+<p>Since <span class="math inline">\(n\)</span> is the number of qubits used in the quantum circuit and was chosen, such that <span class="math inline">\(n \geq 2\log_2(r)\)</span> and thus <span class="math inline">\(2^{n} \geq 2 r^2\)</span> holds and from this we know that <span class="math inline">\(\frac{1}{2^{n+1}} \leq \frac{1}{2r^2}\)</span> holds as well.</p>
+<p>So if <a href="#thm-shor-post-process" class="quarto-xref">Theorem&nbsp;<span>9.3</span></a> holds, we now <span class="math inline">\(\lvert \frac{c}{2^n} - \frac{d}{r} \rvert \leq \frac{1}{2r^2}\)</span> also holds. Our task is now rewritten to find <span class="math inline">\(\frac{d}{r}\)</span> under this condition. For this we use another theorem:</p>
+<div class="callout callout-style-simple callout-note no-icon">
+<div class="callout-body d-flex">
+<div class="callout-icon-container">
+<i class="callout-icon no-icon"></i>
+</div>
+<div class="callout-body-container">
+<div id="thm-shor-post-process-frac" class="theorem">
+<p><span class="theorem-title"><strong>Theorem 9.4</strong></span> For a given real number <span class="math inline">\(\varphi \geq 0\)</span> and integer <span class="math inline">\(q &gt; 0\)</span> there is at most one fraction <span class="math inline">\(\frac{d}{r}\)</span> with <span class="math inline">\(r \leq q\)</span> and <span class="math inline">\(\lvert \varphi - \frac{d}{r} \rvert \leq \frac{1}{2q}\)</span>. In this case, this <span class="math inline">\(\frac{d}{r}\)</span> is a convergent of the continued fraction expansion of <span class="math inline">\(\varphi\)</span>.</p>
+</div>
+</div>
+</div>
+</div>
+<p>This theorem uses the convergent of a continued fraction expansion. A continued fraction expansion of a number <span class="math inline">\(t\)</span> is the number rewritten as a fraction in the form</p>
+<p><span class="math display">\[
+t = a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{a_3 + \dots}}}
+\]</span></p>
+<p>where <span class="math inline">\(a_i\)</span> always has to be the biggest possible integer. We call <span class="math inline">\([a_0,a_1,a_2,a_3,\dots]\)</span> the continued expansion of <span class="math inline">\(t\)</span>. The expansion is finite iff t is rational. For a given continued expansion, a prefix <span class="math inline">\([a_0,\dots,a_i]\)</span> is called a convergent. Writing this convergent as a normal fraction will give us an approximation of the number <span class="math inline">\(t\)</span>.</p>
+<div class="callout callout-style-simple callout-tip no-icon callout-titled">
+<div class="callout-header d-flex align-content-center">
+<div class="callout-icon-container">
+<i class="callout-icon no-icon"></i>
+</div>
+<div class="callout-title-container flex-fill">
+Example: continued expansion of a fraction
+</div>
+</div>
+<div class="callout-body-container callout-body">
+<p>The number <span class="math inline">\(2.3\)</span> can be written as <span class="math display">\[
+2.3 = 2 + \frac{1}{3 + \frac{1}{3 + 0}}
+\]</span> and the continued fraction expansion of <span class="math inline">\(2.3\)</span> is <span class="math inline">\([2,3,3]\)</span>. The expansions <span class="math inline">\([2]\)</span> and <span class="math inline">\([2,3]\)</span> are convergents of the expansion of <span class="math inline">\(2.3\)</span> and written as a fraction will give us the approximations <span class="math inline">\(2\)</span> and <span class="math inline">\(2+\frac{1}{3} = 2.\bar{3}\)</span>.</p>
+<p>The number <span class="math inline">\(0.99\)</span> can be written as</p>
+<p><span class="math display">\[
+0.99 = 0 + \frac{1}{1 + \frac{1}{99 + 0}}
+\]</span> and the continued fraction expansion of <span class="math inline">\(0.99\)</span> is <span class="math inline">\([0,1,99]\)</span>. The expansions <span class="math inline">\([0]\)</span> and <span class="math inline">\([0,1]\)</span> are convergents of the expansion of <span class="math inline">\(0.99\)</span> and written as a fraction will give us the approximations <span class="math inline">\(0\)</span> and <span class="math inline">\(0+\frac{1}{1} = 1\)</span>.</p>
+</div>
+</div>
+<p>Using <a href="#thm-shor-post-process-frac" class="quarto-xref">Theorem&nbsp;<span>9.4</span></a> (with <span class="math inline">\(\varphi:= \frac{c}{2^n}\)</span> and <span class="math inline">\(q:=2^n\)</span>) we can find <span class="math inline">\(\frac{d}{r}\)</span> and from this <span class="math inline">\(r\)</span> which is the period of our function using the following steps:</p>
+<p>For each convergent <span class="math inline">\(\gamma\)</span> of <span class="math inline">\(\varphi\)</span> do the following:</p>
+<ol type="1">
+<li>Compute <span class="math inline">\(\gamma\)</span> as fraction <span class="math inline">\(\frac{d}{r}\)</span>.</li>
+<li>Stop if <span class="math inline">\(r \leq 2^n\)</span> and <span class="math inline">\(\varphi\)</span> is <span class="math inline">\(\frac{1}{2^{n+1}}\)</span>-close to <span class="math inline">\(\frac{c}{2^n}\)</span> and return <span class="math inline">\(r\)</span>.</li>
+</ol>
+<p>Note: It can happen, that the resulting fraction does not have the right <span class="math inline">\(r\)</span> in the denominator, because <span class="math inline">\(\frac{d}{r}\)</span> was simplified (if numerator and denominator shared a common factor). But the probability of this happening is sufficiently small and already included in the probability in <a href="#thm-shor-post-process" class="quarto-xref">Theorem&nbsp;<span>9.3</span></a>.</p>
+<p>This completes the postprocessing of Shor’s algorithm.</p>
+</section>
+<section id="constructing-the-dft" class="level2" data-number="9.5">
+<h2 data-number="9.5" class="anchored" data-anchor-id="constructing-the-dft"><span class="header-section-number">9.5</span> Constructing the DFT</h2>
+<p>So far we have described everything necessary for Shor’s algorithm, but only described the matrix representation of the <span class="math inline">\(\operatorname{DFT}_M\)</span>. We will now take a closer look into implementing the <span class="math inline">\(\operatorname{DFT}_M\)</span> as a quantum circuit. Since we only use the <span class="math inline">\(\operatorname{DFT}_M\)</span> for Shor’s algorithm so far, we will only look at <span class="math inline">\(M=2^n\)</span>, which is the <span class="math inline">\(\operatorname{DFT}\)</span> applied on <span class="math inline">\(n\)</span> qubits.</p>
+<p>To start the circuit, we recall the definition of the <span class="math inline">\(\operatorname{DFT}_{2^n}\)</span> from <a href="#def-shor-dft" class="quarto-xref">Definition&nbsp;<span>9.1</span></a>: <span class="math inline">\(\operatorname{DFT}_{2^n} := \frac{1}{\sqrt{{2^n}}} (\omega^{kl})_{kl}\)</span> with <span class="math inline">\(\omega:= e^{2\pi i / 2^n}\)</span>. To apply the <span class="math inline">\(\operatorname{DFT}_{2^n}\)</span> to a quantum state <span class="math inline">\(\ket{j}\)</span> we calculate <span class="math display">\[
+\operatorname{DFT}_{2^n}\ket{j} = \frac{1}{\sqrt{{2^n}}} \sum_k e^{2\pi i j k 2^{-n}} \ket{k}
+\]</span> We can rewrite this as follows: <span class="math display">\[
+\begin{aligned}
+\operatorname{DFT}_{2^n}\ket{j} =&amp; \frac{1}{\sqrt{{2^n}}} \sum_k e^{2\pi i j k 2^{-n}} \ket{k}\\
+=&amp; \frac{1}{\sqrt{{2^n}}} \sum_{k_1} \dots \sum_{k_n} e^{2\pi i j (\sum_l k_l 2^{-l})} \ket{k_1 \dots k_n}\\
+=&amp; \frac{1}{\sqrt{{2^n}}} \sum_{k_1} \dots \sum_{k_n} \bigotimes^n_{l=1} e^{2\pi i j (k_l 2^{-l})} \ket{k_l}\\
+=&amp; \frac{1}{\sqrt{{2^n}}} \bigotimes_{l=1}^n \sum_{k_l} e^{2\pi i j (k_l 2^{-l})} \ket{k_l}\\
+=&amp; \frac{1}{\sqrt{{2^n}}} \bigotimes_{l=1}^n (\ket{0} +  e^{2\pi i j 2^{-l}} \ket{1})\\
+=&amp; \frac{1}{\sqrt{{2^n}}} \bigotimes_{l=1}^n (\ket{0} +  e^{2\pi i 0.j_{n-(l-1)} \dots j_{n}} \ket{1})\\
+=&amp; \bigotimes_{l=1}^n \frac{1}{\sqrt{2}}(\ket{0} +  e^{2\pi i 0.j_{n-(l-1)} \dots j_{n}} \ket{1})
+\end{aligned}
+\]</span> The expression <span class="math inline">\(0.j\)</span> expresses a binary fraction (e.g.&nbsp;<span class="math inline">\(0.101 = \frac{1}{2} + \frac{1}{8} = \frac{5}{8}\)</span>).</p>
+<p>With this we have shown, that we can write <span class="math inline">\(\operatorname{DFT}_{2^n}\ket{j}\)</span> as the following tensor product of quantum states</p>
+<p><span class="math display">\[
+\frac{1}{\sqrt{2}}(\ket{0} +  e^{2\pi i 0.j_n} \ket{1}) \otimes \frac{1}{\sqrt{2}}(\ket{0} +  e^{2\pi i 0.j_{n-1}j_n} \ket{1}) \otimes \dots \otimes \frac{1}{\sqrt{2}}(\ket{0} +  e^{2\pi i 0.j_1\dots j_n} \ket{1})
+\]</span></p>
+<p>The rest of this section will be updated after the next lecture.</p>
 
 
 </section>
diff --git a/_book/sitemap.xml b/_book/sitemap.xml
index b28a67efde6da1720e86528f9abf662789ad4e13..b6f92a7a03596e62115b75dbb7237763fe02897a 100644
--- a/_book/sitemap.xml
+++ b/_book/sitemap.xml
@@ -2,7 +2,7 @@
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
     <loc>https://qis.rwth-aachen.de/teaching/24ss/intro-quantum-computing/script/index.html</loc>
-    <lastmod>2024-05-31T13:16:17.782Z</lastmod>
+    <lastmod>2024-06-11T17:32:07.892Z</lastmod>
   </url>
   <url>
     <loc>https://qis.rwth-aachen.de/teaching/24ss/intro-quantum-computing/script/quantumBasics.html</loc>
@@ -18,11 +18,11 @@
   </url>
   <url>
     <loc>https://qis.rwth-aachen.de/teaching/24ss/intro-quantum-computing/script/quantumSystems.html</loc>
-    <lastmod>2024-05-31T17:19:26.978Z</lastmod>
+    <lastmod>2024-06-11T10:58:17.042Z</lastmod>
   </url>
   <url>
     <loc>https://qis.rwth-aachen.de/teaching/24ss/intro-quantum-computing/script/observingSystems.html</loc>
-    <lastmod>2024-05-31T17:18:58.860Z</lastmod>
+    <lastmod>2024-06-11T17:30:13.951Z</lastmod>
   </url>
   <url>
     <loc>https://qis.rwth-aachen.de/teaching/24ss/intro-quantum-computing/script/partialObserving.html</loc>
@@ -46,14 +46,14 @@
   </url>
   <url>
     <loc>https://qis.rwth-aachen.de/teaching/24ss/intro-quantum-computing/script/shorsAlgorithm.html</loc>
-    <lastmod>2024-06-01T09:32:38.929Z</lastmod>
+    <lastmod>2024-06-11T17:28:37.603Z</lastmod>
   </url>
   <url>
     <loc>https://qis.rwth-aachen.de/teaching/24ss/intro-quantum-computing/script/Introduction-to-Quantum-Computing.pdf</loc>
-    <lastmod>2024-06-01T09:33:36.308Z</lastmod>
+    <lastmod>2024-06-11T17:32:55.904Z</lastmod>
   </url>
   <url>
     <loc>https://qis.rwth-aachen.de/teaching/24ss/intro-quantum-computing/script/Introduction-to-Quantum-Computing.epub</loc>
-    <lastmod>2024-06-01T09:33:37.814Z</lastmod>
+    <lastmod>2024-06-11T17:32:57.519Z</lastmod>
   </url>
 </urlset>
diff --git a/_quarto.yml b/_quarto.yml
index b7faca1ead8b911b743fedd89059a186fdcf380b..c70b2277b3950340dc5a451d6dab9fece3576404 100644
--- a/_quarto.yml
+++ b/_quarto.yml
@@ -8,7 +8,7 @@ book:
     - name: Jannik Hellenkamp
     - name: Dominique Unruh
   downloads: [pdf, epub]
-  version: 0.1.2
+  version: 0.1.3
   search: true
   page-navigation: true
   site-url: https://qis.rwth-aachen.de/teaching/24ss/intro-quantum-computing/script/
diff --git a/index.qmd b/index.qmd
index 736859e22739adaeebd3f9a1cee7055e6c0d47c2..9958abc7f31d006905b9c2b424a2e417c6ab592b 100644
--- a/index.qmd
+++ b/index.qmd
@@ -12,6 +12,11 @@ These lecture notes are released under the CC BY-NC 4.0 license, which can be fo
 
 ## Changelog {.unnumbered}
 
+#### Version 0.1.3 (11.06.2024)
+- added/extended 9.4 + 9.5 (Post processing and Beginning of DFT circuit)
+- updated 9.3
+- added chapter 3 (Quantum systems)
+- error correction in chapter 9
 
 #### Version 0.1.2 (31.05.2024)
 - minor changes to chapter 2
diff --git a/observingSystems.qmd b/observingSystems.qmd
index b1e0c82389f6f8def1e2e356937aa4f6700641d9..afe207ee1b89210f9360b50057b5834e3561ca6e 100644
--- a/observingSystems.qmd
+++ b/observingSystems.qmd
@@ -1,5 +1,4 @@
 # Observing probabilistic and measuring quantum systems
-
 <!--
 So far we only talked about the description of a probabilistic and a quantum system. We now look into observing/measuring those systems. 
 
@@ -23,7 +22,7 @@ When observing a probabilistic system, the observation is just a passive process
 
 ## Example: Random 1-bit number
 
-We usa a the random 1-bit number example to the random 2-bit example from @sec-prob.
+We usa a the random 1-bit number example similar to the random 2-bit example from @sec-prob.
 We have a distribution $d_{\text{1-bit}} = \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \end{pmatrix}$ which represents the probability distribution of generating a 1-bit number with equal probability. We also have a process $A_{\text{flip}} = \begin{pmatrix} \frac{2}{3} &  \frac{1}{3} \\ \frac{1}{3} &  \frac{2}{3} \end{pmatrix}$ which flips the bit with a probability of $\frac{1}{3}$. 
 
 We look at two different cases: For the first case, we observe only the final distribution and for the second case we observe after the generation of the 1-bit number and we also observe the final distribution. 
@@ -34,11 +33,13 @@ From @sec-prob-apply we know that the final distribution $d$ is
 $$
 d = A_{\text{flip}} \cdot d_{\text{1-bit}} = \begin{pmatrix} \frac{2}{3} &  \frac{1}{3} \\ \frac{1}{3} &  \frac{2}{3} \end{pmatrix} \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \end{pmatrix} = \begin{pmatrix} \frac{1}{2} \\ \frac{1}{2} \end{pmatrix}
 $$
-We observe this distribution and will get outcome $0$ and the new distribution $d = e_0 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ with a probability of $d_0 = \frac{1}{2}$ and the outcome $1$ and the new distribution $d = e_1 = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ with a probability of $d_1 = \frac{1}{2}$.
+We observe this distribution and will get outcome $0$ and the new distribution $d = e_0 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ with a probability of $\Pr[0] = d_0 = \frac{1}{2}$ and the outcome $1$ and the new distribution $d = e_1 = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ with a probability of $\Pr[1] = d_1 = \frac{1}{2}$.
 
 ##### Observing after generation {.unnumbered}
 
-We now observe the system after the generation of the 1-bit number and also observe the final distribution
+We now observe the system after the generation of the 1-bit number and also observe the final distribution. After the generation, we will get outcome $0$ and the new distribution $d = e_0 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ with a probability of $\Pr[0] = d_0 = \frac{1}{2}$ and the outcome $1$ and the new distribution $d = e_1 = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ with a probability of $\Pr[1] = d_1 = \frac{1}{2}$. 
+
+We now apply in each case the matrix $A_\text{flip}$. This will give us the outcome $A_\text{flip} \cdot \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$
 
 :::
 
@@ -72,7 +73,18 @@ $$
 H\psi = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix} =  \begin{pmatrix} 1 \\ 0 \end{pmatrix}
 $$
 
-Measuring this state will get the outcome $0$ with probability $|\psi_0|^2 = 1$ and have the post measurement state $\begin{pmatrix} 1 \\ 0 \end{pmatrix}$.
+Measuring this state will get the outcome $0$ with probability $\Pr[0] = |\psi_0|^2 = 1$ and have the post measurement state $\begin{pmatrix} 1 \\ 0 \end{pmatrix}$.
+
+##### Measure the initial and the final state {.unnumbered}
+
+Measuring $\psi$ with no further unitary matrices applied can have the outcome $0$ or $1$. We will look at the final measurement for each case:
+
+
+The first measurement will have outcome $0$ with probability $\Pr[0] = |\psi_0|^2 = \frac{1}{2}$ and the post measurement state will be $\begin{pmatrix} 1 \\ 0 \end{pmatrix}$. $H$ applied to this post measurement state will be $H\begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix}$. When measuring this state, we will get the outcome $0$ with probability $\Pr[0] = |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2}$ and outcome $1$ with with probability $\Pr[1] = |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2}$.
+
+The outcome $1$ will appear at the initial state with probability $\Pr[1] = |\psi_1|^2 = \frac{1}{2}$ and the post measurement state will be $\begin{pmatrix} 0 \\ 1 \end{pmatrix}$. $H$ applied to this post measurement state will be $H\begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} \end{pmatrix}$. When measuring this state, we will get the outcome $0$ with probability $\Pr[0] = |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2}$ and outcome $1$ with with probability $\Pr[1] = |-\frac{1}{\sqrt{2}}|^2 = \frac{1}{2}$.
+
+So no independent of the outcome of the first measurement, at the second measurement the outcome $0$ and $1$ have a probability of $\frac{1}{2}$. This shows, that when measuring before applying $H$, we will receive different probabilities, then when measuring only at the end. This proves, that measurements can change the system.
 
 
 :::
diff --git a/quantumSystems.qmd b/quantumSystems.qmd
index 3d08c9ca5d7278abec8bace08b91e5040d06dfe4..9c7283ebf2bd7018aadb6831ee6b48cd01c75b7a 100644
--- a/quantumSystems.qmd
+++ b/quantumSystems.qmd
@@ -1,6 +1,5 @@
 # Quantum systems
 
-<!--
 With the basics for a probabilistic system defined, we now look into describing a quantum computer mathematically. In the following table you can see the analogy from the quantum world to the probabilistic world. 
 
 | Probabilistic world           | Quantum world              |
@@ -11,9 +10,9 @@ With the basics for a probabilistic system defined, we now look into describing
 | Stochastic matrix as process  | Unitary matrix as process  |
 
 ## Quantum states
-One of the most important element of the quantum world is a quantum state. A quantum state describes the state of a quantum system as a vector. Each entry of the vector represents a *classical* possibility (similar to the deterministic possibilities in a probability distribution). The entries of a quantum state called *amplitude*. In contrast to a probabilistic system, these entries can be negative and are also complex numbers. 
+One of the most important element of the quantum world is a quantum state. A quantum state describes the state of a quantum system as a vector. Each entry of the vector represents a *classical* possibility (similar to the deterministic possibilities in a probability distribution). The entries of a quantum state are called *amplitude*. In contrast to a probabilistic system, these entries can be negative and are also complex numbers. 
 
-These amplitudes correlate to the probability of the quantum state being in the corresponding classical probability. To calculate the probabilities from the amplitude, we can take the square of the absolute value of the amplitude.
+These amplitudes tell us the probability of the quantum state being in the corresponding classical possibility. To calculate the probabilities from the amplitude, we can take the square of the absolute value of the amplitude.
 
 This means, that for the classical possibility $x$ and a quantum state $\psi$ the probability for $x$ is $\Pr[x] = |\psi|^2$. To have valid probabilities, the sum of all probabilities need to sum up to $1$. From this we get the formal definition of a quantum state:
 
@@ -31,31 +30,32 @@ A quantum state is a vector $\psi \in \mathbb{C}^n$ with $\sqrt{\sum |\psi|^2} =
 ## Example: Some Quantum states
 The following vectors are valid quantum states with the classical possibilities $0$ and $1$:
 $$
-\ket{0} = \begin{pmatrix} 1 \\ 0 \end{pmatrix}\quad
-\ket{1} = \begin{pmatrix} 0 \\ 1 \end{pmatrix}\quad
-\ket{+} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix}\quad
-\ket{-} = \begin{pmatrix} \frac{1}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} \end{pmatrix}
+\ket{0} := \begin{pmatrix} 1 \\ 0 \end{pmatrix}\quad
+\ket{1} := \begin{pmatrix} 0 \\ 1 \end{pmatrix}\quad
+\ket{+} := \begin{pmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{pmatrix}\quad
+\ket{-} := \begin{pmatrix} \frac{1}{\sqrt{2}} \\ -\frac{1}{\sqrt{2}} \end{pmatrix}
 $$
 Note that the symbol $\ket{}$ is not yet introduced, so just understand it as some label at this point. The probabilities for each state can be calculated as follows:
 $$
 \begin{aligned}
-\ket{0}: \Pr[0] &= |1|^2 = 1 \quad &&\Pr[1] = |0|^2 = 0 \\
-\ket{1}: \Pr[0] &= |0|^2 = 0 \quad &&\Pr[1] = |1|^2 = 1 \\
-\ket{+}: \Pr[0] &= |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2} &&\Pr[1] = |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2} \\
-\ket{-}: \Pr[0] &= |\frac{1}{\sqrt{2}}|^2 = \frac{1}{2} &&\Pr[1] = |\frac{-1}{\sqrt{2}}|^2 = \frac{1}{2}
+\ket{0}:&& \Pr[0] &= |1|^2 = 1 \quad &&\Pr[1] = |0|^2 = 0 \\
+\ket{1}:&& \Pr[0] &= |0|^2 = 0 \quad &&\Pr[1] = |1|^2 = 1 \\
+\ket{+}:&& \Pr[0] &= \lvert\tfrac{1}{\sqrt{2}}\rvert^2 = \tfrac{1}{2} &&\Pr[1] = \lvert\tfrac{1}{\sqrt{2}}\rvert^2 = \tfrac{1}{2} \\
+\ket{-}:&& \Pr[0] &= \lvert\tfrac{1}{\sqrt{2}}\rvert^2 = \tfrac{1}{2} &&\Pr[1] = \lvert\tfrac{-1}{\sqrt{2}}\rvert^2 = \tfrac{1}{2}
 \end{aligned}
 $$
 We can see here, that two different quantum states ($\ket{+}$ and $\ket{-}$) can have the same probabilities for all classical possibilities. 
 :::
 
 ## Unitary transformation
-We now have defined quantum states and need a way to describe  some processes, which we want to apply on the quantum states. In the probabilistic world, we have stochastic matrices for this, but unfortunately we can not use these matrices on quantum states, since the output of applying these on a quantum state is not guaranteed to be a quantum state again. We therefore make a new addition to our quantum toolbox called a *unitary transformation*. 
+We now have defined quantum states and need a way to describe  some processes, which we want to apply on the quantum states. In the probabilistic world, we have stochastic matrices for this, but unfortunately we can not use these matrices on quantum states, since the output of applying these on a quantum state is not guaranteed to be a quantum state again. We therefore look for a different property of a matrix for which the outcome of applying that matrix is guaranteed to be a quantum state. We get this property with *unitary* matrices. 
+
 
 ::: {.callout-note appearance="minimal" icon=false}
 ::: {.definition #def-unitary-transformation}
 
 ## Unitary transformation
-Given a quantum state $\psi \in \mathbb{C}^n$ and a unitary matrix $U \in \mathbb{C}^{n\times n}$, the state after the transformation is $U\psi$.
+Given a quantum state $\psi \in \mathbb{C}^n$ and a unitary matrix $U \in \mathbb{C}^{n\times n}$, the state after the transformation is a quantum state $U\psi$.
 :::
 :::
 
@@ -67,7 +67,7 @@ A matrix $U \in \mathbb{C}^{n\times n}$ is called *unitary* iff $U^\dagger U = I
 :::
 :::
 
-A unitary transformation is by definition invertible, therefore we can undo all unitary transformations by applying $U^\dagger$. 
+A unitary matrix is by this lemma invertible, therefore we can undo all unitary transformations by applying $U^\dagger$. 
 
 ::: {.callout-tip icon=false}
 
@@ -85,4 +85,4 @@ X\ket{0} = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \cdot \begin{pmatrix} 1
 $$
 :::
 
--->
+
diff --git a/shorsAlgorithm.qmd b/shorsAlgorithm.qmd
index a1cbe2d7d727c3734027be0dfb5dc487f7b51bb2..8b412cc5e61448730c2df1aac4c03e9842ded445 100644
--- a/shorsAlgorithm.qmd
+++ b/shorsAlgorithm.qmd
@@ -13,11 +13,11 @@ The DFT is defined as follows:
 
 ## Discrete Fourier Transformation (DFT)
 
-The discrete Fourier transform (DFT) is a linear transformation on $\mathbb{C}^N$ represented by the matrix 
+The discrete Fourier transform (DFT) is a linear transformation on $\mathbb{C}^M$ represented by the matrix 
 $$
-\operatorname{DFT}_N = \frac{1}{\sqrt{N}} (\omega^{kl})_{kl} \in \mathbb{C}^{N\times N}
+\operatorname{DFT}_M = \frac{1}{\sqrt{M}} (\omega^{kl})_{kl} \in \mathbb{C}^{M\times M}
 $$
-with $\omega = e^{2i\pi/N}$, which is the $N$-th root of unity. 
+with $\omega = e^{2i\pi/M}$, which is the $M$-th root of unity. 
 :::
 :::
 
@@ -31,10 +31,10 @@ This transformation is best imagined as a process, which takes a periodic vector
 Here are some properties of the DFT which can be used without further proof. 
 
 1. The DFT is unitary.
-2. $\omega^t = \omega^{t\mod N}$ for all $t \in \mathbb{Z}$.
-3. Given a quantum state $\psi \in \mathbb{C}^N$ which is $r$-periodic and where $r\mid N$, $\operatorname{DFT}_N \psi$ will compute a quantum state $\phi \in \mathbb{C}^N$, which has non-zero values on the multiples of $\frac{N}{r}$. Note that $\frac{N}{r}$ intuitively represents the frequency of $\psi$. This means, that 
+2. $\omega^t = \omega^{t\mod M}$ for all $t \in \mathbb{Z}$.
+3. Given a quantum state $\psi \in \mathbb{C}^M$ which is $r$-periodic and where $r\mid M$, $\operatorname{DFT}_M \psi$ will compute a quantum state $\phi \in \mathbb{C}^M$, which has non-zero values on the multiples of $\frac{M}{r}$. Note that $\frac{M}{r}$ intuitively represents the frequency of $\psi$. This means, that 
 $$
-|\phi_i| = \begin{cases} \frac{1}{\sqrt{t}}, & \text{if}\ \frac{N}{t}\mid i \\ 0, & \text{otherwise} \end{cases}
+|\phi_i| = \begin{cases} \frac{1}{\sqrt{r}}, & \text{if}\ \frac{M}{r}\mid i \\ 0, & \text{otherwise} \end{cases}
 $$
 :::
 :::
@@ -72,7 +72,7 @@ To start the reduction, we need a special case of the period finding problem cal
 
 ## Order finding problem
 
-For known $a$ and $N$ which are relatively prime, find the period $r$ of $f(i) = a^i \bmod n$. We call $r$ the order of $a$ written $r = \text{ ord } a$. (This is similar to finding the smallest $i > 0$ with $f(i) = 1$).
+For known $a$ and $N$ which are relatively prime, find the period $r$ of $f(i) = a^i \bmod N$. We call $r$ the order of $a$ written $r = \text{ ord } a$. (This is similar to finding the smallest $i > 0$ with $f(i) = 1$).
 :::
 :::
 
@@ -80,7 +80,7 @@ Since the order finding problem is just the period finding problem for a specifi
 
 We have a integer $N$ as an input for the factoring problem.
 
-1. Pick an $a \in \{1,...,N-1\}$ with $a$ relatively prime to $n$.
+1. Pick an $a \in \{1,\dots,N-1\}$ with $a$ relatively prime to $N$.
 2. Compute the order of $a$, so that $r = \text{ ord } a$ (using the solver for the order finding problem).
 3. If the order $r$ is odd, we abort.
 4. Calculate $x:= a^{\frac{r}{2}}+1 \bmod N$ and $y:= a^{\frac{r}{2}}-1 \bmod N$.
@@ -105,7 +105,9 @@ All in all this reduction shows, that if we have an oracle which can solve the p
 
 ## The quantum algorithm for period finding {#sec-shor-algo}
 
-We now look into an quantum algorithm that solves the period finding problem within reasonable runtime. The quantum circuit for Shor's algorithm requires a $f:\{0,1\}^n\rightarrow\{0,1\}^m$ which is $r$-periodic and is show in this figure:
+We now look into an quantum algorithm that solves the period finding problem within reasonable runtime. The quantum circuit for Shor's algorithm requires a $f:\mathbb{Z}\rightarrow X$ which is $r$-periodic. We choose a number $m$ which needs to be big enough to encode the values of $X$ and choose a number $n$ under the condition of $n\geq 2 \log_2(r)$ for the post processing to work. Note that when using this algorithm for factoring, we choose $n$ to be $n:=2\lvert N \rvert$, since $r \leq N$. $\lvert N\rvert$ denotes the number of bits needed to encode $N$ here.
+
+The quantum algorithm for period finding is shown in this figure:
 
 ![Shor's algorithm (quantum part)](shor){width=100%}
 
@@ -113,15 +115,13 @@ The algorithm works as follows:
 
 1. We start with a $\ket{0}$ entry on every wire.
 2. We bring the top wire into the superposition over all entries. The quantum state is then $2^\frac{-n}{2}\sum_x \ket{x} \otimes \ket{0^m}$.
-3. We apply $U_f$, which is the unitary of $f:\{0,1\}^n\rightarrow\{0,1\}^m$. This calculates the superposition over all possible values $f(x)$ on the bottom wire. The resulting quantum state is $\frac{-n}{2}\sum_x \ket{x,f(x)}$. 
+3. We apply $U_f$, which is the unitary of $f:\{0,1\}^n\rightarrow\{0,1\}^m$. This calculates the superposition over all possible values $f(x)$ on the bottom wire. The resulting quantum state is $2^\frac{-n}{2}\sum_x \ket{x,f(x)}$. 
 4. To understand the algorithm better, we measure the bottom wire at this point. This will give us one random value $f(x_0)$ for some $x_0$. The top wire will then contain a superposition over all values $x$ where $f(x) = f(x_0)$. Since $f$ is know to be $r$-periodic, we know, that $f(x) = f(x_0)$ iff $x \equiv x_0 \bmod r$. This means, that on the resulting quantum state on the top wire is periodic and can be written as $\frac{1}{\sqrt{2^\frac{n}{r}}} \sum_{x\equiv x_0 \bmod r} \ket{x} \otimes \ket{f(x_0)}$.
 5. We apply the Discrete Fourier Transform on the top wire. This will "analyze" the top wire for the period and output a vector with entries at multiples of $\frac{2^n}{r}$ as seen in @thm-dft-properties. For simplicity we assume, that $r \mid 2^n$ holds.
 6. We measure the top wire and get one random multiple of $\frac{2^n}{r}$, which we can denote as $a\cdot\frac{2^n}{r}$
 
 
-Since we get a multiple of $\frac{2^n}{r}$ on each run, we can simply run the algorithm multiple times to get different multiples and then compute $\frac{2^n}{r}$ by taking the gcd of those multiples. From that we compute $r$.
-
-Unfortunately this only works because we assumed $r \mid 2^n$. Since this does usually not hold, we only get approximate multiples of $\frac{2^n}{r}$ (which is not even an integer) and thus post processing is a bit more complex. 
+Since we get a multiple of $\frac{2^n}{r}$ on each run, we can simply run the algorithm multiple times to get different multiples and then compute $\frac{2^n}{r}$ by taking the gcd of those multiples. From that we compute $r$. Unfortunately this only works because we assumed $r \mid 2^n$. Since this does usually not hold, we only get approximate multiples of $\frac{2^n}{r}$ (which is not even an integer) and thus post processing is a bit more complex. 
 
 ## Post processing
 
@@ -131,27 +131,109 @@ So far we have seen the DFT to analyze the period of a quantum state, we have se
 ::: {.therorem #thm-shor-post-process}
 
 ## 
-If $\{0,1\}^n \rightarrow \{0,1\}^n$ is $r$-periodic with probability $\Omega(1/\log\log r)$ the following holds:
+Iff $f: \mathbb{Z} \rightarrow X$ is $r$-periodic, the following holds with probability $\Omega(1/\log\log r)$:
 $$
 \frac{-r}{2} \leq rc\bmod 2^n \leq \frac{r}{2}
 $$
-where $c$ is the output of the second measurement of the quantum circuit described in @sec-shor-algo. 
+where $c$ is the output of the second measurement of the quantum circuit described in @sec-shor-algo and $n$ is the number of qubits on the upper wire of the quantum circuit. 
 :::
 :::
 
-We assume that the theorem holds for our outcome of the second measurement (If that is not the case, our result will be wrong and we can just run the quantum algorithm again to get a different outcome):
+We assume that the theorem holds for our outcome $c$ of the second measurement (if that is not the case, our result will be wrong and we can just run the quantum algorithm again to get a different outcome):
 
-Then exists a $d$ such that:
+Then exists an integer $d$ such that:
 $$
 \begin{aligned}
 &\lvert rc - d2^n\rvert \leq \frac{r}{2} \\
-\Leftrightarrow&\lvert \frac{c}{2^n} - \frac{d}{r}\rvert \leq \frac{1}{2^{n+1}}
+\iff&\lvert \frac{c}{2^n} - \frac{d}{r}\rvert \leq \frac{1}{2^{n+1}} && |\text{ division by } r\cdot 2^n
+\end{aligned}
+$$
+The fraction $\frac{c}{2^n}$ is known, so the goal is to find a fraction $\frac{d}{r}$ that is $\frac{1}{2^{n+1}}$-close to $\frac{c}{2^n}$. 
+
+Since $n$ is the number of qubits used in the quantum circuit and was chosen, such that $n \geq 2\log_2(r)$ and thus $2^{n} \geq 2 r^2$ holds and from this we know that $\frac{1}{2^{n+1}} \leq \frac{1}{2r^2}$ holds as well. 
+
+So if @thm-shor-post-process holds, we now $\lvert \frac{c}{2^n} - \frac{d}{r} \rvert \leq \frac{1}{2r^2}$ also holds. Our task is now rewritten to find $\frac{d}{r}$ under this condition. For this we use another theorem:
+
+::: {.callout-note appearance="minimal" icon=false}
+::: {.theorem #thm-shor-post-process-frac}
+
+For a given real number $\varphi \geq 0$ and integer $q > 0$ there is at most one fraction $\frac{d}{r}$ with $r \leq q$ and $\lvert \varphi - \frac{d}{r} \rvert \leq \frac{1}{2q}$. In this case, this $\frac{d}{r}$ is a convergent of the continued fraction expansion of $\varphi$.
+
+:::
+:::
+This theorem uses the convergent of a continued fraction expansion. A continued fraction expansion of a number $t$ is the number rewritten as a fraction in the form 
+
+$$
+t = a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{a_3 + \dots}}}
+$$
+
+where $a_i$ always has to be the biggest possible integer.
+We call $[a_0,a_1,a_2,a_3,\dots]$ the continued expansion of $t$.
+The expansion is finite iff t is rational.
+For a given continued expansion, a prefix $[a_0,\dots,a_i]$ is called a convergent. Writing this convergent as a normal fraction will give us an approximation of the number $t$. 
+
+::: {.callout-tip icon=false}
+
+## Example: continued expansion of a fraction
+
+The number $2.3$ can be written as 
+$$
+2.3 = 2 + \frac{1}{3 + \frac{1}{3 + 0}}
+$$
+and the continued fraction expansion of $2.3$ is $[2,3,3]$. The expansions $[2]$ and $[2,3]$ are convergents of the expansion of $2.3$ and written as a fraction will give us the approximations $2$ and $2+\frac{1}{3} = 2.\bar{3}$.
+
+The number $0.99$ can be written as 
+
+$$
+0.99 = 0 + \frac{1}{1 + \frac{1}{99 + 0}}
+$$
+and the continued fraction expansion of $0.99$ is $[0,1,99]$.
+The expansions $[0]$ and $[0,1]$ are convergents of the expansion of $0.99$ and written as a fraction will give us the approximations $0$ and $0+\frac{1}{1} = 1$.
+
+:::
+
+Using @thm-shor-post-process-frac (with $\varphi:= \frac{c}{2^n}$ and $q:=2^n$) we can find $\frac{d}{r}$ and from this $r$ which is the period of our function using the following steps:
+
+For each convergent $\gamma$ of $\varphi$ do the following:
+
+1. Compute $\gamma$ as fraction $\frac{d}{r}$.
+2. Stop if $r \leq 2^n$ and $\varphi$ is $\frac{1}{2^{n+1}}$-close to $\frac{c}{2^n}$ and return $r$.
+
+Note: It can happen, that the resulting fraction does not have the right $r$ in the denominator, because $\frac{d}{r}$ was simplified (if numerator and denominator shared a common factor). But the probability of this happening is sufficiently small and already included in the probability in @thm-shor-post-process.
+
+
+This completes the postprocessing of Shor's algorithm.
+
+
+## Constructing the DFT
+
+So far we have described everything necessary for Shor's algorithm, but only described the matrix representation of the $\operatorname{DFT}_M$. We will now take a closer look into implementing the $\operatorname{DFT}_M$ as a quantum circuit. Since we only use the $\operatorname{DFT}_M$ for Shor's algorithm so far, we will only look at $M=2^n$, which is the $\operatorname{DFT}$ applied on $n$ qubits. 
+
+To start the circuit, we recall the definition of the $\operatorname{DFT}_{2^n}$ from @def-shor-dft: $\operatorname{DFT}_{2^n} := \frac{1}{\sqrt{{2^n}}} (\omega^{kl})_{kl}$ with $\omega:= e^{2\pi i / 2^n}$. To apply the $\operatorname{DFT}_{2^n}$ to a quantum state $\ket{j}$ we calculate
+$$
+\operatorname{DFT}_{2^n}\ket{j} = \frac{1}{\sqrt{{2^n}}} \sum_k e^{2\pi i j k 2^{-n}} \ket{k}
+$$
+We can rewrite this as follows:
+$$
+\begin{aligned}
+\operatorname{DFT}_{2^n}\ket{j} =& \frac{1}{\sqrt{{2^n}}} \sum_k e^{2\pi i j k 2^{-n}} \ket{k}\\
+=& \frac{1}{\sqrt{{2^n}}} \sum_{k_1} \dots \sum_{k_n} e^{2\pi i j (\sum_l k_l 2^{-l})} \ket{k_1 \dots k_n}\\
+=& \frac{1}{\sqrt{{2^n}}} \sum_{k_1} \dots \sum_{k_n} \bigotimes^n_{l=1} e^{2\pi i j (k_l 2^{-l})} \ket{k_l}\\
+=& \frac{1}{\sqrt{{2^n}}} \bigotimes_{l=1}^n \sum_{k_l} e^{2\pi i j (k_l 2^{-l})} \ket{k_l}\\
+=& \frac{1}{\sqrt{{2^n}}} \bigotimes_{l=1}^n (\ket{0} +  e^{2\pi i j 2^{-l}} \ket{1})\\
+=& \frac{1}{\sqrt{{2^n}}} \bigotimes_{l=1}^n (\ket{0} +  e^{2\pi i 0.j_{n-(l-1)} \dots j_{n}} \ket{1})\\
+=& \bigotimes_{l=1}^n \frac{1}{\sqrt{2}}(\ket{0} +  e^{2\pi i 0.j_{n-(l-1)} \dots j_{n}} \ket{1})
 \end{aligned}
 $$
-The fraction $\frac{c}{2^n}$ is known, so the goal is to find a fraction $\frac{d}{r}$ that is $\frac{1}{2^{n+1}}$ close to $\frac{c}{2^n}$. 
+The expression $0.j$ expresses a binary fraction (e.g. $0.101 = \frac{1}{2} + \frac{1}{8} = \frac{5}{8}$). 
+
+With this we have shown, that we can write $\operatorname{DFT}_{2^n}\ket{j}$ as the following tensor product of quantum states
 
-The rest of postprocessing will be updated after the next lecture. 
+$$
+\frac{1}{\sqrt{2}}(\ket{0} +  e^{2\pi i 0.j_n} \ket{1}) \otimes \frac{1}{\sqrt{2}}(\ket{0} +  e^{2\pi i 0.j_{n-1}j_n} \ket{1}) \otimes \dots \otimes \frac{1}{\sqrt{2}}(\ket{0} +  e^{2\pi i 0.j_1\dots j_n} \ket{1}) 
+$$
 
+The rest of this section will be updated after the next lecture.