# Displaced squeezed state

**URL:** <https://discuss.pennylane.ai/t/displaced-squeezed-state/67>\
**Category:** PennyLane Help\
**Created:** [January 8, 2019, 6:21pm UTC](https://discuss.pennylane.ai/t/displaced-squeezed-state/67 "2019-01-08T18:21:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kareem\_essafty](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/kareem_essafty/32/401_2.png) [@kareem\_essafty](https://discuss.pennylane.ai/u/kareem_essafty)\
**Post date:** [January 8, 2019, 6:21pm UTC](https://discuss.pennylane.ai/t/displaced-squeezed-state/67/1 "2019-01-08T18:21:32Z")

</div>

while going through the documentation i stared at this section for a while:

 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/1X/b56ec0202b63d99c0ebe131ea7f46d2004e2d916.png)

i searched for it and i think and please correct it me it’s safe to say that the displacement operator can be made first according to [this paper](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.54.5378) they say in the intro that someone had derived it this way

am i missing something or not?  
@Maria_Schuld @josh @Christian_Gogolin

---

<div class="post-metadata">

**Author:** ![Christian\_Gogolin](https://avatars.discourse-cdn.com/v4/letter/c/91b2a8/32.png) [@Christian\_Gogolin](https://discuss.pennylane.ai/u/Christian_Gogolin)\
**Post date:** [January 10, 2019, 7:18pm UTC](https://discuss.pennylane.ai/t/displaced-squeezed-state/67/2 "2019-01-10T19:18:35Z")

</div>

The easiest thing is to try it out in PennyLane:

```
import pennylane as qml
from pennylane import numpy as np

num_subsystems = 1
dev = qml.device('default.gaussian', wires=num_subsystems)
a = 0.2
r = 0.4
phi = 0

@qml.qnode(dev)
def circuit1():
    qml.DisplacedSqueezedState(a, r, phi, wires=[0])
    return qml.expval.MeanPhoton(wires=[0])

@qml.qnode(dev)
def circuit2():
    qml.Squeezing(r, phi, wires=[0])
    qml.Displacement(a, 0, wires=[0])
    return qml.expval.MeanPhoton(wires=[0])

@qml.qnode(dev)
def circuit3():
    qml.Displacement(a, 0, wires=[0])
    qml.Squeezing(r, phi, wires=[0])
    return qml.expval.MeanPhoton(wires=[0])

print(circuit1())
print(circuit2())
print(circuit3())

```

You will see that this prints

```
0.2087174731524224
0.2087174731524224
0.1866906317171112

```

which means that the order of squeezing and displacement does matter.

---

<div class="post-metadata">

**Author:** ![kareem\_essafty](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/kareem_essafty/32/401_2.png) [@kareem\_essafty](https://discuss.pennylane.ai/u/kareem_essafty)\
**Post date:** [January 10, 2019, 8:34pm UTC](https://discuss.pennylane.ai/t/displaced-squeezed-state/67/3 "2019-01-10T20:34:22Z")

</div>

the replacement itself affects the training a lot too  
thanks for explanation 😉
