quantastica / quantum-circuit

Quantum Circuit Simulator implemented in JavaScript
MIT License
243 stars 47 forks source link

problem with U3 gate #16

Closed whu-dft closed 5 years ago

whu-dft commented 5 years ago

OPENQASM 2.0; include "qelib1.inc"; qreg q[8]; creg c[1]; x q[0]; u1 (pi/6) q[1]; z q[2]; ry (pi/6) q[3]; rz (0) q[4]; s q[5]; srswap q[6], q[7]; h q[0]; u2 (0, pi/7) q[1]; h q[2]; u1 (pi/2) q[3]; u2 (pi/11, 0) q[4]; sdg q[5]; tdg q[6]; y q[0]; srn q[1]; u1 (pi/4) q[2]; u1 (pi/8) q[3]; t q[4]; ms (0) q[6], q[7]; u2 (0, 0) q[5]; ms (pi/7) q[0], q[2]; u1 (0) q[3];

u3 (1, 2, 3) q[4];

swap q[5], q[6]; srswap q[3], q[7]; srswap q[6], q[1];

In above circuit, when I uncomment the U3 gate, the states of other qubits changes, which is obviously wrong because U3 gate only apply to q[4].

I see you have fixed the U2 gate and I think the U3 gate may have the same issue with U2.

perak commented 5 years ago

Fixed.

whu-dft commented 5 years ago

please also fix the U1 gate :handshake:

perak commented 5 years ago

@whu-dft u1 gate looks good. How to reproduce the issue?

whu-dft commented 5 years ago

I see that you fix the issue by replacing the pow with exp so I guess U1 gate may be problematic. I don't have an evidence.

But I found the numeric results (amplitude) of u1 gate are different with that of my implementation. May be you can check it by comparing with other quantum simulator.

perak commented 5 years ago

@whu-dft Amplitude should not change with u1 gate - only phase changes (u1 is rotation over Z axis, the same as rz gate). I tested the gate and it looks good.

I will close this issue, but if you find it is incorrect, please report.

Thank you!