# Strange behaviour from displaced squeezed states

**URL:** <https://discuss.pennylane.ai/t/strange-behaviour-from-displaced-squeezed-states/207>\
**Category:** Strawberry Fields\
**Created:** [September 10, 2019, 2:41pm UTC](https://discuss.pennylane.ai/t/strange-behaviour-from-displaced-squeezed-states/207 "2019-09-10T14:41:48Z")\
**Posts on this page:** 8\
**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:** [September 10, 2019, 2:41pm UTC](https://discuss.pennylane.ai/t/strange-behaviour-from-displaced-squeezed-states/207/1 "2019-09-10T14:41:48Z")

</div>

the version is 0.10.0

> import strawberryfields as sf  
> from strawberryfields.ops import \*  
> import numpy as np

> z2 = -1j  
> z1 = 5j  
> d1 = 1+0.2j  
> d2 = 1-0.7j

> eng, q = sf.Engine(2)  
> with eng:  
> DisplacedSqueezed(z1,d1.real,d1.imag) | q[0]  
> DisplacedSqueezed(z2,d2.real,d2.imag) | q[1]  
> state = eng.run(‘fock’, cutoff\_dim=70)

when i tried to get the scalar value of this state this was the output:

> r0=state.reduced\_dm(modes=0)  
> r1=state.reduced\_dm(modes=1)  
> (np.dot(r0.conj().T.flatten(),r1.flatten()))

the answer was

> (17028300.770738766-4.9837951616186406e-08j)

is that normal?!

---

<div class="post-metadata">

**Author:** ![nathan](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nathan/32/85_2.png) [@nathan](https://discuss.pennylane.ai/u/nathan)\
**Post date:** [September 10, 2019, 3:30pm UTC](https://discuss.pennylane.ai/t/strange-behaviour-from-displaced-squeezed-states/207/2 "2019-09-10T15:30:48Z")

</div>

Hi @kareem_essafty,

I suspect your squeezing amplitude is too large for accurate simulation.  
Can you confirm what the trace of your state is?

---

<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:** [September 10, 2019, 3:47pm UTC](https://discuss.pennylane.ai/t/strange-behaviour-from-displaced-squeezed-states/207/3 "2019-09-10T15:47:08Z")

</div>

Trace is bigger than 1!

---

<div class="post-metadata">

**Author:** ![nathan](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nathan/32/85_2.png) [@nathan](https://discuss.pennylane.ai/u/nathan)\
**Post date:** [September 10, 2019, 4:00pm UTC](https://discuss.pennylane.ai/t/strange-behaviour-from-displaced-squeezed-states/207/4 "2019-09-10T16:00:31Z")

</div>

Yep, definitely numerical instability then. If your trace is not in the range ~0.95-1 or so, the simulation is likely unphysical. Try repeating your experiment with reduced squeezing amplitudes until you can get the trace near 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:** [September 11, 2019, 2:21am UTC](https://discuss.pennylane.ai/t/strange-behaviour-from-displaced-squeezed-states/207/5 "2019-09-11T02:21:22Z")

</div>

what if i want to apply high squeezing amplitudes with a complex displacement parameter

---

<div class="post-metadata">

**Author:** ![nathan](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nathan/32/85_2.png) [@nathan](https://discuss.pennylane.ai/u/nathan)\
**Post date:** [September 11, 2019, 1:31pm UTC](https://discuss.pennylane.ai/t/strange-behaviour-from-displaced-squeezed-states/207/6 "2019-09-11T13:31:01Z")

</div>

Squeezing and displacement are both operations that increase the energy. Higher energies require higher cutoffs.

You always need to make sure you’re in a regime where the energy isn’t too high compared to the cutoff (trace ~1). As long as that holds true, you can use any parameters you wish

---

<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:** [September 11, 2019, 3:58pm UTC](https://discuss.pennylane.ai/t/strange-behaviour-from-displaced-squeezed-states/207/7 "2019-09-11T15:58:42Z")

</div>

If I may ask you sir,  
How exactly should I calculate the proper cutoff dimension value?  
And for the above values, I guess 60 is good enough but still strange results come up.  
Besides that, when I operate on a single mode with two different states and then compute the scalar product the outcome does obey the classical equation  
Is it because it is a mixed state?  
I will be more than happy if you set me up on the road to understand quantum optics. My basic background is microwave engineering and 8.05 courses about quantum mechanics from MIT besides qml.  
Thanks again 😍

---

<div class="post-metadata">

**Author:** ![nathan](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nathan/32/85_2.png) [@nathan](https://discuss.pennylane.ai/u/nathan)\
**Post date:** [September 13, 2019, 4:55pm UTC](https://discuss.pennylane.ai/t/strange-behaviour-from-displaced-squeezed-states/207/8 "2019-09-13T16:55:58Z")

</div>

Hi @kareem_essafty,

Only for the simplest states are there easy formulas to determine the overlap of the state with various Fock-basis states. For example, the overlap of a coherent state \langle \alpha | n \rangle (displacement applied to vacuum) with the Fock state |n\rangle is e^{-\frac{|\alpha|^2}{2}}\frac{\alpha}{\sqrt{n}}. With this, you can estimate what value of cutoff n would make this small.

However, for anything beyond the basic states, the formulas are either known but complex, or simply unknown. For example, check out the formula for a squeezed displaced state. Other than numerically calculating, I don’t know a way to easily invert this and estimate a safe value of cutoff n.

Honestly, the best approach is to experiment numerically with the simulator, since it can give you quick feedback. Start with small values and circuits, and only if you are confident that the cutoff is not an issue should you increase parameter values and circuit depth. A preferred approach is to regularize values so they can’t become too big.
