Concept:
This differential equation is solved using the method of separation of variables.
The idea is to collect all terms involving \(y\) on one side and all terms involving \(x\) on the other side, and then integrate both sides separately.
Step 1: Rewriting the given differential equation.
The equation is:
\[
\left(\frac{2+\sin x}{1+y}\right)\frac{dy}{dx}=-\cos x
\]
Multiply both sides by \(dx\):
\[
\left(\frac{2+\sin x}{1+y}\right)dy=-\cos x \, dx
\]
Now divide both sides by \(2+\sin x\):
\[
\frac{dy}{1+y}=-\frac{\cos x}{2+\sin x}\,dx
\]
Thus, the variables are successfully separated.
Step 2: Integrating both sides.
Integrate:
\[
\int \frac{dy}{1+y} = -\int \frac{\cos x}{2+\sin x}\,dx
\]
For the left side:
\[
\int \frac{dy}{1+y} = \ln|1+y|
\]
For the right side, let
\[
u=2+\sin x
\]
Then,
\[
du=\cos x\,dx
\]
Hence,
\[
-\int \frac{\cos x}{2+\sin x}\,dx
=
-\int \frac{du}{u}
=
-\ln|u|
\]
Substituting back:
\[
-\ln|2+\sin x|
\]
Therefore,
\[
\ln|1+y|
=
-\ln|2+\sin x|+C
\]
Step 3: Simplifying the logarithmic expression.
Using logarithmic properties:
\[
\ln|1+y|+\ln|2+\sin x|=C
\]
\[
\ln|(1+y)(2+\sin x)|=C
\]
Removing logarithm:
\[
(1+y)(2+\sin x)=K
\]
where \(K\) is a constant.
Step 4: Using the initial condition \(y(0)=2\).
Substitute \(x=0\) and \(y=2\):
\[
(1+2)(2+\sin0)=K
\]
\[
3(2+0)=K
\]
\[
K=6
\]
Thus, the particular solution becomes:
\[
(1+y)(2+\sin x)=6
\]
Step 5: Finding \(y\left(\frac{\pi}{2}\right)\).
Substitute \(x=\frac{\pi}{2}\):
\[
(1+y)\left(2+\sin\frac{\pi}{2}\right)=6
\]
Since,
\[
\sin\frac{\pi}{2}=1
\]
we get:
\[
(1+y)(2+1)=6
\]
\[
3(1+y)=6
\]
\[
1+y=2
\]
\[
y=1
\]
Hence,
\[
y\left(\frac{\pi}{2}\right)=1
\]