/ concept-collection / numbl-quantum-optics
Sign in
concept-collection / numbl-quantum-optics
numbl-quantum-optics / ex05_thermal_state.m
15 lines · 528 BCodeBlameHistory
21c62a3Quantum optics in numbl: companion to arXiv:2309.14354Jeremy Magland 1% Thermal state (Sec. II.D)
2% rho_th = 1/(1+nth) * sum_n (nth/(1+nth))^n |n><n|
3% A mixed state: a square density matrix, diagonal in the number basis.
5clear; % Clear memory
6clc; % Clear the command window/screen
7d = 10;
8I = eye(d);
9nth = 0.5; % average number of photons in the thermal state
10RhoTh = 0; % initialization
11for x = 0:d-1
12 RhoTh = RhoTh + nth^(x)/(1+nth)^(x+1)*I(:,x+1)*I(:,x+1)';
13end
14RhoTh % display the thermal state
15N_th = trace(RhoTh) % check trace (should be 1)
moveopenescclose