.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/optics/quantum_optics/plot_coherent_state_statistics.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_optics_quantum_optics_plot_coherent_state_statistics.py: Glauber's coherent states: displaced vacuum, Poissonian statistics ======================================================================== Roy Glauber identified the coherent states :math:`|\alpha\rangle` -- eigenstates of the annihilation operator, :math:`\hat a|\alpha\rangle = \alpha|\alpha\rangle` -- as the quantum states that most closely reproduce a classical, stable-amplitude light wave: a positive Gaussian in phase space, displaced away from the origin, whose photon number follows a Poissonian distribution -- the quantum-mechanical signature of what an ideal, shot-noise-limited laser beam actually is. :func:`~physicskit.optics.quantum_optics.coherent_state` constructs this state directly in a truncated Fock basis (dimension ``cutoff``), .. math:: \lvert\alpha\rangle = e^{-\lvert\alpha\rvert^2/2} \sum_{n=0}^{\infty} \frac{\alpha^n}{\sqrt{n!}}\,\lvert n\rangle, for use with :func:`~physicskit.optics.quantum_optics.compute_wigner_function` and any of the package's other state-based quantum-optics tools. Below, :math:`\alpha = 2+i` (mean photon number :math:`\langle n\rangle = |\alpha|^2 = 5`) is used to compute both the phase-space Wigner function :math:`W(x,p)` and the photon-number distribution :math:`P(n) = |\langle n|\alpha\rangle|^2`. .. GENERATED FROM PYTHON SOURCE LINES 27-33 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from physicskit.optics.quantum_optics import coherent_state, compute_wigner_function .. GENERATED FROM PYTHON SOURCE LINES 34-36 A coherent state :math:`|\alpha\rangle`, its phase-space blob and photon statistics ------------------------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 36-50 .. code-block:: Python cutoff = 30 alpha = 2.0 + 1.0j psi = coherent_state(alpha, cutoff) n = np.arange(cutoff) P_n = np.abs(psi) ** 2 mean_n = np.sum(n * P_n) var_n = np.sum(n**2 * P_n) - mean_n**2 x = np.linspace(-6, 6, 121) p = np.linspace(-6, 6, 121) W = compute_wigner_function(psi, x, p) .. GENERATED FROM PYTHON SOURCE LINES 51-54 A coherent state's Wigner function is a Gaussian bump displaced from the origin (never negative), and its photon-number distribution is Poissonian: mean and variance both equal :math:`|\alpha|^2`. .. GENERATED FROM PYTHON SOURCE LINES 54-71 .. code-block:: Python fig, axes = plt.subplots(1, 2, figsize=(9, 4)) axes[0].contourf(x, p, W.T, levels=40, cmap="RdBu_r") axes[0].set_title(r"$W(x,p)$ for a displaced coherent state") axes[0].set_xlabel("x") axes[0].set_ylabel("p") axes[1].bar(n, P_n) axes[1].axvline(mean_n, color="r", ls="--", label=r"$\langle n\rangle=|\alpha|^2$") axes[1].set_title("Poissonian photon-number distribution") axes[1].set_xlabel("n") axes[1].legend() fig.tight_layout() print(f"alpha = {alpha}, |alpha|^2 = {abs(alpha) ** 2:.4f}") print(f"measured = {mean_n:.4f} measured Var(n) = {var_n:.4f}") print("Poissonian statistics: = Var(n) = |alpha|^2, confirmed above.") print(f"minimum of W(x,p) over the grid: {W.min():.6f} (non-negative: classical state)") .. image-sg:: /api/gallery/optics/quantum_optics/images/sphx_glr_plot_coherent_state_statistics_001.png :alt: $W(x,p)$ for a displaced coherent state, Poissonian photon-number distribution :srcset: /api/gallery/optics/quantum_optics/images/sphx_glr_plot_coherent_state_statistics_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none alpha = (2+1j), |alpha|^2 = 5.0000 measured = 5.0000 measured Var(n) = 5.0000 Poissonian statistics: = Var(n) = |alpha|^2, confirmed above. minimum of W(x,p) over the grid: -0.000000 (non-negative: classical state) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.327 seconds) .. _sphx_glr_download_api_gallery_optics_quantum_optics_plot_coherent_state_statistics.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_coherent_state_statistics.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_coherent_state_statistics.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_coherent_state_statistics.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_