Hi,
I am trying to simulate a simple Feynman quantum computer that executes the NOT logical function:
a = np.array([[0,0],[1,0]]) #matrix for annihilation operator
c=np.array([[0,1],[0,0]]) #matrix for creation operator
h=qml.QubitUnitary(a,wires=2)@qml.QubitUnitary(c,wires=1)@qml.PauliX(0)
Ht=qml.op_sum(h,qml.adjoint(h))
@qml.qnode(qml.device(‘default.qubit’, wires=3))
def FNOT(t): # t is time
qml.BasisState(np.array([1,0,0]), wires=range(3))
qml.exp(Ht,-1j*t)
return qml.state()
t
However, when executing FNOT(1) the output is:
tensor([0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], requires_grad=True)
This is NOT RIGHT!
The answer should be:
he=qml.exp(Ht,-1j*1).matrix()
v=np.array([0,0,0,0,1,0,0,0])
he.dot(v)=array([0. +0.j , 0. +0.j ,
0. +0.j , 0. -0.84147098j,
0.54030231+0.j , 0. +0.j ,
0. +0.j , 0. +0.j ])
So it would seem that Pennylane is correctly calculating the exponential operator outside the function using the defined Hamiltonian, but the qml.state() is not correctly reporting the result.
Any ideas on what could be going wrong here?
Thanks!