Trace is wrong but circuit looks correct

Trace is wrong but circuit looks correct

by Daniel Andrzej Polka -
Number of replies: 4
Hi, I implemented the circuit in qiskit and it seems to be correct if I draw it using circuit.draw('mpl'). I computed |0⟩⟨0|⊗I +|1⟩⟨1|⊗U as one matrix in numpy and then converted it into a UnitaryGate, which I then applied to the right qubits. However, I'm getting seemingly random trace estimation results. Does anyone have an idea where I could be going wrong by any chance? This is my result for circuit.draw('mpl'):
Circuit
Thanks in advance for any responses.
In reply to Daniel Andrzej Polka

Re: Trace is wrong but circuit looks correct

by Khurshed Porus Fitter -

I believe, if you look at the given circuit diagram again, it will be easy to spot the error :)

In reply to Daniel Andrzej Polka

Trace is wrong but circuit looks correct

by Dina Khaled Sayed Abdelhadi -
Hi Daniel,
May be try to increase the number of shots.
In reply to Dina Khaled Sayed Abdelhadi

Re: Trace is wrong but circuit looks correct

by Dina Khaled Sayed Abdelhadi -
That is, assuming you do the rest of the computation correctly.
In general, the more shots, the more accurate your estimate is. Try 1 million shots.
In reply to Dina Khaled Sayed Abdelhadi

Re: Trace is wrong but circuit looks correct

by Daniel Andrzej Polka -
Thanks! It's okay, I managed to fix it now, everything works