# Solve differential equation dy/dx+ycos(x)= 4cos(x), y(0)=6

First order differential equations

Solve differential equation $$\frac{dy}{dx}+y \cos(x)= 4\cos(x)$$, y(0)=6

2021-02-24

$$\frac{dy}{dx}+y \cos x= 4\cos x$$
That is $$\frac{dy}{dx}+(\cos x)y= 4\cos x$$
$$\frac{dy}{dx}+P(x)=Q(x)$$
So $$P(x)= \cos x$$, $$Q(x)= 4\cos x$$
Integrating factor is
$$I.F.= e^{(\int P(x)dx)}$$
$$= e^{\int \cos xdx}$$
$$= e^{\sin x}$$
$$y \cdot I.F.= \int Q(x) \cdot I.F. dx+c$$
$$ye^{\sin x}= \int 4\cos x e^{\sin x} dx+c$$
$$= 4 \int e^{\sin x} \cos x dx+c$$
$$= 4 \int e^t dt+c$$ (by subtitution)
$$= 4e^t+c$$
$$ye^{\sin x}= 4e^{\sin x}+c$$
$$y(x)=4e^{\sin x}+c$$
Now apply the initial condition y(0)=6 in the general solution
$$4e^{\sin(0)}+c=6$$
$$4e^0+c=6 => 4+c=6$$
c=6-4=2 Now substitute 2 for c in general solution
Thus,the particular solution is $$y(x)=4e^{\sin x}+2$$