I was trying to write a Maple sheet to calculate some perturbation theory expension as close to the "book notation" as possible. Lets for example consider a linearly perturbed harmonic oscillator with H = hω(n+1/2) and V = λ(a†+a), this is one of the classical examples as it can be solved analytically by completing the square. In the Kato formulation (as used in the appended Maple worksheet), as well as in Rayleigh-Schrödinger perturbation theory one uses the projector onto the complement of the unperturbed state. I would like to do this by defining a projector in Maple. I've read the examples concerning projectors in Maple but it seems I have to use a rather ugly workaround by treating the states "below" the unperturbed state and the ones "above" separately. While this is a little annoying in one dimension it becomes a major nuisance in higher dimensions.
My question would be: How do I define the projector onto the complement of some state?