[HS.4.2a] I have gotten the feedback "correct". But I think system answer is not correct

Hi,

I have marked my answer and system’s “correct” answer in my code comments.

Want to confirm if I’m right.

#################### my code #################

h_coeffs = [1/4,1/4,1/2]
h_ops = [qp.PauliZ(5),qp.PauliZ(6),qp.PauliX(5)@qp.PauliX(6)]
H = qp.dot(h_coeffs,h_ops)# Write the Hamiltonian here

dev = qp.device(“default.qubit”, wires = range(7))
walk_powers_1 = [qp.pow(qp.Qubitization(H, control = [3,4]), i) for i in range(0,3)]
walk_powers_2 = [qp.pow(qp.adjoint(qp.Qubitization(H, control = [3,4])), i) for i in reversed(range(1,3))]
print(“walk_powers_1:”, walk_powers_1)
print(“walk_powers_2:”, walk_powers_2)
lcu_ops = walk_powers_2 + walk_powers_1
print(“lcu_ops:”, lcu_ops)

bessel_1 = [0.7651976865579666, 0.44005058574493355, 0.1149034849319005]

###Construct the coefficients for the Jacobi-Anger LCU

J0,J1,J2 = bessel_1
norm_fact = J0+2J1+2J2

“”"

#This is my proposed correct answer.

lcu_coeffs = [
(-1)*J2/norm_fact,
(-1j)*J1/norm_fact,
J0/norm_fact,
(1j)*J1/norm_fact,
(-1)*J2/norm_fact,
]
“”"
“”"
lcu_coeffs = [
(-1)*J2/norm_fact,
(1j)*J1/norm_fact,
J0/norm_fact,
(-1j)*J1/norm_fact,
(-1)*J2/norm_fact,
]
“”"

“”"
lcu_coeffs = [
(-1)*J2/norm_fact,
(-1j)*J1/norm_fact,
J0/norm_fact,
(-1j)*J1/norm_fact,
(-1)*J2/norm_fact,
]
“”"

#This is the system-verified correct answer.
lcu_coeffs = [
(-1)*J2/norm_fact,
(1j)*J1/norm_fact,
J0/norm_fact,
(1j)*J1/norm_fact,
(-1)*J2/norm_fact,
]

lcu = qp.dot(lcu_coeffs, lcu_op@qp.qnode)

@qp.qnode(dev)
def prep_sel_prep_walk():
“”"
Quantum circuit that applies PrepSelPrep to the Walk operator
to generate the Jacobi Anger expansion to order 2.
Returns:

  • (np.ndarray): The quantum state
    “”"
####################
###YOUR CODE HERE###
####################

qp.PrepSelPrep(lcu, control=[0,1,2])

return qp.state()

encoded_matrix = qp.matrix(prep_sel_prep_walk, wire_order=range(7))()[:4, :4]
print(“The encoded matrix is: \n”, encoded_matrix)

##################### User output #############################

walk_powers_1: [Qubitization(0.25, 0.25, 0.5, wires=[3, 4, 5, 6])**0, Qubitization(0.25, 0.25, 0.5, wires=[3, 4, 5, 6])**1, Qubitization(0.25, 0.25, 0.5, wires=[3, 4, 5, 6])**2]
walk_powers_2: [(Adjoint(Qubitization(0.25, 0.25, 0.5, wires=[3, 4, 5, 6])))**2, (Adjoint(Qubitization(0.25, 0.25, 0.5, wires=[3, 4, 5, 6])))**1]
lcu_ops: [(Adjoint(Qubitization(0.25, 0.25, 0.5, wires=[3, 4, 5, 6])))**2, (Adjoint(Qubitization(0.25, 0.25, 0.5, wires=[3, 4, 5, 6])))**1, Qubitization(0.25, 0.25, 0.5, wires=[3, 4, 5, 6])**0, Qubitization(0.25, 0.25, 0.5, wires=[3, 4, 5, 6])**1, Qubitization(0.25, 0.25, 0.5, wires=[3, 4, 5, 6])**2]
The encoded matrix is: 
 [[4.08082400e-01+2.34680400e-01j 0.00000000e+00+0.00000000e+00j
  0.00000000e+00+0.00000000e+00j 1.77716646e-17+2.34680400e-01j]
 [0.00000000e+00+0.00000000e+00j 4.69360800e-01-4.65865772e-17j
  1.33504646e-17+2.34680400e-01j 0.00000000e+00+0.00000000e+00j]
 [0.00000000e+00+0.00000000e+00j 1.53895955e-17+2.34680400e-01j
  4.69360800e-01+3.15776979e-17j 0.00000000e+00+0.00000000e+00j]
 [1.09683955e-17+2.34680400e-01j 0.00000000e+00+0.00000000e+00j
  0.00000000e+00+0.00000000e+00j 4.08082400e-01-2.34680400e-01j]]