XanaduAI / thewalrus

A library for the calculation of hafnians, Hermite polynomials and Gaussian boson sampling.
https://the-walrus.readthedocs.io
Apache License 2.0
101 stars 55 forks source link

P ( [ ℓ ] ) is not defined. Is it the power set of (0, 1, ...l-1)? #242

Closed yu289333 closed 3 years ago

yu289333 commented 3 years ago

Before posting an issue

Search existing GitHub issues to make sure the issue does not already exist: https://github.com/XanaduAI/thewalrus/issues

If posting a library issue, delete everything above the dashed line, and fill in the template.

If making a feature request, delete the following template and describe, in detail, the feature and why it is needed.

For general technical details check out our documentation: https://the-walrus.readthedocs.io


Issue description

Description of the issue - include code snippets and screenshots here if relevant. You may use the following template below

Source code and tracebacks

Please include any additional code snippets and error tracebacks related to the issue here.

Additional information

Any additional information, configuration or data that might be necessary to reproduce the issue.

nquesada commented 3 years ago

HI @yu289333 --- You are correct, P([l]) is the power set of the first l integers. Where it is not defined?

yu289333 commented 3 years ago

Then |S| is the number of elements in set S? Thank you so much for explaining.

nquesada commented 3 years ago

Correct.

yu289333 commented 3 years ago

Sorry for asking all the questions. I'm on the physics side and am overwhelmed by all the math. For N=2, and vector_n = {1, 0}, O{n} should be a 2x2 matrix, it's not possible to go over S∈P([ℓ]), right? Where do I get wrong?

yu289333 commented 3 years ago

For a Two Mode Squeezed State (TMSS), the probability of the |0>0> Fock state is 1-[tanh(r)]^2. I'm having trouble verifying with the torontorian result for vector_n={0,0}

yu289333 commented 3 years ago

And for vector_n={0,1} and {1,0}, the probability is (x-1)/x.(x+ln(1-x)) where x=[tanh(r)]^2. I hope to compare with the torontorian result.

nquesada commented 3 years ago

Hi --- The easiest way to calculate these probabilities is to use threshold_detection_prob. For a two mode squeezed vacuum state you can do

import numpy as np
from thewalrus.symplectic import two_mode_squeezing
from thewalrus._torontonian import threshold_detection_prob

n_mean =  np.arcsinh(1.0)
cov = two_mode_squeezing(2*n_mean, 0)
mean = np.zeros([4])
patterns = [[0,0], [0,1], [1,0], [1,1]]
probs = [threshold_detection_prob(mean, cov, pat) for pat in patterns]
for i, pat in enumerate(patterns):
    print("The probability of the event "+str(pat)+" is "+str(probs[i]))

to get

The probability of the event [0, 0] is (0.4999999999999999+0j) The probability of the event [0, 1] is (1.1102230246251563e-16+0j) The probability of the event [1, 0] is (1.1102230246251563e-16+0j) The probability of the event [1, 1] is (0.5000000000000001+0j)

As for your question

Sorry for asking all the questions. I'm on the physics side and am overwhelmed by all the math. For N=2, and vector_n = {1, 0}, O{n} should be a 2x2 matrix, it's not possible to go over S∈P([ℓ]), right? Where do I get wrong?

in that case [ℓ] = [2] = [0,1] and the P[ℓ] = [[], [0], [1], [0,1]]

yu289333 commented 3 years ago

Thanks. I forgot to mention that my trouble is to calculate the results of TMSS photons going through a symmetric beam splitter to compare with the original Hong-Ou-Mandel experiment.

nquesada commented 3 years ago

You can generate the relevant covariance matrices either using the symplectic module or Strawberry Fields. Once you have the covariance matrix you can pass them to threshold_detection_prob as above.