Find the first two terms in the perturbation expansion of the solution I want to find the $\mathcal{O}(1)$ and $\mathcal{O}(\epsilon)$ terms in the pedestrian expansion $y = y_0 + \epsilon y_1 + \epsilon ^2 y_2 + \dots$, where $y$ satisfies the following second order ODE:
$\frac{d^2y}{dx^2} + (1-\epsilon x)y = 0$, 
with $|{\epsilon}|\ll 1$ and subject to $y(0) = 1$, $y'(0) = 0$.
I have already found that $y_0 = \cos x$, but I'm stuck with finding $y_1$.
Any help would be much appreciated.
 A: You're right that $y_0 = \cos x$. To find $y_1$, we need to plug our expansion for $y$ into the ODE and collect the $\mathcal{O} (\epsilon)$ terms:
$\frac{d^2}{dx^2} (y_0 + \epsilon y_1 + \dots) + (1-\epsilon x)(y_0 + \epsilon y_1 + \dots) = 0$.
Taking order $\epsilon$ terms:
$\frac{d^2y_1}{dx^2} + y_1 - xy_0 = 0$.
Subbing $y_0 = \cos x$:
$\frac{d^2y_1}{dx^2} + y_1 - x \cos x = 0$.
This is a second order nonhomogeneous ODE, which we can solve by finding the complementary and particular solutions and adding them together.
First we need to work out our conditions on $y_1$. We know that $y(0) = y_0(0) +\epsilon y_1(0) + \dots = 1$. Since $1$ is $\mathcal{O}(1)$, we can only have $y_0(0) = 1$, $y_i(0) = 0 \ \ \forall \ \ i \neq 1$. Also, since $y'(0) = y_0' + \epsilon y_1' + \dots = 0$, we must have $y_i'(0) = 0 \ \ \forall \ \ i = 0,1,2,\dots$
So we've now got the conditions $y_1(0)=y_1'(0)=0$.
The complementary solution is $y_1^p = c_1 \sin x + c_2 \cos x$ for some constants $c_1,c_2$. (Solution to $\frac{d^2y_1}{dx^2} + y_1 = 0$).
For the particular solution, we can use the trial function: $y_1 = (Ax^2+Bx)\sin x + (Cx^2+Dx)\cos x$, with $A,B,C,D$ constants to be determined.
Subbing this in and equating coefficients, we end up with particular solution $y_1^p = \frac{x^2}{4}\sin x + \frac{x}{4} \cos x$.
So:
$y_1 = y_1^c +y_1^p = c_1\sin x + c_2 \cos x + \frac{x^2}{4}\sin x + \frac{x}{4} \cos x$
Applying the conditions, we find that $c_1=c_2=0$, so that:
$y_1 = \frac{x^2}{4}\sin x + \frac{x}{4} \cos x$.
Hence, $y \sim \cos x + \epsilon\left(\frac{x^2}{4}\sin x + \frac{x}{4} \cos x \right)$.
$x$." />
The dotted line is the asymptotic approximation, the solid line is the solution to the ODE. You can see the approximation is pretty much exact for small $x$.This is for $\epsilon = 0.01$, the approximation would get better and better the smaller $\epsilon$ becomes.
