Second Order ODE Problem

I'm trying to solve a boundary layer problem but I've ran into some trouble when it comes to solving the second order ODE's that have come up. I've been attempting to apply the method of undetermined coefficients, but I suspect I'm doing something wrong when it comes to finding the particular solution.

Here's an example of the problem I'm having,

$y_{1}''+y_{1}'=xe^{-x}-1+A_{0}(1-e^{-x}),\hspace{10mm} y_{1}(0)=0$

where the right hand side has come from me solving the homogeneous case and plugging it in, where

$y_{0}=1+A_{0}(e^{-x})$

and the RHS is $-xy_{0}'-y_{0}$

Apparently the answer I should be getting is

$y(x)=-x+A_{0}(x-\frac12 x^{2}e^{-x})+A_{1}(e^{-x}-1)$

but after trying a few different particular solutions I can't seem to see how it comes out.

Any help would be appreciated.

$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\mc}[1]{\mathcal{#1}} \newcommand{\mrm}[1]{\mathrm{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$ \begin{align} \totald{\bracks{\expo{x}y'}}{x} & = x - \expo{x} + A_{0}\pars{\expo{x} - 1} \\[5mm] \expo{x}y' & = {1 \over 2}\,x^{2} - \expo{x} + A_{0}\pars{\expo{x} - x} + a \\[5mm] y' & = {1 \over 2}\,x^{2}\expo{-x} - 1 + A_{0}\pars{1 - x\expo{-x}} + a\expo{-x} \\[5mm] y & = \bbx{-\expo{-x}\pars{{1 \over 2}\,x^{2} + x + 1} - x + A_{0}\bracks{x + \expo{-x}\pars{x + 1}} - a\expo{-x} + b} \\[5mm] 0 & = y\pars{0} = -{1 \over 2} + A_{0} - a + b \end{align}

$\ds{a}$ and $\ds{b}$ are constants.

• Thanks, that's massively useful. I'm a little unclear about how you've obtained the first line, I can see you've multiplied both sides by $e^{x}$ but I'm not too sure about how you've obtained the left hand side. Would you mind clarifying? – M.Lyons May 7 '18 at 21:07
• @M.Lyons Thanks. $\displaystyle{\mathrm{d}\left[\mathrm{e}^{x}y'\right] \over \mathrm{d}x} = \mathrm{e}^{x}y' + \mathrm{e}^{x}y'' = \mathrm{e}^{x}\left(y'' + y'\right)$. – Felix Marin May 8 '18 at 0:17

You can use undetermined coefficients to solve it. First, rewrite

$$y_1'' + y_1' = xe^{-x} -A_0e^{-x} + (A_0-1)$$

Observe that the homogeneous solution has the form $c_0 + c_1e^{-x}$, so we guess a particular solution $$y_{p1} = Cx^2e^{-x} + Dxe^{-x} + Ex$$

Differentiating gives

\begin{align} y_{p1}' &= C(2x-x^2)e^{-x} + D(1-x)e^{-x} + E \\ &= -Cx^2e^{-x} + (2C-D)xe^{-x} + De^{-x} + E \end{align}

\begin{align} y_{p1}'' &= -C(2x-x^2)e^{-x} + (2C-D)(1-x)e^{-x} - De^{-x} \\ &= Cx^2e^{-x} + (D-4C)xe^{-x} + (2C-2D)e^{-x} \end{align}

Plugging in, we find $$y_{p1}'' + y_{p1}' = -2Cxe^{-x} + (2C-D)e^{-x} + E$$

which gives $$C = -\frac12, \ D = A_0 - 1, \ E = A_0-1$$

The final solution, including the initial condition is

$$y_1(x) = c_0(1-e^{-x}) - \frac12x^2e^{-x} + (A_0-1)x(e^{-x} + 1)$$