{"id":22891906,"url":"https://github.com/stephenhky/pyqentangle","last_synced_at":"2025-12-24T07:28:45.063Z","repository":{"id":12739690,"uuid":"72043361","full_name":"stephenhky/pyqentangle","owner":"stephenhky","description":"Quantum Entanglement in Python","archived":false,"fork":false,"pushed_at":"2025-04-20T04:16:26.000Z","size":3828,"stargazers_count":20,"open_issues_count":2,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-20T05:22:24.769Z","etag":null,"topics":["numerical-methods","package","physics","python","python-library","quantum-entanglement","schmidt-decomposition"],"latest_commit_sha":null,"homepage":"http://pyqentangle.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stephenhky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-10-26T20:51:14.000Z","updated_at":"2025-04-17T13:06:41.000Z","dependencies_parsed_at":"2023-10-13T16:39:06.986Z","dependency_job_id":"e2f502bc-4bae-4ed8-b16e-a070a5864d60","html_url":"https://github.com/stephenhky/pyqentangle","commit_stats":{"total_commits":301,"total_committers":4,"mean_commits":75.25,"dds":0.1129568106312292,"last_synced_commit":"c7090b0502f217a4e95af4d5ce890de3b4bd2f81"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenhky%2Fpyqentangle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenhky%2Fpyqentangle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenhky%2Fpyqentangle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenhky%2Fpyqentangle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephenhky","download_url":"https://codeload.github.com/stephenhky/pyqentangle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252923655,"owners_count":21825904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["numerical-methods","package","physics","python","python-library","quantum-entanglement","schmidt-decomposition"],"created_at":"2024-12-13T22:45:53.147Z","updated_at":"2025-12-24T07:28:44.997Z","avatar_url":"https://github.com/stephenhky.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quantum Entanglement in Python\n\n[![CircleCI](https://circleci.com/gh/stephenhky/pyqentangle.svg?style=svg)](https://circleci.com/gh/stephenhky/pyqentangle.svg)\n[![GitHub release](https://img.shields.io/github/release/stephenhky/pyqentangle.svg?maxAge=3600)](https://github.com/stephenhky/pyqentangle/releases)\n[![Documentation Status](https://readthedocs.org/projects/pyqentangle/badge/?version=latest)](https://pyqentangle.readthedocs.io/en/latest/?badge=latest)\n[![Updates](https://pyup.io/repos/github/stephenhky/pyqentangle/shield.svg)](https://pyup.io/repos/github/stephenhky/pyqentangle/)\n[![Python 3](https://pyup.io/repos/github/stephenhky/pyqentangle/python-3-shield.svg)](https://pyup.io/repos/github/stephenhky/pyqentangle/)\n[![pypi](https://img.shields.io/pypi/v/pyqentangle.svg?maxAge=3600)](https://pypi.org/project/pyqentangle/)\n[![download](https://img.shields.io/pypi/dm/pyqentangle.svg?maxAge=2592000\u0026label=installs\u0026color=%2327B1FF)](https://pypi.org/project/pyqentangle/)\n\n## Version\n\nThe releases of `pyqentangle` 2.x.x is incompatible with previous releases.\n\nThe releases of `pyqentangle` 3.x.x is incompatible with previous releases.\n\nSince release 3.1.0, the support for Python 2 was decomissioned.\n\n## Installation\n\nThis package can be installed using `pip`.\n\n```\n\u003e\u003e\u003e pip install pyqentangle\n```\n\nTo use it, enter\n\n```\n\u003e\u003e\u003e import pyqentangle\n\u003e\u003e\u003e import numpy as np\n```\n\n## Schmidt Decomposition for Discrete Bipartite States\n\nWe first express the bipartite state in terms of a tensor. For example, if the state is `|01\u003e+|10\u003e`, then express it as\n\n```\n\u003e\u003e\u003e tensor = np.array([[0., np.sqrt(0.5)], [np.sqrt(0.5), 0.]])\n```\n\nTo perform the Schmidt decompostion, just enter:\n\n```\n\u003e\u003e\u003e pyqentangle.schmidt_decomposition(tensor)\n[(0.7071067811865476, array([ 0., -1.]), array([-1., -0.])),\n (0.7071067811865476, array([-1.,  0.]), array([-0., -1.]))]\n ```\n\nFor each tuple in the returned list, the first element is the Schmidt coefficients, the second the component for first subsystem, and the third the component for the second subsystem.\n\n## Schmidt Decomposition for Continuous Bipartite States\n\nWe can perform Schmidt decomposition on continuous systems too. For example, define the following normalized wavefunction:\n\n```\n\u003e\u003e\u003e fcn = lambda x1, x2: np.exp(-0.5 * (x1 + x2) ** 2) * np.exp(-(x1 - x2) ** 2) * np.sqrt(np.sqrt(8.) / np.pi)\n```\n\nThen perform the Schmidt decomposition, \n\n```\n\u003e\u003e\u003e modes = pyqentangle.continuous_schmidt_decomposition(biwavefcn, -10., 10., -10., 10., keep=10)\n```\n\nwhere 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:\n\n```\n\u003e\u003e\u003e list(map(lambda dec: dec[0], modes))\n[0.9851714310094161,\n 0.1690286950361957,\n 0.02900073920775954,\n 0.004975740210361192,\n 0.0008537020544076649,\n 0.00014647211608480773,\n 2.51306421011773e-05,\n 4.311736522272035e-06,\n 7.39777032460608e-07,\n 1.2692567250688184e-07]\n```\n\nThe second and the third elements in each tuple in the list `decompositions` are lambda functions for the modes of susbsystems A and B respectively. The Schmidt functions can be plotted:\n```\n\u003e\u003e\u003e xarray = np.linspace(-10., 10., 100)\n\n    plt.subplot(3, 2, 1)\n    plt.plot(xarray, modes[0][1](xarray))\n    plt.subplot(3, 2, 2)\n    plt.plot(xarray, modes[0][2](xarray))\n\n    plt.subplot(3, 2, 3)\n    plt.plot(xarray, modes[1][1](xarray))\n    plt.subplot(3, 2, 4)\n    plt.plot(xarray, modes[1][2](xarray))\n\n    plt.subplot(3, 2, 5)\n    plt.plot(xarray, modes[2][1](xarray))\n    plt.subplot(3, 2, 6)\n    plt.plot(xarray, modes[2][2](xarray))\n```\n\n![alt](https://github.com/stephenhky/pyqentangle/raw/master/fig/three_harmonic_modes.png)\n\n\n## Useful Links\n\n* Study of Entanglement in Quantum Computers: [https://datawarrior.wordpress.com/2017/09/20/a-first-glimpse-of-rigettis-quantum-computing-cloud/](https://datawarrior.wordpress.com/2017/09/20/a-first-glimpse-of-rigettis-quantum-computing-cloud/)\n* Github page: [https://github.com/stephenhky/pyqentangle](https://github.com/stephenhky/pyqentangle)\n* PyPI page: [https://pypi.python.org/pypi/pyqentangle/](https://pypi.python.org/pypi/pyqentangle/)\n* Documentation: [http://pyqentangle.readthedocs.io/](http://pyqentangle.readthedocs.io/)\n* RQEntangle: [https://CRAN.R-project.org/package=RQEntangle](https://CRAN.R-project.org/package=RQEntangle) (corresponding R library)\n\n## Reference\n* Artur Ekert, Peter L. Knight, \"Entangled quantum systems and the Schmidt decomposition\", *Am. J. Phys.* 63, 415 (1995).\n\n## Acknowledgement\n* [Hossein Seifoory](https://ca.linkedin.com/in/hosseinseifoory?trk=public_profile_card_url)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenhky%2Fpyqentangle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenhky%2Fpyqentangle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenhky%2Fpyqentangle/lists"}