Find the general solution of y'' + n^2 y = a x sin(nx) +…
Find the general solution of $y'' + n^2 y = a x \sin(nx) + b\cos(nx)$, where $a$, $b$, $n$ are given constants ($n\neq0$).
Explanation of Method
The forcing frequency matches the natural frequency exactly, so the standard undetermined-coefficients trial must be multiplied by $x$; the resonant particular solution is worked out for general constants $a$, $b$, $n$.
Step 1: Characteristic equation
Substituting $y=e^{rx}$ into the homogeneous equation $y''+n^2y=0$ gives
\[ r^2+n^2=0 \implies r=\pm ni. \]
Step 2: Homogeneous solution
\[ Y_h = C_1\cos(nx) + C_2\sin(nx). \]
Step 3: Form of the right-hand side
The forcing term $ax\sin(nx)+b\cos(nx)$ has the general shape $e^{\alpha x}\bigl[P(x)\cos\beta x+Q(x)\sin\beta x\bigr]$ with $\alpha=0$, $\beta=n$: the coefficient of $\cos(nx)$ is the constant $P(x)=b$ (degree $0$), and the coefficient of $\sin(nx)$ is $Q(x)=ax$ (degree $1$). The working degree of the trial polynomials is $\max(0,1)=1$.
Step 4: Resonance check
The associated complex exponent is $\alpha+i\beta=ni$, which coincides exactly with the characteristic root $r=ni$ found in Step 1 (multiplicity $s=1$). Because of this resonance, the usual degree-$1$ trial polynomials times $\cos(nx),\sin(nx)$ must be multiplied by an extra factor $x$:
\[ y^{*} = x\Bigl[(A_1x+A_0)\cos(nx) + (B_1x+B_0)\sin(nx)\Bigr]. \]
Step 5: Substituting and matching coefficients
Differentiating $y^{*}$ twice and substituting into $y''+n^2y=ax\sin(nx)+b\cos(nx)$, the terms group by the four independent functions $x\cos nx$, $x\sin nx$, $\cos nx$, $\sin nx$. Matching coefficients on each side yields the linear system
\[ x\cos nx:\ 4nB_1=0, \qquad x\sin nx:\ -4nA_1=a, \qquad \cos nx:\ 2A_1+2nB_0=b, \qquad \sin nx:\ 2B_1-2nA_0=0. \]
Solving in order: \[B_1=0, \qquad A_1=-\frac{a}{4n}, \qquad A_0=\frac{B_1}{n}=0, \qquad 2nB_0=b-2A_1=b+\frac{a}{2n} \implies B_0=\frac{b}{2n}+\frac{a}{4n^2}.\]
Step 6: Assembling the particular solution
\[ y^{*} = x\left[-\frac{a}{4n}\,x\cos(nx) + \left(\frac{b}{2n}+\frac{a}{4n^2}\right)\sin(nx)\right] = -\frac{a}{4n}\,x^2\cos(nx) + \frac{2bn+a}{4n^2}\,x\sin(nx). \]
Step 7: General solution
The solution is recorded in the result below.
Result
Final answer:
\[\boxed{\,y = C_1\cos(nx) + C_2\sin(nx) - \frac{a}{4n}\,x^2\cos(nx) + \frac{2bn+a}{4n^2}\,x\sin(nx)\,}\]
Remark
Why the resonance matters. Because the forcing frequency $n$ exactly matches the natural frequency of the homogeneous oscillator $y''+n^2y=0$, a plain (non-$x$-multiplied) trial of degree $1$ would be annihilated by the operator $D^2+n^2$ and could never balance the $ax\sin(nx)$ term. Multiplying by $x$ is what produces the characteristic secular growth $x\cos(nx)$, $x\sin(nx)$ seen in resonant forced oscillators.