<jupyter_start><jupyter_text>DECLARING |0> AND |1><jupyter_code>import numpy as np
q0=np.array([[1],[0]])
q1=np.array([[0],[1]])
print("\nq0=\n",q0 )
print("\nq1=\n",q1)<jupyter_output>q0=
 [[1]
 [0]]

q1=
 [[0]
 [1]]<jupyter_text>DECLARING UNITARY MATRIX AND HERMITIAN MATRIX<jupyter_code>X = np.array([[0,1],[1, 0]])
print("X = \n",X)
hermitianMatrix = np.conj(X).transpose()
unitaryMatrix = np.matmul(X, hermitianMatrix)
print("unitaryMatrix: XX* =\n ",unitaryMatrix)
print("hermitianMatrix: if A* = A i.e,\nA =\n",X,"\nand A* =\n",hermitianMatrix,"\ntherefore we can conclude A=A*, therefore A is a Hermitian Matrix.")<jupyter_output>unitaryMatrix: XX* =
  [[1 0]
 [0 1]]
hermitianMatrix: if A* = A i.e,
A =
 [[0 1]
 [1 0]] 
and A* =
 [[0 1]
 [1 0]] 
therefore we can conclude A=A*, therefore A is a Hermitian Matrix.<jupyter_text>INNER PRODUCT, OUTER PRODUCT AND TENSOR PRODUCT<jupyter_code>print("INNER PRODUCT")
F = np.array([2, 1-2j])
V = np.array([[1, 2]])
print("Inner product of F and V is\n",np.dot(V,np.conj(F).transpose()))
print("Outer Product of F and V is\n",np.outer(F,V))
print("Tensor Product of \nV=\n", V,"\nand F =\n",F,"\nis =\n",np.tensordot(V,F,0))<jupyter_output>Tensor Product of 
V=
 [[1 2]] 
and F =
 [2.+0.j 1.-2.j] 
is =
 [[[2.+0.j 1.-2.j]
  [4.+0.j 2.-4.j]]]<jupyter_text>QUANTUM GATES: PAULI-X(NOT), PAULI-Z, HADAMARD, CNOT, TOFFOLI<jupyter_code>print("PAULI-X Gate output when applied on state 0: \n",np.matmul(X, q0))
print("PAULI-X Gate output when applied on state 1: \n",np.matmul(X, q1))
print("PAULI Z-Gate")
Z = np.array([[1,0],[0, -1]])
print("When acted on state 0: \n|0>:\n",np.matmul(Z,q0))
print("When acted on state 1: \n|1>:\n",np.matmul(Z,q1))
print("Z- gate leaves |0 unchanged, and flips the sign of |1 to give −|1")
import math
print("HADAMARD GATE")
X1 = np.array([[1,0],[0,1]])
H = np.dot(1/math.sqrt(2),np.array([[1,1],[1,-1]]))
print("Output of the hadamard gate when applied to |0>:\n",np.matmul(H,q0))
print("Output of the hadamard gate when applied to |1>:\n",np.matmul(H,q1))
print("CNOT GATE")
q00 = np.tensordot(q0,q0,0)
q01 = np.tensordot(q0,q1,0)
q10 = np.tensordot(q1,q0,0)
q11 = np.tensordot(q1,q1,0)
cnot = np.array([[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]])
q10 = np.tensordot(q1,q0,0)
cnot.resize(4,4)
q10.resize(4,1)
q11.resize(4,1)
q00.resize(4,1)
q01.resize(4,1)
print("CNOT |00> =\n", np.matmul(cnot,q00))
print("CNOT |01> =\n",np.matmul(cnot,q01))
print("CNOT |10> =\n",np.matmul(cnot,q10))
print("CNOT |11> =\n",np.matmul(cnot,q11))
q000=np.tensordot(q00,q0,0)
q001=np.tensordot(q00,q1,0)
q010=np.tensordot(q01,q0,0)
q011=np.tensordot(q01,q1,0)
q100=np.tensordot(q10,q0,0)
q101=np.tensordot(q10,q1,0)
q110=np.tensordot(q11,q0,0)
q111=np.tensordot(q11,q1,0)
Toffoli = np.array([
            [1,0,0,0,0,0,0,0],
            [0,1,0,0,0,0,0,0],
            [0,0,1,0,0,0,0,0],
            [0,0,0,1,0,0,0,0],
            [0,0,0,0,1,0,0,0],
            [0,0,0,0,0,1,0,0],
            [0,0,0,0,0,0,0,1],
            [0,0,0,0,0,0,1,0]])
q000.resize(8,1)
q001.resize(8,1)
q010.resize(8,1)
q011.resize(8,1)
q100.resize(8,1)
q101.resize(8,1)
q110.resize(8,1)
q111.resize(8,1)
a = np.array([q000,q001,q010,q011,q100,q101,q110,q111])
av = np.array(["000","001","010","011","100","101","110","111"])
for i in range(0,8):
    print("Toffoli |",av[i],"> =\n",np.matmul(Toffoli,a[i]))<jupyter_output>Toffoli | 000 > =
 [[1]
 [0]
 [0]
 [0]
 [0]
 [0]
 [0]
 [0]]
Toffoli | 001 > =
 [[0]
 [1]
 [0]
 [0]
 [0]
 [0]
 [0]
 [0]]
Toffoli | 010 > =
 [[0]
 [0]
 [1]
 [0]
 [0]
 [0]
 [0]
 [0]]
Toffoli | 011 > =
 [[0]
 [0]
 [0]
 [1]
 [0]
 [0]
 [0]
 [0]]
Toffoli | 100 > =
 [[0]
 [0]
 [0]
 [0]
 [1]
 [0]
 [0]
 [0]]
Toffoli | 101 > =
 [[0]
 [0]
 [0]
 [0]
 [0]
 [1]
 [0]
 [0]]
Toffoli | 110 > =
 [[0]
 [0]
 [0]
 [0]
 [0]
 [0]
 [0]
 [1]]
Toffoli | 111 > =
 [[0]
 [0]
 [0]
 [0]
 [0]
 [0]
 [1]
 [0]]
{'fraction_non_alphanumeric': 0.2572992700729927, 'fraction_numerical': 0.11965589155370178, 'mean_word_length': 4.336578581363004, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '506038', 'license': 'MIT', 'n_tokens_mistral': 2171, 'n_tokens_neox': 2027, 'n_words': 363, 'path': 'QUBITOPERATIONSANDGATES.ipynb', 'repo_name': 'anshulanema/Quantum-Computing-and-Quantum-Error-Correcting-Codes', 'size': '3836'}