Computational Notebooks
This page is the notebook index and reproducibility contract for composite systems and entanglement. It specifies what each notebook should compute, which conventions it must state, and which checks must pass before the notebook should be treated as a reliable teaching or reference artifact.
At this draft stage, the entries below are specifications rather than downloadable notebook links. When notebook files are added, they should live under a stable path such as notebooks/composite-systems/, preserve these validation checks, and link back to the canonical explanatory pages.
What This Page Owns
Section titled “What This Page Owns”This page owns the computational contract for small, transparent notebooks in this volume. It does not own the derivations of tensor products, partial traces, Schmidt decomposition, entanglement entropy, or second quantization. Those stay in their canonical pages and are linked below.
The notebook suite should emphasize reproducible understanding:
- state the basis ordering before constructing arrays;
- print dimensions of vectors, matrices, and reshaped tensors;
- check normalization, Hermiticity, trace preservation, and eigenvalue sanity;
- compare numerical outputs to analytic formulas from the text;
- avoid hidden high-level library calls for the core operation being taught;
- expose small parameters that readers can change without rewriting the notebook.
Shared Conventions
Section titled “Shared Conventions”Unless a notebook explicitly states otherwise, two-qubit vectors use the product basis
with subsystem written first and subsystem second. If , the array index is
For qubits in this convention,
This is a big-endian convention for displayed bit strings. Other conventions are legitimate, but a notebook must state the convention before using compact labels.
Density matrices are represented as square arrays in the same product-basis order. A two-qubit density matrix can be reshaped as
The partial trace over is then the index contraction
Required Validation Checks
Section titled “Required Validation Checks”Every notebook that constructs a state or density operator should include the relevant subset of these checks:
Density-operator eigenvalues should be nonnegative up to numerical tolerance:
where is a stated roundoff tolerance, not an unexamined escape hatch.
Reduced states should preserve trace:
Pure-state Schmidt coefficients should satisfy
For fermionic notebooks, the creation and annihilation matrices should satisfy
The notebook should print the maximum residual norm for these identities. A result that is “visually close” in a matrix display is not enough.
Core Notebook Suite
Section titled “Core Notebook Suite”| Notebook specification | Canonical filename | Main computation | Required checks | Canonical pages |
|---|---|---|---|---|
| Tensor-product basis ordering | tensor-product-basis-ordering.ipynb | Build two- and three-qubit bases; construct local Pauli operators | Dimensions, index map, local-operator commutators | Product Bases |
| Partial trace for two qubits | partial-trace-two-qubits.ipynb | Reduce product, Bell, and classically correlated states | Trace preservation, Hermiticity, local expectation values | Partial Trace |
| Schmidt decomposition by SVD | schmidt-decomposition-svd.ipynb | Reshape a pure-state vector into a coefficient matrix and compute singular values | Reconstruction error, normalized singular values, entropy comparison | Schmidt Decomposition |
| Bell-state correlations | bell-states-correlations.ipynb | Compute Pauli correlation matrices and reduced states for Bell states | Orthonormality, one-qubit reductions, correlation signs | Bell States |
| Small-system entanglement entropy | entanglement-entropy-spin-chain-small.ipynb | Diagonalize small spin chains and compute subsystem entropies | Normalization, trace preservation, entropy benchmarks | Entanglement in Many-Body Physics |
| Fermionic signs and Jordan-Wigner preview | fermionic-signs-jordan-wigner-preview.ipynb | Build occupation basis and fermionic ladder operators | Anticommutators, sign conventions, number eigenvalues | Fermionic Anticommutation Relations |
| Small second-quantized Hamiltonian | second-quantized-hamiltonian-small-basis.ipynb | Build a two-site Hubbard-style Hamiltonian in fixed particle sectors | Hermiticity, particle-number conservation, sector dimensions | Many-Particle Hamiltonians |
Tensor-Product Basis Ordering Notebook
Section titled “Tensor-Product Basis Ordering Notebook”This notebook should begin with arrays, not abstractions. For two qubits, list the basis states, array indices, and subsystem labels in a table:
Then construct local Pauli operators as
The notebook should verify that operators on different subsystems commute:
It should also show one failure mode: if the basis ordering is silently changed, an array with the same numerical entries can represent a different physical operator.
Partial-Trace Notebook
Section titled “Partial-Trace Notebook”The partial-trace notebook should compute reduced states in three examples:
- a product pure state;
- a Bell state;
- a classically correlated separable mixed state.
For the plus Bell state,
the notebook should obtain
For the classically correlated state
the same local reductions occur, but the joint state is separable. This is a mandatory comparison: it prevents the common mistake of using mixed marginals as a mixed-state entanglement test.
The notebook should verify local statistics by comparing
with
for several one-qubit observables .
Schmidt-SVD Notebook
Section titled “Schmidt-SVD Notebook”For a pure vector
the notebook should reshape the state into the coefficient matrix and compute its singular-value decomposition:
The diagonal entries of are the Schmidt coefficients. The notebook should reconstruct the state and report the residual
It should compare the entropy computed from singular values,
with the entropy computed from eigenvalues of the reduced density operator .
Useful test cases:
- a product state, with one singular value equal to one;
- a Bell state, with two singular values equal to ;
- a random normalized two-qubit state, with results checked by reconstruction.
Bell-Correlations Notebook
Section titled “Bell-Correlations Notebook”The Bell-correlation notebook should compute the matrix
for each Bell state. It should also compute the one-qubit Bloch vectors and show that they vanish for all Bell states:
This makes the distinction between local randomness and joint correlation explicit. It also gives a numerical bridge to Bell measurements, correlation tensors, witnesses, and foundations examples.
Small-System Entanglement-Entropy Notebook
Section titled “Small-System Entanglement-Entropy Notebook”The spin-chain entropy notebook should stay small enough that a reader can inspect the arrays. A good first target is a few qubits with a Hamiltonian such as
with open boundary conditions and small. The notebook should diagonalize , choose a low-energy state, trace out part of the chain, and compute
Validation should include benchmark states whose entropy is known before diagonalization:
- a product state, with for every cut;
- a Bell pair crossing the cut, with ;
- a GHZ state, with one bit or one nat depending on logarithm base;
- a classically correlated mixed state, used only to show why mixed-state entropy is not automatically entanglement entropy.
The notebook should state the logarithm base and label entropy units.
Fermionic-Signs Notebook
Section titled “Fermionic-Signs Notebook”The fermionic-sign notebook should build an occupation basis for modes, such as
With canonical mode order , the annihilation operator acts as
where
The creation operator is similar, with replaced by . The notebook should verify anticommutation relations as matrix identities and show how Jordan-Wigner strings implement the same signs in a qubit representation.
This notebook should not present the Jordan-Wigner transformation as a full many-body algorithm. It is a sign-convention preview that prepares readers for later computational and many-body treatments.
Second-Quantized Hamiltonian Notebook
Section titled “Second-Quantized Hamiltonian Notebook”The small-Hamiltonian notebook should construct a finite basis and a Hamiltonian such as a two-site spinful Hubbard model:
It should build the Hamiltonian from creation and annihilation matrices, verify Hermiticity, and check particle-number conservation:
For small sectors, the notebook should print the basis states explicitly and diagonalize each sector separately. This keeps the connection between first-quantized intuition, occupation notation, and matrix mechanics visible.
Optional Advanced Notebooks
Section titled “Optional Advanced Notebooks”Optional notebooks should be added only after the core suite is stable:
negativity-ppt-two-qubits.ipynb: partial transpose, eigenvalues, and negativity for simple two-qubit mixed states.ghz-w-entanglement.ipynb: reduced states of GHZ and W states for different traced-out subsystems.occupation-number-bosons-two-modes.ipynb: bosonic occupation basis, ladder-operator square roots, and two-mode examples.two-mode-squeezed-state-truncation.ipynb: truncated continuous-variable calculations and normalization errors.jordan-wigner-preview.ipynb: a slightly deeper spin-chain mapping after the sign notebook is mature.
Each optional notebook should have a small analytic benchmark. A notebook that only produces plausible plots is not ready.
Common Numerical Issues
Section titled “Common Numerical Issues”- Silent basis-ordering changes. The same array can mean different states under different bit conventions.
- Using rounded matrices as exact evidence. Always report norms or tolerances.
- Forgetting to renormalize after truncation. This is especially dangerous for continuous-variable and Fock-space examples.
- Treating a negative eigenvalue from roundoff as physical. Compare it with the stated tolerance and with Hermiticity error.
- Using local entropy as mixed-state entanglement. Entropy is an entanglement measure only in the pure bipartite setting.
- Guessing fermionic signs. Derive them from the mode order or verify the anticommutators.
- Hiding the central operation in a library call. A notebook teaching the partial trace should show the contraction at least once.
Cross-Links
Section titled “Cross-Links”- Formula Sheet
- Common Composite States
- Entanglement Diagnostic Table
- Tensor Product Exercises
- Partial Trace Exercises
- Fock Space Exercises
- Tensor Product Ordering
- Product Bases
- Partial Trace
- Schmidt Decomposition
- Bell States
- Entanglement Entropy
- Fermionic Anticommutation Relations
- Many-Particle Hamiltonians
References
Section titled “References”- M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, Cambridge University Press, 2010.
- G. H. Golub and C. F. Van Loan, Matrix Computations, 4th ed., Johns Hopkins University Press, 2013.
- L. N. Trefethen and D. Bau III, Numerical Linear Algebra, SIAM, 1997.
- A. L. Fetter and J. D. Walecka, Quantum Theory of Many-Particle Systems, McGraw-Hill, 1971.
- E. Lieb, T. Schultz, and D. Mattis, “Two soluble models of an antiferromagnetic chain”, Annals of Physics 16, 407-466, 1961, doi:10.1016/0003-4916(61)90115-4.
- P. Jordan and E. Wigner, “Uber das Paulische Aquivalenzverbot”, Zeitschrift fur Physik 47, 631-651, 1928.
- J. Hubbard, “Electron correlations in narrow energy bands”, Proceedings of the Royal Society of London A 276, 238-257, 1963, doi:10.1098/rspa.1963.0204.
- U. Schollwoeck, “The density-matrix renormalization group in the age of matrix product states”, Annals of Physics 326, 96-192, 2011, doi:10.1016/j.aop.2010.09.012.
Exercises
Section titled “Exercises”- Basis index check. In the stated two-qubit convention, what are the array indices of and ? Why does this matter for local operators?
Solution
The convention is
Thus has index and has index . This matters because an operator such as flips the first bit, while flips the second bit. If the basis order is changed silently, the same numerical matrix can act on the wrong subsystem.
- Trace preservation. A notebook computes for a normalized two-qubit density operator. What scalar check should be printed immediately?
Solution
It should print
For a normalized density operator this should be zero up to numerical tolerance. Since , the reduced state should also have trace one.
- SVD entropy check. A normalized two-qubit pure state has Schmidt coefficients . What entropy should both the SVD route and the reduced-density-matrix route produce?
Solution
The probabilities are . Therefore
Both computational routes should give the same value, apart from the chosen logarithm base.
- Fermionic sign. In a three-mode occupation basis with order , compute the sign factor for acting on and on .
Solution
For , the sign exponent is
For , , so the annihilation operator gives zero regardless of the sign. The formal sign factor would be .
For , and , so the sign factor is :