# Gray codes

1. Apr 28, 2015

### jimmycricket

I am trying to derive a quantum circuit that will implement an arbitrary unitary operation using single qubit gates and C-NOT gates only. I have already shown how to construct a controlled U operation where U is a single qubit unitary operation. Furthermore I have proven the universality of two-level unitary matrices. Now I wish to show that any two level unitary operation can be performed using C-NOT and controlled U operations. To do this I must introduce gray codes. I understand that a gray code is a sequence of binary strings $\{x_1,x_2,...,x_n\}$ where neighbouring members differ in one bit only. I can understand when looking at circuit diagrams how the use of Gray codes can be used to implement U however I am struggling to explain the motivation behind using Gray codes in the first place. I can also construct some examples of circuits that execute U that I would show here but it appears qcircuit isnt supported on the forum. Sorry this isn't a very direct question: essentially I'm asking why Gray codes are used in circuits that enact arbitrary two-level unitary operations.

2. Apr 28, 2015

### SteamKing

Staff Emeritus
It's an artifact from the time when electromechanical switches were used in computing devices.

This article may explain the reasoning behind the use of the Gray code:

http://en.wikipedia.org/wiki/Gray_code

3. Apr 28, 2015

### phinds

Although used originally for mechanical switches (as stated in the article linked to by steamking), where varying latency of switching is much greater than with electronic circuits, they have also been used in some digital electronics where it is very important that inputs to a multiplexor, for example, that have varying delay times, do not cause transient spikes in the output while switching states.