# Particular solution for a first-order linear ODE

I have a first-order linear ODE:

$$u'=-2u+y\sin(x)$$ where $$u(0)=y^2$$ basically it is the PDE $$u_x=-2u+y\sin(x)$$ Where we are looking on it as an ODE

What I have done is to solve the homogenous equation using $$y_h=e^{-\int p(x)dx}$$ and then looking at the particular solution:

$$y_p=c(x)e^{-\int p(x)dx}$$

Deriving it, plug it in back to the ODE and got a correct solution using superposition and initial condition.

In the book they wrote right away that the particular solution is $$y_p=A\sin x+B\cos x$$

Why/How can they do it?

• If you do not show us the differential equation problem, there is no way anyone could tell you how. Commented Nov 26, 2019 at 16:19
• @Rebellos Added the ODE Commented Nov 26, 2019 at 16:26
• If $u$ is a linear combination of $\sin x$ and $\cos x$, then so is $u'$. But $\sin x,\cos x$ are not solutions to $u'+2u$, so $u'+2u$ is not zero. Hence $u'+2u=A'\cos x+B'\sin x$ where $A',B'$ are linear functions of $A,B$. So now one just determines which $A,B$ give $A'=0$ and $B'=y$. (Note that this logic would work for $u'+p u = q \sin x$ as well, so long as $p\neq 1$.) Commented Nov 26, 2019 at 16:36

$$y'+p(x)y=q(x)$$ When you have on the right side $$( q(x))$$ a cosine or a sine you try as a particular solution a combinaison of both $$A\cos(x)+B\sin(x)$$. This is true as long as cosine and sine aren't solution of the homogeneous equation. If they are solution you have to multiply by $$x$$ the particular solution for a first order DE.This method is known as Method of Undetermined Coefficients ( link https://www.efunda.com/math/ode/linearode_undeterminedcoeff.cfm )

Here I integrate both side. $$u_x=-2u+y\sin(x)$$ $$u_x+2u=y\sin(x)$$ Integrating factor is $$\mu(x) = e^{2x}$$ $$(ue^{2x})'=y\sin(x)e^{2x}$$ Integrate $$ue^{2x}=y\int \sin(x)e^{2x}dx$$ Evaluate the integral by part $$I=-\frac 1 5e^{2x}(\cos(x)-2\sin(x))+C(y)$$ $$ue^{2x}=-\frac y 5e^{2x}(\cos(x)-2\sin(x))+C(y)$$ $$u=\frac y 5(-\cos(x)+2\sin(x))+C(y)e^{-2x}$$