# Qiskit Example: Basic Quantum Circuit Simulation

## Importing Required Libraries

from qiskit import QuantumCircuit, Aer, execute
from qiskit.tools.visualization import plot_bloch_multivector, plot_histogram
from qiskit.quantum_info import Operator


# Create a quantum circuit with 1 qubit and 1 classical bit
circuit = QuantumCircuit(1, 1)

# Apply X gate to the qubit
circuit.x(0)

# Draw the circuit
circuit.draw('mpl')

# Simulate the circuit and obtain the statevector
simulator = Aer.get_backend('statevector_simulator')
result = execute(circuit, backend=simulator).result()
statevector = result.get_statevector()

# Print the statevector
print(statevector)

# Plot the Bloch vector
plot_bloch_multivector(statevector)

# Measure the qubit and obtain the counts
circuit.measure([0], [0])
backend = Aer.get_backend('qasm_simulator')
result = execute(circuit, backend=backend, shots=1024).result()
counts = result.get_counts()

# Plot the histogram of counts
plot_histogram(counts)


circuit = QuantumCircuit(1,1)
circuit.x(0)
simulator = Aer.get_backend('unitary_simulator')
result = execute(circuit, backend = simulator).result()
unitary = result.get_unitary()
print(unitary)

circuit.draw()

