$$ f(x) = 2x \cos(x)$$
We use partial integration where $2x = g$ and $\cos(x) = f'$
I know what you mean but if $ f(x) = 2x \cos(x)$, $f'(x)$ is not equal to $\cos x$. So I denote $$u(x)=2x,\qquad v^{\prime }(x)=\cos x.$$
Then
$$
\begin{eqnarray*}
u^{\prime }(x) &=&2 \\
v(x) &=&\int \cos x\ dx=\sin x.
\end{eqnarray*}
$$
From
$$
\begin{equation*}
I=\int u(x)v^{\prime }(x)\ dx=u(x)v(x)-\int u^{\prime }(x)v(x)\ dx,
\end{equation*}
$$
we get
$$
\begin{eqnarray*}
I &=&\int \underset{u(x)}{\underbrace{2x}}\cdot\text{ }\underset{v^{\prime }(x)}{\underbrace{\cos x}}dx=\underset{u(x)}{\underbrace{2x}}\cdot\underset{u(x)}{\underbrace{\sin x}}-\int \underset{u'(x)}{\underbrace{2}}\cdot\underset{v(x)}{\underbrace{\sin x}}\ dx \\
&=&2x\sin x-(-2\cos x)+C \\
&=&2x\sin x+2\cos x+C.
\end{eqnarray*}
$$
What confuses me is the term $\sin(x) \cdot d2x$
The term we got was $\sin(x) \cdot 2x$.
Added: We have selected $u(x)$ and $v(x)$ according to the LIATE rule (L ogarithm I nverse trigonometric A lgebraic T rigonometric E xponential). By doing this, we try to:
- Find easily $v(x)$ from $v'(x)$, and
- Evaluate $\int v(x)u'(x)\ dx$ easier than $\int u(x)v'(x)\ dx$.
This rule works most of the times because when we differentiate the polynomial (algebraic function) $u(x)=2x$ we get a simpler algebraic function and when we integrate the direct trigonometric function $v'(x)=\cos x$ we get another direct trigonometric function.