# ODE problem using method of undetermined coefficients

$$y'' + 3y' + 2y = \frac{e^x}{1+e^x}$$

My attempt to this problem was finding $y_h$ as usual and let $y_p$ of the form: $$y_p = \frac{Ae^x}{B+De^x}$$

I then go ahead and differentiate $y_p$ and substitute into the first equation to get the following:

$$\frac{AB^3e^x-ABD^2e^{3x}}{(B+De^x)^4} + 3\frac{ABe^x(B+De^x)^2}{(B+De^x)^4}+2\frac{Ae^x(B+De^x)}{(B+De^x)^4} = \frac{e^x}{1+e^x}$$

From there I got the following: For the $$6AB^3=1$$ $$12AB^2D=0$$ $$8ABD^2=0$$ $$2AD^3=0$$

and

$$B^4=1$$ $$4B^3D=1$$ $$6B^2D^2=0$$ $$4BD^3=0$$ $$D^4=0$$

which yields an invalid result.

Can someone point out my mistakes? Thanks :).

• Well nobody said that the solution must be of that form. – Kenny Lau May 13 '18 at 9:39
• @KennyLau That's one of my theory too, but if it isn't in that form, what would the correct form be? – Anh Tran May 13 '18 at 9:44
• Generally speaking, the "method of undetermined coefficients" only works when the right-hand-side is a function of the type we expect as solutions to linear homogeneous differential equation with constant coefficients. Those are: exponentials, sine and cosine, polynomials, and products of those. The fraction $\frac{1}{1+ e^x}$ is not of that form so "undetermined coefficients" will not work here. – user247327 May 13 '18 at 12:11

You can use variation of parameters here. Note that the homogeneous solutions are $y_1 = e^{-x}$ and $y_2 = e^{-2x}$, so we look for a particular solution of the form $$y_p(x) = v_1(x)y_1(x) + v_2(x)y_2(x)$$

The Wronskian is $$W(x) = y_1{y_2}' - y_2{y_1}' = -e^{-3x}$$

so the solution is $${v_1}' = -\frac{y_2(x)f(x)}{W(x)} = \frac{e^{2x}}{1+e^x}$$ $${v_2}' = \frac{y_1(x)f(x)}{W(x)} = -\frac{e^{3x}}{1+e^x}$$

You can integrate by substituting $u=1+e^x$

\begin{align} v_1 &= \int \frac{e^{2x}}{1+e^x} dx = \int\frac{u-1}{u}\ du = \frac13 \big(u - \ln u\big) \\ v_2 &= -\int \frac{e^{3x}}{1+e^x} dx = -\int \frac{(u-1)^2}{u}\ du = -\frac13 \left(\frac{u^2}{2} - 2u + \ln u\right) \end{align}

The final solution is

\begin{align} y(x) &= \bar{c_1} e^{-x} + \bar{c_2}e^{-2x} \\ &\quad - e^{-x}\big[\ln(1+e^x) - (1+e^x)\big] \\ &\quad - e^{-2x}\left[\ln(1+e^x) + \frac{(1+e^x)^2}{2} - 2(1+e^x)\right] \\ &\equiv c_1e^{-x} + c_2e^{-2x} + \frac12 - \big(e^{-x}+e^{-2x}\big)\ln(1+e^x) \\ \end{align}

• Thanks, it's very easy to understand :) – Anh Tran May 13 '18 at 11:52

That approach only works for sums of exponentials, but you have here a rational expression. You will need the variation of constants approach, or, as it is simple here, the use of integrating factors. As in \begin{align} (e^x(y'+2y))'&=\frac{e^{2x}}{1+e^x}\\ e^x(y'+2y)&=\int\frac{u}{1+u}du=u-\ln(1+u)+C\tag{$u=e^x$}\\ y'+2y&=1-e^{-x}\ln(1+e^x)+Ce^{-x} \end{align} and then again with slightly more complicated integrals \begin{align} (y^{2x}y)'&=e^{2x}-e^x\ln(1+e^x)+Ce^x\\ e^{2x}y&=\frac12e^{2x}-\int \ln v\,dv +Ce^x+D\tag{$v=1+e^x$}\\ &=\frac12e^{2x}+v-v\ln v+Ce^x+D\\ y&=\frac12-e^{-2x}(1+e^x)\ln(1+e^x)+\tilde Ce^{-x}+\tilde D e^{-2x},... \end{align}

The "method of undetermined coefficients" only works when the right hand side is a linear combination of exponential-type functions ($\exp$, $\cos$, $\sin$) and polynomials.

Let $u = y' + y$. Then, $u' + 2u = \dfrac{e^x}{1+e^x}$.

$(e^{2x} u)' = \dfrac{e^{3x}}{1+e^x}$

$e^{2x} u = \displaystyle \int \dfrac{e^{3x}}{1+e^x} \ \mathrm dx$

$u = \displaystyle e^{-2x} \int \dfrac{e^{3x}}{1+e^x} \ \mathrm dx$

$y' + y = \displaystyle e^{-2x} \int \dfrac{e^{3x}}{1+e^x} \ \mathrm dx$

$(e^x y)' = \displaystyle e^{-x} \int \dfrac{e^{3x}}{1+e^x} \ \mathrm dx$

$e^x y = \displaystyle \int e^{-x} \left( \int \dfrac{e^{3x}}{1+e^x} \ \mathrm dx \right) \ \mathrm dx$

$y = \displaystyle e^{-x} \int e^{-x} \left( \int \dfrac{e^{3x}}{1+e^x} \ \mathrm dx \right) \ \mathrm dx$

$y = \displaystyle -xe^{-x} + \frac12 - e^{-x} \log(e^{-x}+1) - e^{-2x} \log(e^x+1) + Ae^{-x} + Be^{-2x}$