<h1>Basic Symbolic Quantum Mechanics</h1>


```
%load_ext sympyprinting
```


```
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>Bras and Kets</h2>

Create symbolic states


```
phi, psi = Ket('phi'), Ket('psi')
alpha, beta = symbols('alpha beta', complex=True)
```

Create a superposition


```
state = alpha*psi + beta*phi; state

```

Dagger the superposition and multiply the original


```
ip = Dagger(state)*state; ip

```

Distribute


```
qapply(expand(ip))

```

<h2>Operators</h2>

Create symbolic operators


```
A = Operator('A')
B = Operator('B')
C = Operator('C')
```

Test commutativity


```
A*B == B*A

```




    False



Distribute A+B squared


```
expand((A+B)**2)
```

Create a commutator


```
comm = Commutator(A,B); comm

```

Carry out the commutator


```
comm.doit()
```

Create a more fancy commutator


```
comm = Commutator(A*B,B+C); comm
```

Expand the commutator


```
comm.expand(commutator=True)
```

Carry out and expand the commutators


```
_.doit().expand()

```

Take the dagger


```
Dagger(_)
```

002a0b0d663b1f84b68756353dd7b7425d1a6528
ipynb
Jupyter Notebook
docs/examples/notebooks/basic_quantum.ipynb
tinyclues/ipython
71e32606b0242772b81c9be0d40751ba47d95f2c
BSD-3-Clause-Clear
2016-05-26T10:57:18.000Z
2016-05-26T10:57:18.000Z
docs/examples/notebooks/basic_quantum.ipynb
adgaudio/ipython
a924f50c0f7b84127391f1c396326258c2b303e2
BSD-3-Clause-Clear
docs/examples/notebooks/basic_quantum.ipynb
adgaudio/ipython
a924f50c0f7b84127391f1c396326258c2b303e2
BSD-3-Clause-Clear
Qwen/Qwen-72B
1. YES
2. YES