Skip to content

Commit 16e25aa

Browse files
Merge pull request #486 from rawkintrevo/quantum-computing-primer
Add QC Primer
2 parents 456860e + 1dcc8e4 commit 16e25aa

File tree

15 files changed

+1417
-3
lines changed

15 files changed

+1417
-3
lines changed

website/Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ source "https://rubygems.org"
2929
# Happy Jekylling!
3030

3131
gem "jekyll", "4.3.2"
32+
gem 'jekyll-latex'
3233

3334
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
3435
# uncomment the line below. To upgrade, run `bundle update github-pages`.

website/_config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ baseurl: ""
4141
markdown: kramdown
4242
plugins:
4343
- jekyll-feed
44+
- jekyll-latex
4445

4546
# Exclude from processing.
4647
# The following items will not be processed, by default. Create a custom list

website/_includes/head.html

+20-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,24 @@
2323
<link rel="canonical" href="{{ page.url | replace:'index.html','' | absolute_url }}">
2424
<link rel="alternate" type="application/rss+xml" title="{{ site.title | escape }}" href="{{'/feed.xml' | relative_url }}">
2525

26-
26+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML">
27+
MathJax.Hub.Config({
28+
"HTML-CSS": {
29+
availableFonts: ["TeX"],
30+
},
31+
tex2jax: {
32+
inlineMath: [['$','$'],["\\(","\\)"]]},
33+
displayMath: [ ['$$','$$'], ['\[','\]'] ],
34+
TeX: {
35+
extensions: ["AMSmath.js", "AMSsymbols.js", "color.js"],
36+
equationNumbers: {
37+
autoNumber: "AMS"
38+
}
39+
},
40+
showProcessingMessages: false,
41+
messageStyle: "none",
42+
imageFont: null,
43+
"AssistiveMML": { disabled: true }
44+
});
45+
</script>
2746
</head>

website/_includes/navbar.html

+12
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@
3131
</div>
3232
</li>
3333

34+
<li class="nav-item dropdown">
35+
<a class="nav-link dropdown-toggle"
36+
href="" id="navbarDropdownMenuLink-qumat"
37+
data-toggle="dropdown"
38+
aria-haspopup="true"
39+
aria-expanded="false">Qumat</a>
40+
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
41+
<a class="dropdown-item"
42+
href="/quantum-computing-primer">Quantum Computing Primer</a>
43+
<!-- TODO: Add More QuMat stuff here or refactor the whole thing-->
44+
</div>
45+
</li>
3446
<!-- Documentation -->
3547
<li class="nav-item dropdown">
3648
<a class="nav-link dropdown-toggle"

website/general/books-tutorials-and-talks.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
layout: default
33
title: Books Tutorials and Talks
4-
5-
64
---
75
# Intro
86

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
layout: page
3+
title: Introduction to Quantum Computing
4+
---
5+
6+
# 1. Introduction to Quantum Computing
7+
8+
## 1.1 What is Quantum Computing?
9+
10+
Quantum computing is a revolutionary approach to computation that leverages the principles of quantum mechanics to process information in ways that classical computers cannot. Unlike classical computers, which use bits as the smallest unit of information (representing either a 0 or a 1), quantum computers use **qubits** (quantum bits). Qubits can exist in a **superposition** of states, meaning they can be both 0 and 1 simultaneously. This property allows quantum computers to perform many calculations at once, potentially solving certain problems much faster than classical computers.
11+
12+
### Key Concepts:
13+
- **Qubits**: The fundamental unit of quantum information, which can be in a superposition of states.
14+
- **Superposition**: A quantum phenomenon where a qubit can be in multiple states at once.
15+
- **Entanglement**: A unique quantum property where qubits become interconnected, such that the state of one qubit is directly related to the state of another, even if they are separated by large distances.
16+
- **Quantum Gates**: Operations that manipulate qubits, analogous to classical logic gates but with the ability to exploit quantum phenomena.
17+
18+
### Why Quantum Computing Matters:
19+
Quantum computing has the potential to revolutionize fields such as cryptography, optimization, and material science. For example, quantum algorithms like **Shor's algorithm** can factorize large numbers exponentially faster than classical algorithms, posing a threat to current cryptographic systems. Similarly, **Grover's algorithm** can search unsorted databases quadratically faster than classical methods.
20+
21+
---
22+
23+
## 1.2 Why Quantum Computing?
24+
25+
Quantum computing is not just a theoretical concept; it has practical implications that could transform industries. Here are some reasons why quantum computing is gaining attention:
26+
27+
### 1. **Exponential Speedup for Certain Problems**:
28+
- Quantum computers can solve certain problems exponentially faster than classical computers. For example, simulating quantum systems (e.g., molecules for drug discovery) is infeasible for classical computers but manageable for quantum computers.
29+
30+
### 2. **Breaking Classical Cryptography**:
31+
- Quantum algorithms like Shor's algorithm can break widely used cryptographic schemes, such as RSA, by efficiently factorizing large numbers. This has spurred interest in **quantum-resistant cryptography**.
32+
33+
### 3. **Optimization**:
34+
- Quantum computers can explore multiple solutions simultaneously, making them ideal for optimization problems in logistics, finance, and machine learning.
35+
36+
### 4. **Quantum Simulation**:
37+
- Quantum computers can simulate quantum systems, enabling breakthroughs in chemistry, material science, and physics.
38+
39+
### 5. **Machine Learning**:
40+
- Quantum machine learning algorithms promise to accelerate training and improve model performance for specific tasks.
41+
42+
---
43+
44+
## 1.3 Quantum Computing vs. Classical Computing
45+
46+
| Feature | Classical Computing | Quantum Computing |
47+
|------------------------|-----------------------------------|----------------------------------|
48+
| **Basic Unit** | Bit (0 or 1) | Qubit (superposition of 0 and 1)|
49+
| **State Representation**| Deterministic | Probabilistic |
50+
| **Operations** | Logic gates (AND, OR, NOT, etc.) | Quantum gates (X, Y, Z, H, etc.)|
51+
| **Parallelism** | Limited by CPU cores | Exponential parallelism via superposition |
52+
| **Error Correction** | Well-established | Still an active area of research|
53+
54+
---
55+
56+
## 1.4 Getting Started with Quantum Computing Using `qumat`
57+
58+
To begin your journey into quantum computing, you'll use the `qumat` library, which provides a simple and unified interface for working with quantum circuits across different backends (e.g., Amazon Braket, Cirq, Qiskit). Here's a quick example to get you started:
59+
60+
```python
61+
from qumat import QuMat
62+
63+
# Initialize a quantum circuit with 1 qubit
64+
backend_config = {'backend_name': 'qiskit', 'backend_options': {'simulator_type': 'qasm_simulator', 'shots': 1000}}
65+
qc = QuMat(backend_config)
66+
qc.create_empty_circuit(1)
67+
68+
# Apply a Hadamard gate to create a superposition
69+
qc.apply_hadamard_gate(0)
70+
71+
# Execute the circuit and measure the result
72+
result = qc.execute_circuit()
73+
print(result)
74+
```
75+
76+
In this example, we:
77+
78+
* Created a quantum circuit with 1 qubit.
79+
* Applied a Hadamard gate to put the qubit into a superposition state.
80+
* Measured the qubit to observe the probabilistic outcome.
81+
82+
This is just the beginning! In the next sections, you'll dive deeper into quantum gates, circuits, and algorithms using qumat.
83+
84+
---
85+
86+
## 1.5 Summary
87+
88+
* Quantum computing leverages quantum mechanics to process information in fundamentally new ways.
89+
* Qubits, superposition, and entanglement are the building blocks of quantum computing.
90+
* Quantum computing has the potential to solve problems that are intractable for classical computers.
91+
* The `qumat` library provides a simple way to explore quantum computing concepts and algorithms.
92+
93+
In the next section, we'll set up your environment and explore the basics of quantum circuits using `qumat`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
layout: page
3+
title: Quantum Bits (Qubits)
4+
---
5+
6+
# 3. Quantum Bits (Qubits)
7+
8+
## 3.1 Classical Bits vs. Qubits
9+
10+
In classical computing, the fundamental unit of information is the **bit**, which can exist in one of two states: `0` or `1`. Quantum computing, however, introduces the concept of a **qubit**, which can exist in a **superposition** of both states simultaneously. This means a qubit can be in a state that is a combination of `0` and `1`, represented as:
11+
12+
$$|\psi\rangle = \alpha|0\rangle + \beta|1\rangle$$
13+
14+
where \(\alpha\) and \(\beta\) are complex numbers representing the probability amplitudes of the qubit being in the \(|0\rangle\) and \(|1\rangle\) states, respectively. The probabilities of measuring the qubit in either state are given by \(|\alpha|^2\) and \(|\beta|^2\), and they must satisfy the normalization condition:
15+
16+
$$|\alpha|^2 + |\beta|^2 = 1$$
17+
18+
## 3.2 Representing Qubits
19+
20+
Qubits can be visualized using the **Bloch sphere**, a geometric representation of the quantum state of a single qubit. The Bloch sphere is a unit sphere where the north and south poles represent the \(|0\rangle\) and \(|1\rangle\) states, respectively. Any point on the surface of the sphere represents a valid quantum state of the qubit.
21+
22+
The state of a qubit can also be described using a **state vector** in a two-dimensional complex vector space. For example, the state \(|0\rangle\) is represented as:
23+
24+
$$|0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$$
25+
26+
and the state \(|1\rangle\) is represented as:
27+
28+
$$|1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$$
29+
30+
## 3.3 Creating Qubits with `qumat`
31+
32+
In `qumat`, qubits are created by initializing a quantum circuit with a specified number of qubits. The `create_empty_circuit` function is used to create a circuit with a given number of qubits. Here's an example of creating a quantum circuit with a single qubit:
33+
34+
```python
35+
from qumat import QuMat
36+
37+
# Initialize the quantum circuit with a single qubit
38+
backend_config = {
39+
'backend_name': 'qiskit', # Choose the backend (e.g., 'qiskit', 'cirq', 'amazon_braket')
40+
'backend_options': {
41+
'simulator_type': 'qasm_simulator', # Type of simulator
42+
'shots': 1000 # Number of shots (measurements)
43+
}
44+
}
45+
46+
qc = QuMat(backend_config)
47+
qc.create_empty_circuit(1) # Create a circuit with 1 qubit
48+
```
49+
50+
In this example, we initialize a quantum circuit with one qubit using the qiskit backend. The create_empty_circuit function sets up the circuit, and we can now apply quantum gates to manipulate the qubit.
51+
52+
### Example: Applying a Hadamard Gate
53+
54+
The Hadamard gate ((H)) is a fundamental quantum gate that puts a qubit into a superposition state. Applying the Hadamard gate to a qubit initially in the (|0\rangle) state results in the state:
55+
56+
$$H|0\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$
57+
58+
Here's how you can apply a Hadamard gate to a qubit using qumat:
59+
60+
```python
61+
# Apply the Hadamard gate to the first qubit (index 0)
62+
qc.apply_hadamard_gate(0)
63+
64+
# Execute the circuit and get the measurement results
65+
result = qc.execute_circuit()
66+
print(result)
67+
```
68+
69+
In this example, the Hadamard gate is applied to the qubit at index 0, and the circuit is executed to obtain the measurement results. The output will show the probabilities of measuring the qubit in the (|0\rangle) and (|1\rangle) states.
70+
71+
### Visualizing the Circuit
72+
73+
You can also visualize the quantum circuit using the draw method:
74+
75+
```python
76+
# Draw the circuit
77+
qc.draw()
78+
```
79+
80+
This will print a textual representation of the circuit, showing the sequence of gates applied to the qubits.
81+
82+
---
83+
84+
This section introduced the concept of qubits, their representation, and how to create and manipulate them using the qumat library. In the next section, we will explore quantum gates in more detail and learn how to apply them to perform quantum operations.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
layout: page
3+
title: Quantum Gates
4+
---
5+
6+
# 4. Quantum Gates
7+
8+
Quantum gates are the building blocks of quantum circuits, analogous to classical logic gates in classical computing. They manipulate qubits, enabling the creation of complex quantum algorithms. In this section, we will explore the different types of quantum gates and how to apply them using the `qumat` library.
9+
10+
## 4.1 Single-Qubit Gates
11+
12+
Single-qubit gates operate on a single qubit, changing its state. Some of the most common single-qubit gates include:
13+
14+
- **Pauli-X Gate**: Similar to the classical NOT gate, it flips the state of a qubit.
15+
- **Pauli-Y Gate**: Introduces a phase flip and a bit flip.
16+
- **Pauli-Z Gate**: Introduces a phase flip without changing the bit value.
17+
- **Hadamard Gate**: Creates superposition by transforming the basis states.
18+
- **Rotation Gates (Rx, Ry, Rz)**: Rotate the qubit state around the X, Y, or Z axis of the Bloch sphere.
19+
20+
### Example: Applying a Hadamard Gate
21+
```python
22+
from qumat import QuMat
23+
24+
# Initialize the quantum circuit with 1 qubit
25+
backend_config = {'backend_name': 'qiskit', 'backend_options': {'simulator_type': 'qasm_simulator', 'shots': 1000}}
26+
qc = QuMat(backend_config)
27+
qc.create_empty_circuit(1)
28+
29+
# Apply the Hadamard gate to the first qubit
30+
qc.apply_hadamard_gate(0)
31+
32+
# Execute the circuit and print the results
33+
result = qc.execute_circuit()
34+
print(result)
35+
```
36+
37+
## 4.2 Multi-Qubit Gates
38+
39+
Multi-qubit gates operate on two or more qubits, enabling entanglement and more complex quantum operations. Some of the most common multi-qubit gates include:
40+
41+
- **CNOT Gate (Controlled-NOT)**: Flips the target qubit if the control qubit is in the state |1⟩.
42+
- **Toffoli Gate (CCNOT)**: A controlled-controlled-NOT gate that flips the target qubit if both control qubits are in the state |1⟩.
43+
- **SWAP Gate**: Exchanges the states of two qubits.
44+
45+
### Example: Applying a CNOT Gate
46+
```python
47+
# Initialize the quantum circuit with 2 qubits
48+
qc.create_empty_circuit(2)
49+
50+
# Apply the Hadamard gate to the first qubit
51+
qc.apply_hadamard_gate(0)
52+
53+
# Apply the CNOT gate with qubit 0 as control and qubit 1 as target
54+
qc.apply_cnot_gate(0, 1)
55+
56+
# Execute the circuit and print the results
57+
result = qc.execute_circuit()
58+
print(result)
59+
```
60+
61+
## 4.3 Applying Gates with `qumat`
62+
63+
The `qumat` library provides a simple and consistent interface for applying quantum gates. Below are some examples of how to apply different gates using `qumat`.
64+
65+
### Example: Applying Rotation Gates
66+
```python
67+
# Initialize the quantum circuit with 1 qubit
68+
qc.create_empty_circuit(1)
69+
70+
# Apply an Rx gate with a rotation angle of π/2
71+
qc.apply_rx_gate(0, 3.14159 / 2)
72+
73+
# Apply an Ry gate with a rotation angle of π/4
74+
qc.apply_ry_gate(0, 3.14159 / 4)
75+
76+
# Apply an Rz gate with a rotation angle of π
77+
qc.apply_rz_gate(0, 3.14159)
78+
79+
# Execute the circuit and print the results
80+
result = qc.execute_circuit()
81+
print(result)
82+
```
83+
84+
### Example: Applying a Toffoli Gate
85+
```python
86+
# Initialize the quantum circuit with 3 qubits
87+
qc.create_empty_circuit(3)
88+
89+
# Apply the Hadamard gate to the first two qubits
90+
qc.apply_hadamard_gate(0)
91+
qc.apply_hadamard_gate(1)
92+
93+
# Apply the Toffoli gate with qubits 0 and 1 as controls and qubit 2 as target
94+
qc.apply_toffoli_gate(0, 1, 2)
95+
96+
# Execute the circuit and print the results
97+
result = qc.execute_circuit()
98+
print(result)
99+
```
100+
101+
### Example: Applying a SWAP Gate
102+
```python
103+
# Initialize the quantum circuit with 2 qubits
104+
qc.create_empty_circuit(2)
105+
106+
# Apply the Hadamard gate to the first qubit
107+
qc.apply_hadamard_gate(0)
108+
109+
# Apply the SWAP gate to exchange the states of qubits 0 and 1
110+
qc.apply_swap_gate(0, 1)
111+
112+
# Execute the circuit and print the results
113+
result = qc.execute_circuit()
114+
print(result)
115+
```
116+
117+
## 4.4 Visualizing Quantum Circuits
118+
119+
Visualizing quantum circuits can help in understanding the flow of quantum operations. The `qumat` library provides a simple way to draw circuits.
120+
121+
### Example: Drawing a Quantum Circuit
122+
```python
123+
# Initialize the quantum circuit with 2 qubits
124+
qc.create_empty_circuit(2)
125+
126+
# Apply a Hadamard gate to the first qubit
127+
qc.apply_hadamard_gate(0)
128+
129+
# Apply a CNOT gate with qubit 0 as control and qubit 1 as target
130+
qc.apply_cnot_gate(0, 1)
131+
132+
# Draw the circuit
133+
qc.draw()
134+
```
135+
136+
This section introduced the fundamental quantum gates and demonstrated how to apply them using the `qumat` library. In the next section, we will explore how to build more complex quantum circuits by combining these gates.

0 commit comments

Comments
 (0)