Expectation value of transition projection operator

Hi, is there a function in StrawberryFields that can compute the expectation value of the Fock basis operator like | m \rangle \langle n |? I understand that the expectation value of | n \rangle \langle n | operator can be computed using the fock_prob function, but it does not generalize to the case when m \neq n.


Hey @rishab.dutta! Welcome to the forum :slight_smile:

Can you maybe brute-force it by using BaseFockState.ket and picking out the correct elements? Let me know if that helps!

Hi @isaacdevlugt, thanks for your reply! Yes, I was aware of this brute-force approach but sought a more hardware-native alternative. Related to your suggestion, I also found the sf.ops.Ket operator. I wonder if that can be augmented with a corresponding Bra operator to make an operator function for a general Hermitian operator |m \rangle \langle n | + h.c.. Is that something we can expect in a future implementation? Thanks!

Strawberryfields is currently in maintenance mode, meaning that we’ll fix bugs but won’t be adding new features at this time. Any solution there is going to be something brute-forced or something that you add to a local copy of Strawberryfields (i.e., cloning the Github repo, modifying the strawberryfields source code to your liking and installing strawberryfields from your modified local version to access your changes).

You could look at the source code for sf.ops.Ket and make a sf.ops.Bra operator as you suggested. Then in principle you can stitch those two operators together to create the observable you want to measure :). Sorry there’s not an easier way! Let me know if this helps :slight_smile: