Solve ordinary differential equation with undetermined coefficients It's Sarah again. I have the following two kind of related linear ordinary differential equations:
$$\bigg(\frac{d^2x}{dt^2}\bigg) + x = t \cos t \quad \quad ; \quad\quad \bigg(\frac{d^3x}{dt^3}\bigg) + \bigg(\frac{dx}{dt}\bigg) = \cos t$$
I am trying to solve them by the method of undetermined coefficients. The solution to the corresponding homoegeneous equations are no problem, but when I try to find a particular solution the problems arise.
I have tried linear combinations of $t \cos t, \cos t, t \sin t, \sin t$ but they don't work. Also tried linear combinations of $t^2 \cos t, t \cos t, \cos t$, but they failed. Could you indicate some set whose span I should examine? Thanks in advance.
 A: We have
$$x'' + x = t \cos(t)$$
We find the homogeneous solution as
$$x_h(t) = c_1 \cos(t) + c_2 \sin(t)$$
We now look at the ODE's RHS and it is $t \cos(t)$ and the homogeneous solution also has a $\cos(t)$, so we would choose something that includes the sum of all trig terms up to that power of $t$, like $(a \cos(t) + b \sin(t) + t \cos(t) + t \sin(t))$. Because this shares a cosine term with the solution of the ODE, we multiply that entire expression by $t$, so we choose
$$x_p(t) = t(a \cos(t) + b \sin(t) + c~ t \cos(t) +d ~t \sin(t)) \tag 1$$
Note, if the solution had been $t^2 \cos(t)$ we would add two more $t^2$ terms and so forth.
Substituting $(1)$ into the ODE and simplifying, we have
$$2 (\sin (t) (-a-2 c t+d)+\cos (t) (b+c+2 d t)) = t\cos(t)$$
Equating like terms, we find
$$a = \dfrac{1}{4}, b = 0, c = 0, d = \dfrac{1}{4}$$
The final solution is
$$x(t) = x_h(t) + x_p(t) = c_1 \cos t + c_2 \sin(t) + \dfrac{1}{4}( t \cos(t) + t^2 \sin(t))$$
For the second problem, using the same logic, we have
$$x_p(t) = t(a \cos(t) + b \sin(t))$$
