Complex forcing method for a real differential equation (source code)

= Complex forcing method for a real differential equation

For a real linear <differential operator> $L$, one has $L(\operatorname{Im}u)=\operatorname{Im}(Lu)$. A forcing term written as the imaginary part of a polynomial times $e^{i\omega x}$ can therefore be handled by solving one complex equation, then taking the imaginary part. For $L=d^2/dx^2+a$, substituting $u=p(x)e^{i\omega x}$ gives $p''+2i\omega p'+(a-\omega^2)p$. If the forcing frequency is resonant, the polynomial ansatz must include the appropriate additional power of $x$.