Problem 139
Easy Nonhomogeneous Equations

Find the general solution of y'' + y = sin x

Find the general solution of $y'' + y = \sin x$.

Explanation of Method

The forcing frequency β=1 matches the homogeneous roots r=±i exactly, so the trial xAcos x+Bsin x) picks up an extra factor of x.

Step 1: Homogeneous solution

$r^2+1=0 \implies r=\pm i$, $Y_h = C_1\cos x + C_2\sin x$.

Step 2: Choose the trial form

The right-hand side is $\sin\beta x$ with $\alpha=0,\ \beta=1$, so we test whether $r=\pm i$ is a root. It is — with multiplicity $s=1$ — so the trial $A\cos x+B\sin x$ must be multiplied by $x$:

\[ y^* = x(A\cos x+B\sin x). \]

Step 3: Substitute

\[ y^{*\prime}=(A\cos x+B\sin x)+x(-A\sin x+B\cos x). \]

\[ y^{*\prime\prime}=-2A\sin x+2B\cos x - x(A\cos x+B\sin x). \]

Since the $x(A\cos x+B\sin x)$ term in $y^{*\prime\prime}$ exactly cancels the term $x(A\cos x+B\sin x)=y^*$ when substituted: \[y^{*\prime\prime}+y^* = -2A\sin x+2B\cos x - x(A\cos x+B\sin x) + x(A\cos x+B\sin x) = -2A\sin x+2B\cos x.\]

\[ -2A\sin x+2B\cos x=\sin x. \]

Step 4: Match coefficients

\[ \sin x:\ -2A=1\implies A=-\tfrac12, \qquad \cos x:\ 2B=0\implies B=0. \]

\[ y^* = -\frac{x\cos x}{2}. \]

Step 5: Verify

\[ y^{*\prime}=-\frac{\cos x}{2}+\frac{x\sin x}{2}, \qquad y^{*\prime\prime}=\sin x+\frac{x\cos x}{2}. \]

\[ y^{*\prime\prime}+y^* = \left(\sin x+\frac{x\cos x}{2}\right) - \frac{x\cos x}{2} = \sin x.\ \checkmark \]

Step 6: General solution

The solution is recorded in the result below.


Result

Final answer:

\[\boxed{\,y = C_1\cos x + C_2\sin x - \frac{x\cos x}{2}\,}\]