Step 1: Understanding the Concept:
This is a first-order separable ordinary differential equation. We can solve it by isolating all terms involving $y$ on one side of the equation and all terms involving $x$ on the other side. After integrating both sides, we utilize the given initial condition $y(0)=2$ to find the constant of integration, and subsequently find the specific value requested.
Step 2: Key Formula or Approach:
1. Separation of Variables: Rearrange the differential equation into the form $f(y) dy = g(x) dx$.
2. Standard integral forms: $\int \frac{1}{x} dx = \log|x| + C$ and $\int \frac{f'(x)}{f(x)} dx = \log|f(x)| + C$.
Step 3: Detailed Explanation:
The given differential equation is:
\[ \left(\frac{2+\sin x}{1+y}\right) \frac{dy}{dx} = -\cos x \]
Rearrange the terms to separate the variables $x$ and $y$:
\[ \frac{1}{1+y} dy = -\frac{\cos x}{2+\sin x} dx \]
Integrate both sides:
\[ \int \frac{1}{1+y} dy = -\int \frac{\cos x}{2+\sin x} dx \]
The left integral is straightforward:
\[ \int \frac{1}{1+y} dy = \log|1+y| \]
For the right integral, notice that the numerator is the exact derivative of the denominator. Let $u = 2+\sin x$, then $du = \cos x \,dx$.
\[ -\int \frac{du}{u} = -\log|u| = -\log|2+\sin x| \]
Equating the integrated forms and adding a constant $C$:
\[ \log|1+y| = -\log|2+\sin x| + C \]
Using properties of logarithms, bring the log terms together:
\[ \log|1+y| + \log|2+\sin x| = C \]
\[ \log|(1+y)(2+\sin x)| = C \]
Taking the exponential function of both sides:
\[ |(1+y)(2+\sin x)| = e^C \]
Let $e^C$ be a new constant $K$. Near the initial condition $(0, 2)$, $(1+y)$ is positive and $(2+\sin x)$ is positive. We can drop the absolute value bars:
\[ (1+y)(2+\sin x) = K \]
Now, apply the initial condition: when $x = 0, y = 2$.
\[ (1+2)(2+\sin 0) = K \]
\[ (3)(2+0) = K \implies K = 6 \]
The particular solution is:
\[ (1+y)(2+\sin x) = 6 \]
We are asked to find the value of $y$ when $x = \frac{\pi}{2}$. Substitute this into the equation:
\[ \left(1 + y\left(\frac{\pi}{2}\right)\right)\left(2 + \sin\left(\frac{\pi}{2}\right)\right) = 6 \]
Since $\sin\left(\frac{\pi}{2}\right) = 1$:
\[ \left(1 + y\left(\frac{\pi}{2}\right)\right)(2 + 1) = 6 \]
\[ \left(1 + y\left(\frac{\pi}{2}\right)\right) \cdot 3 = 6 \]
Divide both sides by 3:
\[ 1 + y\left(\frac{\pi}{2}\right) = 2 \]
\[ y\left(\frac{\pi}{2}\right) = 2 - 1 = 1 \]
Step 4: Final Answer:
The value is 1.