1% Superposition of number states (Sec. II.B)
2% |psi> = (1/sqrt(3))|2> + (1/sqrt(2))|5> - (1/sqrt(6))|6>
3% Any superposition of number states is a linear combination of identity
4% columns; d must exceed the largest number state present.
6clear; % Clear memory
7clc; % Clear the command window/screen
8d = 7; % dimension of the field
9I = eye(d); % Identity matrix of dimension d
10Ket2 = I(:,3); % two-photon state |2>
11Ket5 = I(:,6); % five-photon state |5>
12Ket6 = I(:,7); % six-photon state |6>
13Psi = 1/sqrt(3)*Ket2 + 1/sqrt(2)*Ket5 - 1/sqrt(6)*Ket6 % superposition state
14N_psi = norm(Psi) % norm of the state Psi