Skip to main content

Quantum Entanglement in Python

Project description

Quantum Entanglement in Python

CircleCI GitHub release Documentation Status Updates Python 3 pypi download

Version

The releases of pyqentangle 2.x.x are incompatible with previous releases.

The releases of pyqentangle 3.x.x are incompatible with previous releases.

The releases of pyqentangle 5.x.x are incompatible with previous releases.

Since release 3.1.0, the support for Python 2 was decomissioned.

Installation

This package can be installed using pip.

>>> pip install pyqentangle

To use it, enter

>>> import pyqentangle
>>> import numpy as np

Schmidt Decomposition for Discrete Bipartite States

We first express the bipartite state in terms of a tensor. For example, if the state is |01>+|10>, then express it as

>>> tensor = np.array([[0., np.sqrt(0.5)], [np.sqrt(0.5), 0.]])

To perform the Schmidt decompostion, just enter:

>>> pyqentangle.DiscreteSchmidtDecomposer(tensor).modes()
[DiscreteSchmidtMode(schmidt_coef=np.float64(0.7071067811865476), mode1=array([ 0., -1.]), mode2=array([-1., -0.])),
 DiscreteSchmidtMode(schmidt_coef=np.float64(0.7071067811865476), mode1=array([-1.,  0.]), mode2=array([-0., -1.]))]

In the returned list, for each element, there are the Schmidt coefficient, the component for first subsystem, and that for the second subsystem.

Schmidt Decomposition for Continuous Bipartite States

We can perform Schmidt decomposition on continuous systems too. For example, define the following normalized wavefunction:

>>> bipartite_wavefcn = pyqentangle.core.wavefunctions.AnalyticMultiDimWaveFunction(
        lambda x: np.exp(-0.5 * (x[0] + x[1]) ** 2) * np.exp(-(x[0] - x[1]) ** 2) * np.sqrt(np.sqrt(8.) / np.pi)
    )

Then perform the Schmidt decomposition,

>>> modes = pyqentangle.ContinuousSchmidtDecomposer(bipartite_wavefcn, -10., 10., -10., 10., keep=10).modes()
>>> modes
[ContinuousSchmidtMode(schmidt_coef=np.float64(0.9851714310094161), wavefunction1=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd9a0f50>, wavefunction2=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd0d4f80>),
 ContinuousSchmidtMode(schmidt_coef=np.float64(0.1690286950361957), wavefunction1=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa8582d7dd0>, wavefunction2=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd15e350>),
 ContinuousSchmidtMode(schmidt_coef=np.float64(0.029000739207759557), wavefunction1=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd0d2cf0>, wavefunction2=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd0d1240>),
 ContinuousSchmidtMode(schmidt_coef=np.float64(0.004975740210361184), wavefunction1=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd4393d0>, wavefunction2=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd4394f0>),
 ContinuousSchmidtMode(schmidt_coef=np.float64(0.0008537020544076699), wavefunction1=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd439550>, wavefunction2=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd439670>),
 ContinuousSchmidtMode(schmidt_coef=np.float64(0.0001464721160848057), wavefunction1=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd4396d0>, wavefunction2=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd4397f0>),
 ContinuousSchmidtMode(schmidt_coef=np.float64(2.5130642101174655e-05), wavefunction1=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd439850>, wavefunction2=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd439970>),
 ContinuousSchmidtMode(schmidt_coef=np.float64(4.311736522271967e-06), wavefunction1=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd4399d0>, wavefunction2=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd439af0>),
 ContinuousSchmidtMode(schmidt_coef=np.float64(7.397770324567384e-07), wavefunction1=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd439b50>, wavefunction2=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd439c70>),
 ContinuousSchmidtMode(schmidt_coef=np.float64(1.2692567250818081e-07), wavefunction1=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd439cd0>, wavefunction2=<pyqentangle.core.wavefunctions.InterpolatingWaveFunction object at 0x7fa6dd439df0>)]

where it describes the ranges of x1 and x2 respectively, and keep=10 specifies only top 10 Schmidt modes are kept. Then we can read the Schmidt coefficients:

>>> from matplotlib import pyplot as plt
>>> [mode.schmidt_coef for mode in modes]
[np.float64(0.9851714310094161),
 np.float64(0.1690286950361957),
 np.float64(0.029000739207759557),
 np.float64(0.004975740210361184),
 np.float64(0.0008537020544076699),
 np.float64(0.0001464721160848057),
 np.float64(2.5130642101174655e-05),
 np.float64(4.311736522271967e-06),
 np.float64(7.397770324567384e-07),
 np.float64(1.2692567250818081e-07)]

The Schmidt functions can be plotted:

>>> xarray = np.linspace(-10., 10., 100)

    plt.subplot(3, 2, 1)
    plt.plot(xarray, modes[0].wavefunction1(xarray))
    plt.subplot(3, 2, 2)
    plt.plot(xarray, modes[0].wavefunction2(xarray))

    plt.subplot(3, 2, 3)
    plt.plot(xarray, modes[1].wavefunction1(xarray))
    plt.subplot(3, 2, 4)
    plt.plot(xarray, modes[1].wavefunction2(xarray))

    plt.subplot(3, 2, 5)
    plt.plot(xarray, modes[2].wavefunction1(xarray))
    plt.subplot(3, 2, 6)
    plt.plot(xarray, modes[2].wavefunction2(xarray))

alt

Useful Links

Reference

  • Artur Ekert, Peter L. Knight, "Entangled quantum systems and the Schmidt decomposition", Am. J. Phys. 63, 415 (1995).

Acknowledgement

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqentangle-5.0.1.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyqentangle-5.0.1-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file pyqentangle-5.0.1.tar.gz.

File metadata

  • Download URL: pyqentangle-5.0.1.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyqentangle-5.0.1.tar.gz
Algorithm Hash digest
SHA256 121de709f1a65b9f3a2000a2db8500fa050fb4a7d9f4d82e10d24f9d17f38873
MD5 99bb0c6217367a2e6f6be78c739ad0de
BLAKE2b-256 133308ff93f71de35cf472c940618917e2413bb4b6d92778193004885869bbba

See more details on using hashes here.

File details

Details for the file pyqentangle-5.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyqentangle-5.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyqentangle-5.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c0a544a633444466add809d95b3cac339ef3b9a638e73d098fd150d158ca1301
MD5 f565b718ff7a109d1b1c6051c652a8e6
BLAKE2b-256 75ccef5ced5e1d2690fdbff730a5d35e7c38a8b454f4bde36daf4ecb1a423d9c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page