finding local behaviour as x tends to $0^+$ of particular solution of ode we have
$$ y' + xy = \cos x $$
I am asked to find the first three terms in local behaviour as $x \to 0^+$.
thought:
As $ x \to 0^+$, then $\cos x \sim 1 $ so
$$ y' + xy \sim 1 $$
which can be solved by using integrating factor $e^{x^2/2}$, thus
$$ ( e^{x^2/2} y ) \sim \int e^{x^2/2} = \int \sum \frac{x^{2n} }{2^n n!} = \sum \frac{x^{2n+1} }{2^n (2n+1) n!} \sim x$$
thus,
$$ y(x) \sim cx e^{-x^2/2} $$
is this a correct?

\begin{equation}
y^\prime+xy=\cos x
\end{equation}
Let $y=\sum_{n=0}^{\infty}c_nx^n$. Then
\begin{eqnarray}
y^\prime+xy&=&\sum_{n=1}^{\infty}nc_nx^{n-1}+x\sum_{n=0}^{\infty}c_nx^n\\
&=&\sum_{n=1}^{\infty}nc_nx^{n-1}+\sum_{n=0}^{\infty}c_nx^{n+1}
\end{eqnarray}
Replacing each $n$ in the first sum with $n+1$ and each $n$ in the second with $n-1$ yields
\begin{eqnarray}
y^\prime+xy&=&\sum_{n=0}^{\infty}(n+1)c_{n+1}x^{n}+\sum_{n=1}^{\infty}c_{n-1}x^{n}\\
&=&c_1+\sum_{n=1}^{\infty}\left[(n+1)c_{n+1}+c_{n-1}\right]x^n
\end{eqnarray}
Therefore the DE can be written in summation form
\begin{equation}
c_1+\sum_{n=1}^{\infty}\left[(n+1)c_{n+1}+c_{n-1}\right]x^n=\sum_{k=0}^{\infty}\dfrac{(-1)^kx^{2k}}{(2k)!}
\end{equation}
Immediately we see that $c_1=1$, so we know that the first two terms of the solution are $y=c_0+x.$ Now, when $n=1$ the coefficient of $x$ in the cosine expansion must be $0$ so we know that $(n+1)c_{n+1}+c_{n-1}=2c_2+c_0=0$. Therefore, $c_2=-\frac{1}{2}c_0$. Thus we now have the first three terms as required
\begin{equation}
y=c_0+x-\frac{1}{2}c_0x^2
\end{equation}
Since we are on a roll, let's find the fourth term of $y$.
When $n=2$ we get $(n+1)c_{n+1}+c_{n-1}=3c_3+c_1=-\frac{1}{2}$, the coefficient of $x$ in the cosine expansion. We already know that $c_1=1$ so we have $c_3=-\frac{1}{2}$ in the expansion of $y$. Therefore we have the first four terms:
\begin{eqnarray}
y&=&c_0+x-\frac{1}{2}c_0x^2-\frac{1}{2}x^3\\
&=&(c_0+x)\left(1-\frac{x^2}{2}\right)
\end{eqnarray}
Thanks to @Winther for the hint.
