Step 1: Standard form. \[\frac{dy}{dx} - y = \cos x\] This is a linear differential equation of the form: \[\frac{dy}{dx} + P(x) y = Q(x), P(x) = -1, \; Q(x) = \cos x\]
Step 2: Find the integrating factor (IF). \[IF = e^{\int P(x)dx} = e^{\int -1 dx} = e^{-x}\]
Step 3: Multiply through by IF. \[e^{-x}\frac{dy}{dx} - e^{-x}y = e^{-x}\cos x\] \[\implies \frac{d}{dx}(y e^{-x}) = e^{-x}\cos x\]
Step 4: Integrate both sides. \[y e^{-x} = \int e^{-x}\cos x \, dx + C\] Now, \[\int e^{-x}\cos x \, dx = \frac{e^{-x}(-\cos x + \sin x)}{2}\]
Step 5: Final solution. \[y e^{-x} = \frac{e^{-x}(\sin x - \cos x)}{2} + C\] \[y = \frac{\sin x - \cos x}{2} + Ce^{x}\]
Final Answer: \[ \boxed{y = \frac{\sin x - \cos x}{2} + Ce^{x}} \]