Basic idea
U-substitution is the reverse of the derivative chain rule. This is important when integrating an expression while chain rule is important while differentiating.
Notice that $\cos(x)$ is the derivative of $\sin(x)$. We can replace $\sin(x)$ with $u(x)$. $$\int u'(x) e^{u(x)}\, \mathrm{d}x$$ We rearrange to write this: $$\int e^{u(x)}\, \boxed{u'(x)\mathrm{d}x}$$ Because it's the opposite of the chain rule, this equals $$e^{u(x)} + C = e^{\sin(x)} + C $$
Examples
David Witten