Find the general solution of y'' + y = xe^(x)cos x
Find the general solution of $y'' + y = xe^{x}\cos x$.
Explanation of Method
A non-resonant exponential shift D→D+1 reduces the four-parameter trial to a linear system matched against x cos x, x sin x, cos x, sin 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: Set up the trial and the shift
The right-hand side has the general form $e^{\alpha x}P_n(x)\cos\beta x$ with $\alpha=1,\ \beta=1$, and $P_1(x)=x$ of degree $n=1$. The associated exponents $r=1\pm i$ are checked against the roots $\{\pm i\}$: not a match, so $s=0$ and the trial keeps its full linear coefficients:
\[ y^*=e^x\bigl[(A_1x+A_0)\cos x+(B_1x+B_0)\sin x\bigr] = e^x v. \]
Shifting $D\to D+1$ in $L(D)=D^2+1$ via $L(D)[e^xv]=e^xL(D+1)[v]$: \[L(D+1)=(D+1)^2+1=D^2+2D+2, \qquad\text{so}\qquad v''+2v'+2v = x\cos x.\]
Step 3: Differentiate the trial
With $v=(A_1x+A_0)\cos x+(B_1x+B_0)\sin x$: $v' = (A_1+B_1x+B_0)\cos x + (B_1-A_1x-A_0)\sin x$, $v'' = (2B_1-A_1x-A_0)\cos x + (-2A_1-B_1x-B_0)\sin x$.
Step 4: Match coefficients
Substituting into $v''+2v'+2v=x\cos x$ and collecting the four independent basis functions $x\cos x,\ x\sin x,\ \cos x,\ \sin x$ (matching each against its coefficient on the right, which is $1,0,0,0$ respectively):
\[ x\cos x:\ A_1+2B_1=1 \qquad x\sin x:\ -2A_1+B_1=0 \]
\[ \cos x:\ 2A_1+2B_1+A_0+2B_0=0 \qquad \sin x:\ -2A_1+2B_1-2A_0+B_0=0 \]
From the first pair: $B_1=2A_1$, so $A_1+4A_1=1\Rightarrow A_1=\dfrac15,\ B_1=\dfrac25$. Substituting these into the second pair: $A_0+2B_0=-\frac65, \qquad -2A_0+B_0=-\frac25.$
Solving this $2\times2$ system: from the second equation $B_0=2A_0-\dfrac25$; substituting, $A_0+2\!\left(2A_0-\dfrac25\right)=-\dfrac65 \Rightarrow 5A_0=-\dfrac25 \Rightarrow A_0=-\dfrac{2}{25}$, and then $B_0=-\dfrac{4}{25}-\dfrac{10}{25}=-\dfrac{14}{25}$.
Step 5: Assemble and verify
\[ v = \left(\frac{x}{5}-\frac{2}{25}\right)\cos x + \left(\frac{2x}{5}-\frac{14}{25}\right)\sin x = \frac{1}{25}\Bigl[(5x-2)\cos x+(10x-14)\sin x\Bigr]. \]
Substituting back confirms $v''+2v'+2v=x\cos x$ exactly, so $y^*=e^xv$.
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{e^{x}}{25}\Bigl[(5x-2)\cos x+(10x-14)\sin x\Bigr]\,}\]