What is the reason the commutation relation fails on the last state
N=7
M=6
commutator(position(N),momentum(N))*basis(N,M)==1.0j*basis(N,M)
and similarly for the create
and destroy
commutator?
Because you are in a truncated Hilbert space, and your excitation is in the upmost level. Thus a creation operator promotes you out of the Hilbert space.