```python
import sympy as sym
from sympy import Matrix
from sympy import exp
from sympy import re, im, I, E, symbols
from sympy.physics.quantum import TensorProduct
from sympy.physics.quantum.dagger import Dagger
```


```python
z = Matrix([[1, 0], [0, -1]])
y = Matrix([[0, -I], [I, 0]])
identity = Matrix([[1, 0], [0, 1]]) 
```


```python
gamma = symbols('gamma', real=True)
beta = symbols('beta', real=True)
```


```python
vec = Matrix([exp(-3*I*gamma), exp(-I*gamma), exp(-I*gamma), exp(-I*gamma), exp(-I*gamma), exp(-I*gamma), exp(-I*gamma), exp(-3*I*gamma)]) / sym.sqrt(2**3)
vec_c = sym.conjugate(vec.transpose())
```


```python
main = sym.sin(2*beta)**2 * TensorProduct(y, y, identity) + sym.cos(2*beta)**2 * TensorProduct(z, z, identity) + sym.cos(2*beta)*sym.sin(2*beta) * (TensorProduct(y, z, identity) + TensorProduct(z, y, identity))
main
```




$\displaystyle \left[\begin{matrix}\cos^{2}{\left(2 \beta \right)} & 0 & - i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & - i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & - \sin^{2}{\left(2 \beta \right)} & 0\\0 & \cos^{2}{\left(2 \beta \right)} & 0 & - i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & - i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & - \sin^{2}{\left(2 \beta \right)}\\i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & - \cos^{2}{\left(2 \beta \right)} & 0 & \sin^{2}{\left(2 \beta \right)} & 0 & i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0\\0 & i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & - \cos^{2}{\left(2 \beta \right)} & 0 & \sin^{2}{\left(2 \beta \right)} & 0 & i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)}\\i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & \sin^{2}{\left(2 \beta \right)} & 0 & - \cos^{2}{\left(2 \beta \right)} & 0 & i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0\\0 & i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & \sin^{2}{\left(2 \beta \right)} & 0 & - \cos^{2}{\left(2 \beta \right)} & 0 & i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)}\\- \sin^{2}{\left(2 \beta \right)} & 0 & - i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & - i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & \cos^{2}{\left(2 \beta \right)} & 0\\0 & - \sin^{2}{\left(2 \beta \right)} & 0 & - i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & - i \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)} & 0 & \cos^{2}{\left(2 \beta \right)}\end{matrix}\right]$




```python
sym.expand(vec_c * main * vec)
```




$\displaystyle \left[\begin{matrix}- \frac{e^{2 i \gamma} \sin^{2}{\left(2 \beta \right)}}{4} - \frac{i e^{2 i \gamma} \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)}}{2} + \frac{\sin^{2}{\left(2 \beta \right)}}{2} - \frac{e^{- 2 i \gamma} \sin^{2}{\left(2 \beta \right)}}{4} + \frac{i e^{- 2 i \gamma} \sin{\left(2 \beta \right)} \cos{\left(2 \beta \right)}}{2}\end{matrix}\right]$




```python

```


```python

```

a203bb6f270fe83878205ceba8c4c01911a35c5e
ipynb
Jupyter Notebook
symbolic_math.ipynb
FyzHsn/qaoa
efb5b9d91b43484ce721b8b404f0004a409abd4c
MIT
symbolic_math.ipynb
FyzHsn/qaoa
efb5b9d91b43484ce721b8b404f0004a409abd4c
MIT
symbolic_math.ipynb
FyzHsn/qaoa
efb5b9d91b43484ce721b8b404f0004a409abd4c
MIT
Qwen/Qwen-72B
1. YES
2. YES