Closed nquesada closed 4 years ago
Merging #371 into master will increase coverage by
0.00%
. The diff coverage isn/a
.
@@ Coverage Diff @@
## master #371 +/- ##
=======================================
Coverage 97.69% 97.70%
=======================================
Files 52 52
Lines 6478 6485 +7
=======================================
+ Hits 6329 6336 +7
Misses 149 149
Impacted Files | Coverage Δ | |
---|---|---|
strawberryfields/ops.py | 99.00% <ø> (ø) |
|
strawberryfields/api/connection.py | 100.00% <0.00%> (ø) |
|
strawberryfields/api/job.py | 94.11% <0.00%> (+0.93%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 5917bac...d7ab1bb. Read the comment docs.
So the one on the conventions page is the correct convention employed by SF? https://strawberryfields.readthedocs.io/en/stable/code/api/strawberryfields.ops.S2gate.html
The correct convention is S^2(z) = \exp( z a_1^\dagger a_2^\dagger - H.c.) with z = r e^{i \theta}. To verify this is the case one can calculate <1,1|S^2(z)|0,0> = tanh(r) e^{i \theta} /cosh(r)
Here is a simple code that checks that:
eng = sf.LocalEngine(backend="fock",backend_options={"cutoff_dim": 6})
width = 2
circuit = sf.Program(width)
z = 0.5*np.exp(1j*np.pi/6)
r = np.abs(z)
theta = np.angle(z)
with circuit.context as q:
ops.S2gate(r,theta)|(q[0],q[1])
x = eng.run(circuit)
state = x.state
state.ket()[1,1], np.tanh(r)*np.exp(1j*theta)/np.cosh(r)
giving
((0.3549095267938162+0.20490711083237245j),
(0.35490952679381627+0.20490711083237248j))
as expected.
The one in https://strawberryfields.readthedocs.io/en/stable/code/api/strawberryfields.ops.S2gate.html is incorrect. A likely cause of confusion is that we define the S gate as S(z) = \exp( -z a^\dagger/2 -H.c.) and thus one would hope that S^(2)(z) is defined as \exp(-z a1^\dagger a^\dagger - H.c.). All of this in turn I think goes back to how Eqs. 31 and 33 of here https://arxiv.org/pdf/1110.3234.pdf are incosistent.
Thanks. Can you update the error also in sf.ops.S2gate
docstring?
No problem.
Fixes wrong sign of two-mode squeezing gate in docs