Understanding your circuits by using the unitary simulator
As it turns out, any valid quantum circuit that consists only of gates can be translated into a unitary matrix that describes the expected outcome for each possible state vector input. As you have seen in Chapter 2, Quantum Computing and Qubits with Python, each quantum gate is in itself a unitary matrix, and the combination of the unitaries that make up the complete quantum circuit can in itself be described as a unitary.
Qiskit® lets you use the Qiskit Aer unitary_simulator
simulator to return the unitary matrix that corresponds with your quantum circuit. You run the job just like you would for qasm_simulator
jobs.
When running unitary_simulator
, you only run the circuit once. We can then use the get_unitary(qc)
method on the returned results to see the unitary as a matrix for a circuit, such as this one-qubit superposition circuit using a Hadamard gate: