# I don't understand unitary of ${e^{iAt}}$ from HHL algorithm

I tried to implement the following circuit in the image below but with the red circled gates replaced with a unitary controlled $${e^{iAt/2}}$$ and controlled $${e^{iAt/4}}$$ The image came from this paper here and someone already implemented this circuit here.

The matrix A is :

And t = 2π

For $${e^{iAt/2}}$$ I found that the matrix is equal to an X gate which is same as the paper.

For $${e^{iAt/4}}$$ I got this matrix.

But in the paper they use U3(-pi/2,-pi/2,pi/2) as target bit and U1(3π/4) afterwards at control bit.
The unitary matrix from both qubit is something like this.(I use qiskit to find the unitary matrix)

While my $${e^{iAt/4}}$$ connected with a control bit gives different unitary matrix.
Am I missing something or is there anything wrong with my $${e^{iAt/4}}$$ unitary?

The mistakes comes from the fact that you missed the controlled-part of the U3 gate.

So your equivalent gate should really be:

qr = QuantumRegister(2, 'qubit')
qc = QuantumCircuit(qr, ClassicalRegister(2, name='classicabit'))
qc.cu3(-math.pi/2, -math.pi/2, math.pi/2, 0, 1)
qc.u1(3.0*math.pi/4,0)


The unitary result of :

is :

[[ 1. +0.j   0. +0.j   0. +0.j   0. +0.j ]
[ 0. +0.j  -0.5+0.5j  0. +0.j  -0.5-0.5j]
[ 0. +0.j   0. +0.j   1. +0.j   0. +0.j ]
[ 0. +0.j  -0.5-0.5j  0. +0.j  -0.5+0.5j]]


Where you find your unitary matrix :

[[ -0.5+0.5j -0.5-0.5j]
[ -0.5-0.5j -0.5+0.5j]]

controlled by qubit 1.

I did not understand how you implemented your $${e^{iAt/4}}$$ controlled gate, at least the methods you use do not work with my qiskit version so you can check with this code :

A = np.array([[1.5, 0.5],[0.5, 1.5]])
qc = QuantumCircuit(2)
gate=ex.UnitaryGate(expm(A*1.j*math.pi/2)).control(1)
qc.append(gate, [0,1])

qasm_sim = BasicAer.get_backend('unitary_simulator')
result = execute(qc, qasm_sim).result()
print(result.get_unitary())


which produces

[[ 1. -5.55111512e-17j 0. +0.00000000e+00j 0. +0.00000000e+00j 0.+0.00000000e+00j]
[ 0. +0.00000000e+00j -0.5+5.00000000e-01j 0. +0.00000000e+00j -0.5-5.00000000e-01j] [ 0. +0.00000000e+00j 0. +0.00000000e+00j 1. -7.21644966e-16j 0. +0.00000000e+00j] [ 0. +0.00000000e+00j -0.5-5.00000000e-01j 0. +0.00000000e+00j -0.5+5.00000000e-01j]]