TITLE: Method of Undermined coefficients
QUESTION [1 upvotes]: The following equation:
$y''+y=\cos(x)$
Solving $y''+y=0$  gives me $c_1\cos(x)+c_2\sin(x)$
Using the particular integral yp form of $a\cos(x)+b\sin(x)$ and substituting this back into the ODE
$y = a\cos(x)+b\sin(x)$,    $y'=-a\sin(x)+b\cos(x)$,  $y''=-a\cos(x)-b\sin(x)$
Plugging this back into the ODE leaves me with $0=\cos(x)$
So how is the particular solution $y=1/2x\sin(x)$ with the coefficients value of $c_1=0$ and $c_2=1/2$, and where does the $x$ come from?

REPLY [0 votes]: Let's choose a more general particular solution for $y''+y=\cos(nx)$ in the form $y_p=(ax+b)\sin(nx)+(cx+d)\cos(nx)$, with $n>0$. You can easily show
$$y_p''=−n((anx+bn+2c)\sin(nx)+(cnx+dn−2a)\cos(nx))$$
Let's plug these two into the original equation, and you get $$x\sin(nx)(-an^2+a)+\sin(nx)(-bn^2-2nc+b)+x\cos(nx)(-cn^2+c)+\cos(nx)(-dn^2+2an+d)=\cos(nx)$$
In case $n=1$, you have $1-n^2=0$, so your equation simplifies to $$-2c\sin(x)+2a\cos(x)=\cos(x)$$
The solutions are therefore $c=0$ and $a=1/2$, so your solution is $$y_p=\frac 12x\sin s$$
It is interesting to see what happens if $n\ne 1$. Then if you kook at just the coefficients of $x\sin(nx)$ you get $a(1-n^2)=0$. That means $a=0$. Similarly, for $x\cos(nx)$ you get $c=0$. You equation reduces to $$b(1-n^2)\sin(nx)+d(1-n^2)\cos(nx)=\cos(nx)$$
You have therefore $b=0$ and $d=\frac1{1-n^2}$. So no terms with $x$ multiplied with a trigonometric function. 
So the conclusion is that if the free term in the ODE is the same type as the homogeneous solution, the particular solution is the form $ax\sin x+bx\cos x$, otherwise it does not contain $x$.
{"set_name": "stack_exchange", "score": 1, "question_id": 3046675}