<h1>Gate Decomposition</h1>

## Imports


```python
%matplotlib inline
```


```python
from IPython.display import display
```


```python
from sympy import init_printing
init_printing(use_latex=True)
```


```python
from sympy import sqrt, symbols, Rational
from sympy import expand, Eq, Symbol, simplify, exp, sin
from sympy.physics.quantum import *
from sympy.physics.quantum.qubit import *
from sympy.physics.quantum.gate import *
from sympy.physics.quantum.grover import *
from sympy.physics.quantum.qft import QFT, IQFT, Fourier
from sympy.physics.quantum.circuitplot import circuit_plot
```

<h2>Example 1</h2>

Create a symbolic controlled-Y gate


```python
CY10 = CGate(1, Y(0));
CY10
```

Decompose it into elementary gates and plot it


```python
CY10.decompose()
```


```python
circuit_plot(CY10.decompose(), nqubits=2);
```

<h2>Example 2</h2>

Create a controlled-Z gate


```python
CZ01 = CGate(0, Z(1));
CZ01
```

Decompose and plot it


```python
CZ01.decompose()
```


```python
circuit_plot(CZ01.decompose(), nqubits=2);
```

<h2>Example 3</h2>

Create a SWAP gate


```python
SWAP10 = SWAP(1, 0);
SWAP10
```

Decompose and plot it


```python
SWAP10.decompose()
```


```python
circuit_plot(SWAP10.decompose(), nqubits=2);
```

<h2>All together now</h2>


```python
gates = [CGate(1,Y(0)), CGate(0,Z(1)), SWAP(1, 0)]
```


```python
for g in gates:
    dg = g.decompose()
    display(Eq(g, dg))
    circuit_plot(g, nqubits=2)
    circuit_plot(dg, nqubits=2)    
```

9210f27c91241099fc1531ec7abb434e9308905f
ipynb
Jupyter Notebook
notebooks/decompose.ipynb
gvvynplaine/quantum_notebooks
58783823596465fe2d6c494c2cc3a53ae69a9752
BSD-3-Clause
2017-10-17T22:44:27.000Z
2022-03-28T06:26:46.000Z
notebooks/decompose.ipynb
gvvynplaine/quantum_notebooks
58783823596465fe2d6c494c2cc3a53ae69a9752
BSD-3-Clause
2017-10-09T05:16:41.000Z
2018-09-22T03:08:29.000Z
notebooks/decompose.ipynb
gvvynplaine/quantum_notebooks
58783823596465fe2d6c494c2cc3a53ae69a9752
BSD-3-Clause
2017-10-09T04:22:19.000Z
2022-03-28T06:25:21.000Z
Qwen/Qwen-72B
1. YES
2. YES