Problem Set 0¶
This is to help you get used to logging into qBraid, loading the notebook, running it, and printing it out to PDF.
Run the following commands. In qBraid you can press the play button, or press Shift-Enter. After you're all done running the commands, go to File > Save and Export Notebook As > HTML and compare the output with ours.
Setting up and installing Qiskit¶
Here you will get qBraid to load and install Qiskit, which we will use to render a quantum circuit. If everything is successful, an "Install Good" quantum circuit should appear below.
!pip install qiskit &> /dev/null
from qiskit import *
import qiskit
def qiskit_check() -> QuantumCircuit():
qc = QuantumCircuit(1) #instal god
I = QuantumCircuit(1)
I.name = "I"
n = QuantumCircuit(1)
n.name = "n"
s = QuantumCircuit(1)
s.name = "s"
t = QuantumCircuit(1)
t.name = "t"
a = QuantumCircuit(1)
a.name = "a"
l = QuantumCircuit(1)
l.name = "l"
space = QuantumCircuit(1)
space.name = " "
G = QuantumCircuit(1)
G.name = "G"
o = QuantumCircuit(1)
o.name = "o"
d = QuantumCircuit(1)
d.name = "d"
qc_list = [I, n, s, t, a, l, l, space, G, o, o, d]
for op in qc_list:
qc.append(op, range(1))
qc.measure_all()
return qc
print("\n Here's an example of a quantum circuit: \n")
qiskit_check().draw()
Here's an example of a quantum circuit:
┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐ ░ ┌─┐
q: ┤ I ├┤ n ├┤ s ├┤ t ├┤ a ├┤ l ├┤ l ├┤ ├┤ G ├┤ o ├┤ o ├┤ d ├─░─┤M├
└───┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘└───┘ ░ └╥┘
meas: 1/════════════════════════════════════════════════════════════════╩═
0
Some LaTeX practice¶
In this section we check that you have some comfort with LaTeX. The next few commands (which are invisible when you render the text) will set up the quantum-specific LaTeX macros we will use in the problem sets. $\newcommand{\ket}[1]{\left|{#1}\right\rangle}$ $\newcommand{\bra}[1]{\left\langle{#1}\right|}$ $\newcommand{\C}{\mathbb{C}}$ Check that the following output looks like the PDF we created.
The quantum state $\ket{\psi} = \frac{1}{\sqrt{2}} \Big( \ket{0} + \ket{1} \Big)$ is in an equal superposition of being in the state "0" and the state "1". In general, an $n$-qubit state is represented by a $2^n$-length unit vector $\ket{\varphi} \in \C^{2^n}$.
Now it's your turn¶
If you aren't familiar with LaTeX, try getting a little practice in this sandbox here.
Some examples:
- Einstein told us that $E = mc^2$. $a^2 + b^2 = c^2$
- Euler told us that $\mathrm{e}^{i \pi} - 1 = 0$.
- The dot product of two $n$-vectors is $\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^n a_i b_i$.
- We can make an equation appear centered on a new line, like
\begin{align}
\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^n a_i b_i.
\end{align}
5. We can also create a sequence of equations using the align environment.
\begin{align} \mathbf{a} \cdot \mathbf{b} &= \sum_{i=1}^n a_i b_i \\ &= a_x b_x + a_y b_y + a_z b_z. \end{align}
For more examples, check out this tutorial.