Skip to content

Commit

Permalink
Fix mathjax/latex
Browse files Browse the repository at this point in the history
  • Loading branch information
rawkintrevo committed Jan 22, 2025
1 parent 1dcc8e4 commit b6aa75a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 32 deletions.
3 changes: 3 additions & 0 deletions website/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ baseurl: ""

# Build settings
markdown: kramdown
kramdown:
math_engine: mathjax
syntax_highlighter: rouge
plugins:
- jekyll-feed
- jekyll-latex
Expand Down
29 changes: 23 additions & 6 deletions website/quantum-computing-primer/03_qubits/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,32 @@ In classical computing, the fundamental unit of information is the **bit**, whic

$$|\psi\rangle = \alpha|0\rangle + \beta|1\rangle$$

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:
{% raw %}
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:
{% endraw %}

$$|\alpha|^2 + |\beta|^2 = 1$$

## 3.2 Representing Qubits

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.
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.

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:
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:

$$|0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$$

and the state \(|1\rangle\) is represented as:
{% raw %}
and the state $|1\rangle$ is represented as:
{% endraw %}

$$|1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$$

Expand Down Expand Up @@ -51,7 +64,9 @@ In this example, we initialize a quantum circuit with one qubit using the qiskit

### Example: Applying a Hadamard Gate

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:
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:

$$H|0\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle)$$

Expand All @@ -66,7 +81,9 @@ result = qc.execute_circuit()
print(result)
```

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.
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.

### Visualizing the Circuit

Expand Down
9 changes: 6 additions & 3 deletions website/quantum-computing-primer/04_quantum_gates/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ print(result)

## 4.2 Multi-Qubit Gates

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:
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:

- **CNOT Gate (Controlled-NOT)**: Flips the target qubit if the control qubit is in the state |1⟩.
- **Toffoli Gate (CCNOT)**: A controlled-controlled-NOT gate that flips the target qubit if both control qubits are in the state |1⟩.
- **CNOT Gate (Controlled-NOT)**: Flips the target qubit if the control qubit is
in the state $|1\rangle$.
- **Toffoli Gate (CCNOT)**: A controlled-controlled-NOT gate that flips the
target qubit if both control qubits are in the state $|1\rangle$.
- **SWAP Gate**: Exchanges the states of two qubits.

### Example: Applying a CNOT Gate
Expand Down
21 changes: 15 additions & 6 deletions website/quantum-computing-primer/07_quantum_algorithms/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@ Quantum algorithms leverage the unique properties of quantum mechanics, such as

## 7.1 Deutsch-Jozsa Algorithm

The Deutsch-Jozsa algorithm is one of the earliest quantum algorithms that demonstrates the potential of quantum computing. It solves a specific problem exponentially faster than any classical algorithm.
The Deutsch-Jozsa algorithm is one of the earliest quantum algorithms that
demonstrates the potential of quantum computing. It solves a specific problem
exponentially faster than any classical algorithm.

### Problem Statement
Given a function \( f: \{0,1\}^n \rightarrow \{0,1\} \), determine whether the function is **constant** (returns the same value for all inputs) or **balanced** (returns 0 for half of the inputs and 1 for the other half).
Given a function $ f: \{0,1\}^n \rightarrow \{0,1\} $, determine whether the
function is **constant** (returns the same value for all inputs) or **balanced**
(returns 0 for half of the inputs and 1 for the other half).

### Quantum Solution
The Deutsch-Jozsa algorithm uses quantum parallelism to evaluate the function over all possible inputs simultaneously. It requires only **one query** to the function, whereas a classical algorithm would need \( 2^{n-1} + 1 \) queries in the worst case.
The Deutsch-Jozsa algorithm uses quantum parallelism to evaluate the function
over all possible inputs simultaneously. It requires only **one query** to the
function, whereas a classical algorithm would need $ 2^{n-1} + 1 $ queries in
the worst case.

### Implementation with `qumat`
Here’s how you can implement the Deutsch-Jozsa algorithm using `qumat`:
Expand Down Expand Up @@ -55,10 +62,12 @@ print(result)

## 7.2 Grover's Algorithm

Grover's algorithm is a quantum search algorithm that can search an unsorted database of \( N \) items in \( O(\sqrt{N}) \) time, compared to \( O(N) \) for classical algorithms.
Grover's algorithm is a quantum search algorithm that can search an unsorted
database of $ N $ items in $ O(\sqrt{N}) $ time, compared to $ O(N) $ for
classical algorithms.

### Problem Statement
Given an unsorted database of \( N \) items, find a specific item (marked by an oracle) with as few queries as possible.
Given an unsorted database of $ N $ items, find a specific item (marked by an oracle) with as few queries as possible.

### Quantum Solution
Grover's algorithm uses amplitude amplification to increase the probability of measuring the marked item. It consists of two main steps:
Expand Down Expand Up @@ -109,7 +118,7 @@ print(result)
```

### Explanation
- The oracle marks the desired state (e.g., `|110>`).
- The oracle marks the desired state (e.g., $|110\rangle$).
- The diffusion operator amplifies the probability of measuring the marked state.
- After running the algorithm, the marked state will have a higher probability of being measured.

Expand Down
34 changes: 17 additions & 17 deletions website/quantum-computing-primer/10_advanced_topics/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ qc.create_empty_circuit(3)

# Apply the Quantum Fourier Transform
def apply_qft(qc, n_qubits):
for qubit in range(n_qubits):
qc.apply_hadamard_gate(qubit)
for next_qubit in range(qubit + 1, n_qubits):
angle = 2 * 3.14159 / (2 ** (next_qubit - qubit + 1))
qc.apply_cu_gate(next_qubit, qubit, angle)
for qubit in range(n_qubits):
qc.apply_hadamard_gate(qubit)
for next_qubit in range(qubit + 1, n_qubits):
angle = 2 * 3.14159 / (2 ** (next_qubit - qubit + 1))
qc.apply_cu_gate(next_qubit, qubit, angle)

apply_qft(qc, 3)

Expand All @@ -56,11 +56,11 @@ qc.create_empty_circuit(3)

# Apply the Quantum Phase Estimation
def apply_qpe(qc, n_qubits):
for qubit in range(n_qubits):
qc.apply_hadamard_gate(qubit)
# Apply controlled unitary operations (simplified example)
qc.apply_cu_gate(1, 0, 3.14159 / 2)
qc.apply_cu_gate(2, 1, 3.14159 / 4)
for qubit in range(n_qubits):
qc.apply_hadamard_gate(qubit)
# Apply controlled unitary operations (simplified example)
qc.apply_cu_gate(1, 0, 3.14159 / 2)
qc.apply_cu_gate(2, 1, 3.14159 / 4)
# Inverse QFT
apply_qft(qc, n_qubits)

Expand Down Expand Up @@ -89,13 +89,13 @@ qc.create_empty_circuit(2)

# Apply the Quantum Annealing process
def apply_quantum_annealing(qc, n_qubits):
for qubit in range(n_qubits):
qc.apply_hadamard_gate(qubit)
# Apply a simple Hamiltonian (simplified example)
qc.apply_rx_gate(0, 3.14159 / 2)
qc.apply_ry_gate(1, 3.14159 / 2)
# Measure the qubits
qc.execute_circuit()
for qubit in range(n_qubits):
qc.apply_hadamard_gate(qubit)
# Apply a simple Hamiltonian (simplified example)
qc.apply_rx_gate(0, 3.14159 / 2)
qc.apply_ry_gate(1, 3.14159 / 2)
# Measure the qubits
qc.execute_circuit()

apply_quantum_annealing(qc, 2)

Expand Down

0 comments on commit b6aa75a

Please sign in to comment.