Before I start, I would like to say sorry for this possibly stupid question of mine. I just recently got into the topic of quantum computing and try me there.
I'm currently trying to display a SU(2) rotation using Qiskit.
from ibm_quantum_widgets import CircuitComposer
from qiskit.quantum_info import Statevector
from qiskit.visualization import plot_bloch_multivector
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from numpy import pi
import numpy as np
from qiskit.quantum_info.operators import Operator, Pauli
qreg_q = QuantumRegister(1, 'q')
circuit = QuantumCircuit(qreg_q)
clreg = ClassicalRegister(1)
...
After the implementations, I tried to achieve such a rotation with some matrices. This is one of them:
def rn_su2_5(theta, n1,n2,n3):
#This represents a matrix operator that will evolve() a Statevector by matrix-vector multiplication and will evolve() a DensityMatrix by left and right multiplication
return Operator([
[np.cos(theta/2)- 1j*n3*np.sin(theta/2), -1j*(n1-1j*n2)*np.sin(theta/2)],
[-1j*(n1+1j*n2)*np.sin(theta/2), np.cos(theta/2)+1j*n3*np.sin(theta/2)]
],input_dims=(2, 1), output_dims=(2, 1))
print(rn_su2_5(pi,1,1,1))
circuit.unitary(rn_su2_5(pi,1,1,1),0)
Output:
Operator([[ 6.123234e-17-1.j, -1.000000e+00-1.j],
[ 1.000000e+00-1.j, 6.123234e-17+1.j]],
input_dims=(2, 1), output_dims=(2, 1))
**ExtensionError: 'Input matrix is not unitary.'**
I would be very happy if you could help me with this problem.
Later the rotation should also be visible on a Blochsphere.
If the code is not sufficient, I will submit it later if necessary.
is_unitary_matrix
function does. It computesA^dagger.A
and checks if it is identity matrix: See Code here. $\endgroup$