# Setup básico
!pip install qiskit -q
!pip install qiskit[visualization] -q
import qiskit as qk

!pip install qiskit-aer -q
import qiskit_aer as qk_aer

import numpy as np
np.set_printoptions(precision=3, suppress=True)

from matplotlib import pyplot as plt
%matplotlib inline

import pandas as pd
import sklearn as sk

import qiskit as qk
qc = qk.QuantumCircuit(3,3)
qc.initialize(1,[0])
qc.barrier()
qc.h(1)
qc.cx(1,2)
qc.barrier()
qc.cx(0,1)
qc.h(0)
qc.barrier()
qc.measure([0,1],[0,1])
display(qc.draw('mpl', style='clifford', scale=1))

import sympy as sp
a, b = sp.symbols('a b')
q0 = sp.Matrix([[a, b]]); display(q0); print(" ")
q1 = sp.Matrix([[1, 0]]); display(q1); print(" ")
q2 = sp.Matrix([[1, 0]]); display(q2);

from sympy import kronecker_product as kron
e0 = kron(q0, kron(q1,q2)); e0

I1 = sp.Matrix([[1,0],
                [0,1]])
H1 = sp.Matrix([[1, 1],
                [1,-1]])
IHI = kron(I1,kron(H1,I1))

CNOT12 = sp.Matrix([[1,0,0,0],
                    [0,1,0,0],
                    [0,0,0,1],
                    [0,0,1,0]])
IC12 = kron(I1,CNOT12)


e1 = e0*IHI*IC12; e1

e2 = e1*kron(CNOT12,I1)*kron(H1,kron(I1,I1)); e2