fbf10dcRename project title to 'Companion to Quantum Optics'Jeremy Magland 1# Companion to Quantum Optics
3A companion to the tutorial article **"Quantum optics in MATLAB"** by Nilakantha
4Meher — [arXiv:2309.14354](https://arxiv.org/abs/2309.14354).
6The article teaches the basics of theoretical quantum optics through short,
7self-contained MATLAB scripts: building quantum states and operators as
8matrices, then using them to compute physical properties and time dynamics.
9This project collects those examples as runnable
10[numbl](https://numbl.org) scripts so you can execute and edit them directly in
11your browser — no MATLAB, no install. Pick a script in the panel on the left and
12click **Run**. Edits stay in memory for your session.
14> This README is a guide to *which* example to open, not a replacement for the
15> article. Read the article for the physics, the equations, and the discussion;
16> come here to run the code. Each numbered script corresponds to one code block
17> in the article, in the same order, and is annotated with its section number.
18> The code is transcribed faithfully from the article; the only additions are
19> axis labels and legends on the plots.
21## Quantum states (Sec. II)
23| Script | Article | What it shows |
24| --- | --- | --- |
25| [`ex01_number_states.m`](ex01_number_states.m) | II.A | Number states `\|0>, \|1>, \|2>` as columns of the identity matrix |
26| [`ex02_number_state_20.m`](ex02_number_state_20.m) | II.A | A higher number state `\|20>`, and why the dimension `d` must exceed it |
27| [`ex03_superposition_state.m`](ex03_superposition_state.m) | II.B | A normalized superposition of number states |
28| [`ex04_coherent_state.m`](ex04_coherent_state.m) | II.C | A coherent state `\|alpha>` built by truncating its number-basis sum |
29| [`ex05_thermal_state.m`](ex05_thermal_state.m) | II.D | A thermal state as a diagonal density matrix (mixed state) |
30| [`ex06_squeezed_vacuum.m`](ex06_squeezed_vacuum.m) | II.E | A squeezed vacuum state — a superposition of even number states |
31| [`ex07_nsfcs.m`](ex07_nsfcs.m) | II.F | A number-state-filtered coherent state (one Fock state removed) |
32| [`ex08_atomic_states.m`](ex08_atomic_states.m) | II.G | Excited/ground states of a two-level atom and their superposition |
34## Operators (Sec. III)
36| Script | Article | What it shows |
37| --- | --- | --- |
38| [`ex09_field_operators.m`](ex09_field_operators.m) | III.A | Annihilation, creation and number operators in the number basis |
39| [`ex10_field_hamiltonian.m`](ex10_field_hamiltonian.m) | III.B | The quantized electromagnetic-field Hamiltonian |
40| [`ex11_pauli_operators.m`](ex11_pauli_operators.m) | III.C | Pauli `sigma_z`, raising/lowering operators, two-level-atom Hamiltonian |
42## Properties of quantum states (Sec. IV)
44| Script | Article | What it shows |
45| --- | --- | --- |
46| [`ex12_photon_distribution.m`](ex12_photon_distribution.m) | IV.A | Photon-number distributions `P_n` (bar plots): coherent vs. thermal |
47| [`ex13_average_photons.m`](ex13_average_photons.m) | IV.B | Average photon number `<a'a>` for number, coherent, thermal states |
48| [`ex14_g2_coherence.m`](ex14_g2_coherence.m) | IV.C | Second-order coherence `g^(2)(0)`: sub-Poissonian, Poissonian, super-Poissonian |
50## Atom–field interaction (Sec. V)
52| Script | Article | What it shows |
53| --- | --- | --- |
54| [`ex15_atom_field_rabi.m`](ex15_atom_field_rabi.m) | V | Jaynes–Cummings vacuum Rabi oscillations `P_e(t)`, `P_g(t)` |
55| [`ex16_atomic_inversion.m`](ex16_atomic_inversion.m) | V | Atomic inversion `<sigma_z(t)>` with a coherent field: collapse and revival |
57## Two-mode field (Sec. VI)
59| Script | Article | What it shows |
60| --- | --- | --- |
61| [`ex17_coupled_cavities.m`](ex17_coupled_cavities.m) | VI.A | Photon exchange between two coupled cavities `P_{10}(t)`, `P_{01}(t)` |
63## A few numbl/MATLAB notes
65- **Time evolution** uses the matrix exponential `U = expm(-i*H*dt)`. The scripts
66 build the propagator once, then apply it repeatedly in a loop.
67- The examples set `hbar = 1` (and often `hbar*omega = 1`) so energies and times
68 are in natural units, exactly as in the article.
69- `i` and `j` both denote the imaginary unit. Scripts begin with `clear; clc;`
70 following the article's convention.
71- `ex16_atomic_inversion.m` is the heaviest example (a 100×100 propagator over a
72 long evolution); give it a few seconds.
74## How it's deployed
76On every push to `main`, the workflow in
77[`.github/workflows/deploy.yml`](.github/workflows/deploy.yml) bundles these
78files with the numbl browser IDE and publishes the result to GitHub Pages — no
79server, nothing to build by hand. Edit `numbl-project.json` to change the title
80or which file opens first.
82## Reference
84Nilakantha Meher, *Quantum optics in MATLAB*, [arXiv:2309.14354](https://arxiv.org/abs/2309.14354).