{"id":8576,"library":"qutip","title":"QuTiP: The Quantum Toolbox in Python","description":"QuTiP is an open-source Python library for simulating the dynamics of closed and open quantum systems. It provides user-friendly and efficient numerical simulations for a wide range of quantum mechanical problems, including those with arbitrary time-dependence, commonly found in quantum optics, trapped ions, superconducting circuits, and quantum nanomechanical resonators. The library, currently at version 5.2.3, is built upon NumPy, SciPy, and Cython for numerical backends and Matplotlib for graphical output, with regular minor and patch releases, and significant major updates.","status":"active","version":"5.2.3","language":"en","source_language":"en","source_url":"https://github.com/qutip/qutip","tags":["quantum computing","quantum mechanics","quantum optics","numerical simulation","physics","scientific computing"],"install":[{"cmd":"pip install qutip","lang":"bash","label":"Minimal installation"},{"cmd":"pip install qutip[full]","lang":"bash","label":"With all optional dependencies"}],"dependencies":[{"reason":"Numerical backend","package":"numpy"},{"reason":"Numerical backend","package":"scipy"},{"reason":"Numerical backend for performance","package":"cython"},{"reason":"Graphical output and visualization","package":"matplotlib"},{"reason":"For quantum information processing functionality (moved from core library in v5)","package":"qutip-qip","optional":true},{"reason":"For quantum optimal control (legacy, `qutip-qoc` is newer)","package":"qutip-qtrl","optional":true},{"reason":"JAX backend for QuTiP (provides JAX-based data formats)","package":"qutip-jax","optional":true}],"imports":[{"note":"While `from qutip import *` is shown in some older tutorials, `import qutip as qt` is generally recommended for clarity and to avoid polluting the namespace.","wrong":"from qutip import *","symbol":"qutip","correct":"import qutip as qt"},{"note":"Qobj is the core class for quantum objects (states and operators).","symbol":"Qobj","correct":"from qutip import Qobj\n# or qt.Qobj if 'import qutip as qt' is used"}],"quickstart":{"code":"import qutip as qt\n\n# Create a basis state |0> for a two-level system\nket0 = qt.basis(2, 0)\nprint(f\"Ket |0>:\\n{ket0}\")\n\n# Create a Pauli sigma-x operator\nsigmax = qt.sigmax()\nprint(f\"Sigma-x operator:\\n{sigmax}\")\n\n# Apply the operator to the state\nket1 = sigmax * ket0\nprint(f\"Sigma-x applied to |0> (gives |1>):\\n{ket1}\")\n\n# Calculate expectation value\nexp_val = qt.expect(sigmax, ket0)\nprint(f\"Expectation value of sigma-x in |0>: {exp_val}\")","lang":"python","description":"This quickstart demonstrates creating basic quantum objects (ket states and operators) and performing fundamental operations like applying an operator to a state and calculating an expectation value."},"warnings":[{"fix":"Consult the official migration guide for QuTiP 4 to 5. Key changes include how `QobjEvo` attributes are accessed, the return type of bra-ket multiplication, and explicit conversion to NumPy arrays using `Qobj.full()` instead of implicit conversion.","message":"QuTiP 5.x introduced significant breaking changes from 4.x, particularly in the core `Qobj`, `QobjEvo`, and solver implementations.","severity":"breaking","affected_versions":"4.x users migrating to 5.x"},{"fix":"Install the respective standalone packages (e.g., `pip install qutip-qip`) and update import statements. For example, `from qutip.qip import QubitCircuit` becomes `from qutip_qip import QubitCircuit` or `from qutip.qip import QubitCircuit` after installing `qutip-qip`.","message":"The `qutip.qip` and `qutip.control` modules have been moved out of the core `qutip` library into separate packages (`qutip-qip`, `qutip-qtrl`, `qutip-qoc`).","severity":"breaking","affected_versions":"5.0.0 and later"},{"fix":"Always verify convergence by increasing the number of states and observing if the results change significantly. Plotting the error as a function of system size can help determine an appropriate truncation.","message":"Using an insufficient number of states (truncation) in simulations, especially for time-evolution of open quantum systems or harmonic oscillators, can lead to inaccurate or incorrect results at later times.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Carefully examine the physical validity of results from `steadystate()` if the system is known to have such pathologies. Consider checking the eigenvalues of the Liouvillian for multiple zero eigenvalues, though this can be computationally costly.","message":"The `steadystate()` solver in older QuTiP versions sometimes produced pivot errors for systems with ill-defined steady states (e.g., dissipationless dark states or multiple steady states). While newer versions might avoid the explicit error, they could silently return a 'nonsense' result.","severity":"gotcha","affected_versions":"All versions, more pronounced as silent failure in newer versions (5.x)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"If your code expects a `Qobj` and attempts to index it, remove the indexing. The result of `bra * ket` is directly the scalar complex number. If you need the complex value, use it directly (e.g., `value = bra * ket`).","cause":"In QuTiP v5.x, the multiplication of a bra `Qobj` with a ket `Qobj` now returns a scalar (a Python `complex` number) instead of a zero-dimensional `Qobj`. Attempting to index this scalar (e.g., `result[0][0]`) will raise this error.","error":"TypeError: 'complex' object is not subscriptable"},{"fix":"Instead of direct attribute access, evaluate the `QobjEvo` object at a specific time step by calling it like a function, e.g., `quobjevo(t)`. Most metadata (dims, shape) can be obtained from its properties directly.","cause":"In QuTiP 5.x, direct access to individual Hamiltonian elements through `QobjEvo.ops` and `QobjEvo.cte` attributes has been removed as part of the core redesign.","error":"AttributeError: 'QobjEvo' object has no attribute 'ops' / 'cte'"},{"fix":"When comparing `Qobj` instances or their NumPy array representations using functions like `numpy.testing.assert_allclose`, explicitly convert the `Qobj` to a NumPy array using the `.full()` method: `qobj.full()`.","cause":"QuTiP 5.x no longer implicitly converts `Qobj` instances to NumPy arrays using `numpy.array(qobj)`. This change prevents silent data type transformations.","error":"Object passed to assert_allclose is not an array."}]}