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