I am working with the following differential equation:
$\frac{d^2z}{dx^2}+z=\frac{\cos 2x}{1+\epsilon z},\:\:\:z(-\pi/4)=z(\pi/4)=0$
where modulus of $\epsilon$ is much less than $1$. The task is then to use perturbation theory to show that the second-order approximation to the solution to this DE is:
$z=-\frac{1}{3}\cos 2x +\epsilon\bigg(\frac{1}{6}-\frac{8\sqrt{2}}{45}\cos x - \frac{1}{90}\cos 4x \bigg) + \epsilon^2 \bigg(\frac{2\sqrt{2}x}{45}\sin x - \frac{\sqrt{2}}{90}(\pi + 1)\cos x + \frac{7}{720} \cos 2x - \frac{\sqrt{2}}{90}\cos 3x - \frac{1}{1050}\cos 6x \bigg).$
By starting point is to use the theory for a regular perturbation (since the modulus of $\epsilon$ is much less than $1$). For the unperturbed equation, I could set $\epsilon=0$ as that would give a simple differential equation which should be solvable. However, the next step is then to expand the solution as a power series, which is what I am less sure about. I can do the computation with Maple if necessary, but would like to know the theory behind what is going on and some pointers as to how this all works.
Let $ z = z_0 + \epsilon z_1 + \epsilon^2 z_2 + O(\epsilon^3) $ then
\begin{align} \frac{1}{1+\epsilon z} &= 1 - \epsilon z + \epsilon^2z^2 + O(\epsilon^3) \\ &= 1 - \epsilon z_0 - \epsilon^2 z_1 + \epsilon^2{z_0}^2 + O(\epsilon^3) \end{align}
Ignoring higher-order terms, the equation becomes $$ {z_0}'' + z_0 + \epsilon({z_1}''+z_1) + \epsilon^2({z_2}''+z_2) = \big[ 1 - \epsilon z_0 + \epsilon^2({z_0}^2-z_1)\big]\cos 2x $$
Collecting like terms $$ \big( {z_0}'' + z_0 - \cos 2x \big) + \epsilon\big({z_1}'' + z_1 + z_0\cos 2x \big) + \epsilon^2 \big[{z_2}'' + z_2 - ({z_0}^2-z_1)\cos 2x \big] = 0 $$
We obtain 3 equations \begin{align} {z_0}'' + z_0 - \cos 2x &= 0 \\ {z_1}'' + z_1 + z_0\cos 2x &= 0 \\ {z_2}'' + z_2 - ({z_0}^2-z_1)\cos 2x &= 0 \end{align}
Note that all boundary conditions are $z_i (-\pi/4) = z_i (\pi/4) = 0$
The constant peturbation gives $z_0 = -\frac13 \cos 2x$
The 1st order peturbation gives $$ {z_1}'' + {z_1} = \frac13 \cos^2 2x = \frac16 (1 + \cos 4x) $$
Using undetermined coefficients, the particular solution is $z_{p1} = \frac16 - \frac{1}{90}\cos 4x$. After setting boundary conditions, we get $z_1 = \frac16 - \frac{1}{90}\cos 4x - \frac{8\sqrt{2}}{45}\cos x$
I'll leave you to find $z_2$. If the question doesn't ask to solve explicitly, you can also plug in the solution you were already given into the 3 peturbations.