concept-collection / numbl-quantum-optics
Go to fileHistoryFork
.githubdeploy: bump checkout@v6, deploy-pages@v5 (Node 24 runtime)
.gitignoreQuantum optics in numbl: companion to arXiv:2309.14354
ex01_number_states.mQuantum optics in numbl: companion to arXiv:2309.14354
ex02_number_state_20.mQuantum optics in numbl: companion to arXiv:2309.14354
ex03_superposition_state.mQuantum optics in numbl: companion to arXiv:2309.14354
ex04_coherent_state.mQuantum optics in numbl: companion to arXiv:2309.14354
ex05_thermal_state.mQuantum optics in numbl: companion to arXiv:2309.14354
ex06_squeezed_vacuum.mQuantum optics in numbl: companion to arXiv:2309.14354
ex07_nsfcs.mQuantum optics in numbl: companion to arXiv:2309.14354
ex08_atomic_states.mQuantum optics in numbl: companion to arXiv:2309.14354
ex09_field_operators.mQuantum optics in numbl: companion to arXiv:2309.14354
ex10_field_hamiltonian.mQuantum optics in numbl: companion to arXiv:2309.14354
ex11_pauli_operators.mQuantum optics in numbl: companion to arXiv:2309.14354
ex12_photon_distribution.mQuantum optics in numbl: companion to arXiv:2309.14354
ex13_average_photons.mQuantum optics in numbl: companion to arXiv:2309.14354
ex14_g2_coherence.mQuantum optics in numbl: companion to arXiv:2309.14354
ex15_atom_field_rabi.mQuantum optics in numbl: companion to arXiv:2309.14354
ex16_atomic_inversion.mQuantum optics in numbl: companion to arXiv:2309.14354
ex17_coupled_cavities.mQuantum optics in numbl: companion to arXiv:2309.14354
numbl-project.jsonRename project title to 'Companion to Quantum Optics'
README.mdRename project title to 'Companion to Quantum Optics'

Companion to Quantum Optics#

A companion to the tutorial article "Quantum optics in MATLAB" by Nilakantha Meher — arXiv:2309.14354.

The article teaches the basics of theoretical quantum optics through short, self-contained MATLAB scripts: building quantum states and operators as matrices, then using them to compute physical properties and time dynamics. This project collects those examples as runnable numbl scripts so you can execute and edit them directly in your browser — no MATLAB, no install. Pick a script in the panel on the left and click Run. Edits stay in memory for your session.

This README is a guide to which example to open, not a replacement for the article. Read the article for the physics, the equations, and the discussion; come here to run the code. Each numbered script corresponds to one code block in the article, in the same order, and is annotated with its section number. The code is transcribed faithfully from the article; the only additions are axis labels and legends on the plots.

Quantum states (Sec. II)#

Script Article What it shows
ex01_number_states.m II.A Number states |0>, |1>, |2> as columns of the identity matrix
ex02_number_state_20.m II.A A higher number state |20>, and why the dimension d must exceed it
ex03_superposition_state.m II.B A normalized superposition of number states
ex04_coherent_state.m II.C A coherent state |alpha> built by truncating its number-basis sum
ex05_thermal_state.m II.D A thermal state as a diagonal density matrix (mixed state)
ex06_squeezed_vacuum.m II.E A squeezed vacuum state — a superposition of even number states
ex07_nsfcs.m II.F A number-state-filtered coherent state (one Fock state removed)
ex08_atomic_states.m II.G Excited/ground states of a two-level atom and their superposition

Operators (Sec. III)#

Script Article What it shows
ex09_field_operators.m III.A Annihilation, creation and number operators in the number basis
ex10_field_hamiltonian.m III.B The quantized electromagnetic-field Hamiltonian
ex11_pauli_operators.m III.C Pauli sigma_z, raising/lowering operators, two-level-atom Hamiltonian

Properties of quantum states (Sec. IV)#

Script Article What it shows
ex12_photon_distribution.m IV.A Photon-number distributions P_n (bar plots): coherent vs. thermal
ex13_average_photons.m IV.B Average photon number <a'a> for number, coherent, thermal states
ex14_g2_coherence.m IV.C Second-order coherence g^(2)(0): sub-Poissonian, Poissonian, super-Poissonian

Atom–field interaction (Sec. V)#

Script Article What it shows
ex15_atom_field_rabi.m V Jaynes–Cummings vacuum Rabi oscillations P_e(t), P_g(t)
ex16_atomic_inversion.m V Atomic inversion <sigma_z(t)> with a coherent field: collapse and revival

Two-mode field (Sec. VI)#

Script Article What it shows
ex17_coupled_cavities.m VI.A Photon exchange between two coupled cavities P_{10}(t), P_{01}(t)

A few numbl/MATLAB notes#

  • Time evolution uses the matrix exponential U = expm(-i*H*dt). The scripts build the propagator once, then apply it repeatedly in a loop.
  • The examples set hbar = 1 (and often hbar*omega = 1) so energies and times are in natural units, exactly as in the article.
  • i and j both denote the imaginary unit. Scripts begin with clear; clc; following the article's convention.
  • ex16_atomic_inversion.m is the heaviest example (a 100×100 propagator over a long evolution); give it a few seconds.

How it's deployed#

On every push to main, the workflow in .github/workflows/deploy.yml bundles these files with the numbl browser IDE and publishes the result to GitHub Pages — no server, nothing to build by hand. Edit numbl-project.json to change the title or which file opens first.

Reference#

Nilakantha Meher, Quantum optics in MATLAB, arXiv:2309.14354.