How to differentiate this integral? Given
$$g(x)=\int_{0}^{x} (x-t)e^{t}dt$$ find out $g''(x)$ 
I thought of using Lebnitz theorem to differentiate it but using Lebnitz I get this $g'(x)=1\cdot (x-x)e^{x}=0$ I don't know how to find the second order derivative of this function.
 A: Your zero Leibniz partial result comes from the upper limit of the integral. You forgot the contribution 
$$\int_0^x \frac{\partial}{\partial x}((x-t)e^{t}) dt = \int_0^x e^t d t=e^x-1$$
So $g'(x)= e^x-1\;$ and $g''(x)= e^x.$
The Leibniz rule for your case is (see e.g. http://mathworld.wolfram.com/LeibnizIntegralRule.html)
$$\frac{\partial}{\partial x}\int_{a(x)}^{b(x)} f(t,x) dt = 
\int_{a(x)}^{b(x)}
 \frac{\partial}{\partial x} f(t,x) dt + f(b(x),x)\frac{\partial b(x)}{\partial x}
-f(a(x),x)\frac{\partial a(x)}{\partial x}
$$
With $b(x) = x, \; f(t,x)=(x-t)e^{t}\; $
the mentioned contribution is the first term, your's is the second and the third is obviously zero because $a(x)\equiv 0$.
A: Write:
$$\forall x\in\mathbb{R},\ g(x)=x\int_0^x\mathrm{e}^t\,\mathrm{d}t-\int_0^x t\mathrm{e}^t\,\mathrm{d}t.$$
This can be computed explicitly, but we don't really mind, as we can differentiate using the product rule (and the integrals that appear are understood as antiderivatives):
$$\forall x\in\mathbb{R},\ g'(x)=\int_0^x\mathrm{e}^t\,\mathrm{d}t+x\mathrm{e}^x-x\mathrm{e}^x=\int_0^x\mathrm{e}^t\,\mathrm{d}t$$
and hence
$$\forall x\in\mathbb{R},\ g''(x)=\mathrm{e}^x.$$
