1% Annihilation, creation and number operators (Sec. III.A)
2% a|n> = sqrt(n)|n-1>, a'|n> = sqrt(n+1)|n+1>, N = a'a, N|n> = n|n>
3% The creation operator is the adjoint of the annihilation operator.
5clear; % Clear memory
6clc; % Clear the command window/screen
7d = 6; % dimension of the operator
8A = diag(sqrt(1:d-1), 1) % Annihilation operator (superdiagonal)
9Ad = A' % Creation operator (adjoint of A)
10N = Ad*A % Number operator (diagonal: 0,1,2,...)