Stuck on Codercise I.5.4

Hello,
I was able to simplify the circuit as follows:

However, I received the following error:
Incorrect: Your resulting output doesn’t look quite right.
Incorrect: more than 1 T gates are needed.
Incorrect: the optimal depth of the circuit is not 4.
Incorrect: the optimal T-count of the circuit is not 1.
Incorrect: the optimal T-depth of the circuit is not 1.

In wire 0: the pairs of H-gates, T-gates, and adjoint T-gates cancel each other, and one H-gate remains
In wire 1: the pair of H-gates cancel each other and the 2 pairs of T-gates become S-gates, one T-gate, and H-gate remain
In wire 2: the pair of H-gates cancel each other, the 2 pairs of adjoint T-gates become adjoint S-gates, and one H-gate remains

I am not sure where the simplification went wrong.

The simplification went wrong because you can only cancel out the pairs of gates when they are right next to each other. For example H T H cannot be simplified to T, but H H T can be. This is because the operators do not commute: you cannot generally swap the ordering of matrix transformations around.

Now with this I’m sure your simplification will be very different.

1 Like

Yes, my updated simplification is now different. I forgot about the non-commutativity, looks like I need to revise the basics. Thank you for your explanation.

1 Like

Hey @Sfdq! Welcome to the forum :slight_smile:

If you have any further questions or concerns, write back!