Step 1: Understanding the Concept The given equation is a first-order ordinary differential equation. To find the solution \( y = f(x) \), we need to separate the variables \( x \) and \( y \) and integrate both sides of the equation.
Step 2: Separating Variables and Integration The given equation is: \( (1 + \sin x) \frac{dy}{dx} + \cos x = 0 \). Rearranging terms: \( (1 + \sin x) \frac{dy}{dx} = -\cos x \) which simplifies to \( \frac{dy}{dx} = -\frac{\cos x}{1 + \sin x} \). Integrating both sides: \( \int dy = -\int \frac{\cos x}{1 + \sin x} dx \). Let \( u = 1 + \sin x \), then \( du = \cos x dx \). The integral becomes: \( y = -\ln|1 + \sin x| + C \).
Step 3: Finding the Constant of Integration Using \( f(0) = 0 \): \( 0 = -\ln|1 + \sin 0| + C \). Since \( \sin 0 = 0 \), we get \( 0 = -\ln(1) + C \), so \( C = 0 \). Thus, \( f(x) = -\ln(1 + \sin x) \).
Step 4: Final Answer Now, calculate \( f\left( \frac{\pi}{2} \right) = -\ln\left(1 + \sin \frac{\pi}{2}\right) \). Since \( \sin \frac{\pi}{2} = 1 \), \( f\left( \frac{\pi}{2} \right) = -\ln(1 + 1) = -\ln 2 \). Therefore, the correct option is (2).