Given f(x) = (ax+b) sin x + (cx+d) cos x with unknown
Given $f(x) = (ax+b)\sin x + (cx+d)\cos x$ with unknown constants $a, b, c, d$, determine them so that $f'(x) = x\cos x$.
Explanation of Method
Matching coefficients to build a prescribed derivative.
Step 1: Differentiate the general form
Apply the product rule to each term: $\frac{d}{dx}\bigl[(ax+b)\sin x\bigr] = a\sin x + (ax+b)\cos x$.
\[ \frac{d}{dx}\bigl[(cx+d)\cos x\bigr] = c\cos x - (cx+d)\sin x. \]
Step 2: Collect by $\sin x$ and $\cos x$
\[ f'(x) = \bigl(-cx + a - d\bigr)\sin x + \bigl(ax + b + c\bigr)\cos x. \tag{1} \]
Step 3: Match against $x\cos x$
The target is $0\cdot\sin x + x\cos x$. Since $\sin x$, $x\sin x$, $\cos x$ and $x\cos x$ are linearly independent, their coefficients must match one by one: \[\begin{aligned} x\sin x: &\quad -c = 0 &&\Longrightarrow\; c = 0, \\ \sin x: &\quad a-d = 0 &&\Longrightarrow\; a = d, \\ x\cos x: &\quad a = 1, \\ \cos x: &\quad b+c = 0 &&\Longrightarrow\; b = 0. \end{aligned}\]
Step 4: Solve
From the third equation $a = 1$; then $d = a = 1$, while $c = 0$ and $b = 0$.
Step 5: Verification
\[f(x) = x\sin x + \cos x \;\Longrightarrow\; f'(x) = \sin x + x\cos x - \sin x = x\cos x \;\;\checkmark\]
Result
Final answer:
\[\boxed{\,a = 1, \quad b = 0, \quad c = 0, \quad d = 1 \qquad\Longrightarrow\qquad f(x) = x\sin x + \cos x\,}\]
Remark
Remark. Read backwards, this is the integration-by-parts result $\displaystyle\int x\cos x\,dx = x\sin x + \cos x + C$. The ansatz $(ax+b)\sin x + (cx+d)\cos x$ is the standard one for integrands of the form (polynomial) × (sine or cosine): the family is closed under differentiation, which is why matching coefficients works.