Evaluate the integral $(x-2) e^x$ I think this problem can be solved using integration by parts. So I set it up as $u = e^x$ and $du = e^x, dv = (x-2)$ and x = (x^2)/(2)-(2x)
But I don't think I'm getting the right answer. Are my $u$ and $v$ wrong? 
 A: You should flip the two. As a Mnemonic, remember the LIATE rule.
Exponentials should come "last"
\begin{align}
\int(x-2)\exp(x) &= (x-2)\int \exp(x) - \int \left(\frac{d}{dx}(x-2)\right) \cdot\exp(x)\\
&=(x-2)\exp(x)-\exp(x)+C\\
&=(x-3)\exp(x)+C
\end{align}
A: To integrate function $u(dv)$, the product rule can be stated as:-
$\int u(dv) = uv - \int v(du) $
The trick is to set $u$ and $dv$ such that both $du$ and $v$ are simpler functions, such that you can easily integrate $v(du)$ - the second term. 
For our case, setting $u=(x-2)$ and $dv=e^x$, results in $du=1$ and $v=e^x$, so that $v(du)$ is $e^x$, so $\int v(du)dx=\int e^xdx$ is simply $e^x$. So we have
$\int (x-2)e^xdx=(x-2)e^x-\int e^xdx=(x-2)e^x-e^x=xe^x-3e^x$
If, on the other hand, you had set $u=e^x$ and $dv=(x-2)$, $v(du)$ would be $(\frac{x^2}{2}-2x)e^x$, which is far more complicated to integrate, and you would end up with 
$\int (x-2)e^xdx=(\frac{x^2}{2}-2x)e^x-\int(\frac{x^2}{2}-2x)e^xdx$
For bounds $[5,2]$
$ \int_5^2(x-2)e^xdx=[(x-2)e^x]_5^2-\int_5^2 e^xdx=-3e^5-e^2+e^5=-2e^5-e^2$
A: 
$u = e^x, dv = (x-2)$
Are my $u$ and $v$ wrong? 

Yes, they are. With your selection of $u$ and $v$ the integration becomes more difficult. To become easier it should be the other way round, i.e $u=(x-2)$ and $dv=e^x$. 
However, I would recomment the following. First split $\int (x-2)e^{x}\,dx$ into two integrals:
\begin{equation*}
I=\int (x-2)e^{x}\,dx=\int xe^{x}\,dx-2\int e^{x}\,dx.
\end{equation*}
Then, since $\int e^{x}\,dx=e^{x}$, we are left with
\begin{equation*}
I=\int xe^{x}\,dx-2e^{x}.
\end{equation*}
The remaining integral $\int xe^{x}dx$ is easily integrable by parts, but
you should differentiate $x$ and integrate $e^{x}$, not otherwise, i.e. you should choose $u(x)=x$ and $v^{\prime }(x)=e^{x}$ (or $dv=e^{x}dx$)
\begin{equation*}
\int x\cdot e^{x}\,dx=\int x\cdot e^{x}\,dx=e^{x}x-\int
e^{x}\,dx=e^{x}x-e^{x}+C.
\end{equation*}
Combining the above results we have that
\begin{equation*}
I=\left( e^{x}x-e^{x}\right) -2e^{x}=e^{x}x-3e^{x}=\left( x-3\right) e^{x}.
\end{equation*}
A: Generally you want $u$ to be something that doesn't get more complicated when you differentiate it and $dv$ to be something that doesn't get more complicated when you antidifferentiate it.  In
$$
\underbrace{(x-2)}_u\ \ \underbrace{\ e^x\, dx\ }_{dv}\ ,
$$
differentiating $u$ gives $1$, and antidifferentiating $dv$ gives something equally complicated, not more.  Multiplying by $1$ is simple.
