The solution of the differential equation \(\displaystyle\frac{dy}{dx} + y = \cos x\) that satisfies \(y(0) = 1\) is
Answer & explanation
Correct answer: option 3
The correct answer is Option (3) → \(y = \displaystyle\frac{1}{2}\left(\sin x + \cos x + e^{-x}\right)\)
This is a linear equation with \(P = 1\) and \(Q = \cos x\). The integrating factor is \(e^x\), so
\( \displaystyle y\,e^x = \int e^x\cos x\,dx \)
Let \(I = \int e^x\cos x\,dx\). Integrating by parts twice:
\( \displaystyle I = e^x\cos x + \int e^x\sin x\,dx \)
\( \displaystyle I = e^x\cos x + e^x\sin x - I \)
\( \displaystyle I = \frac{1}{2}e^x(\sin x + \cos x) \)
So
\( \displaystyle y\,e^x = \frac{1}{2}e^x(\sin x + \cos x) + C \)
\( \displaystyle y = \frac{1}{2}(\sin x + \cos x) + Ce^{-x} \)
Using \(y(0) = 1\):
\( \displaystyle 1 = \frac{1}{2} + C \Rightarrow C = \frac{1}{2} \)
\( \displaystyle y = \frac{1}{2}\left(\sin x + \cos x + e^{-x}\right) \)
Why the other options are incorrect
Option (1) \(y = \displaystyle\frac{1}{2}\left(\sin x - \cos x + 3e^{-x}\right)\) — Incorrect. This is the solution for the right side \(\sin x\); it gives \(y' + y = \sin x\), not \(\cos x\).
Option (2) \(y = \displaystyle\frac{1}{2}\left(\cos x - \sin x + e^{-x}\right)\) — Incorrect. It has \(y(0) = 1\), but \(y' + y = -\sin x\).
Option (4) \(y = \sin x + e^{-x}\) — Incorrect. It has \(y(0) = 1\), but \(y' + y = \cos x + \sin x\).