Commutator of $x$ and $p^2$ I have a question:
If I have to find the commutator $[x, p^2]$ (with $p= {h\over i}{d \over dx} $) the right answer is:
$[x,p^2]=x p^2 - p^2x = x p^2 -pxp + pxp - p^2x = [x,p]p + p[x,p] = 2hip$
But why can't I say:
$[x,p^2]=x p^2 - p^2x = - x h^2{d^2 \over dx^2} + h^2 {d^2 \over dx^2}x = 0$  ?
Thank you for your reply.

What you describe is a quite common situation which pops up when dealing with commutators of operators. On an appropriate space of functions $\mathcal D$ (like an $L^2$-space or the Schwartz space etc...), the operators $x$ and $p$ are given by
$$x(f)(x):=xf(x), $$
$$p(f)(x):=\frac{h}{i}\frac{df}{dx}, $$
for all $f\in \mathcal D$ and $x$ in the domain of $f$. In other words, $x(f)$ and $p(f)$ are elements in $\mathcal D$, i.e. functions. In particular $\frac{df}{dx}$ is the derivative of $f$ w.r.t. $x$ at the point $x$, by convention.
The commutator
$$[x,p]$$
is the operator that, evaluated at any $f$, gives the function $[x,p](f)$ s.t.
$$[x,p](f)(x):=\frac{h}{i}x\frac{df}{dx}-\frac{h}{i}\frac{d}{dx}(xf)=
\frac{h}{i}x\frac{df}{dx}-\frac{h}{i}x\frac{d}{dx}(f)-\frac{h}{i}f(x)=
-\frac{h}{i}f(x),  $$
or   $[x,p](f)=-\frac{h}{i}f$.
Similarly, 
$$[x,p^2]$$
is the operator that, once evaluated at any $f\in \mathcal D$, gives the function 
$[x,p^2](f)$, with
$$[x,p^2](f)(x)=-h^2x\frac{d^2f}{dx^2}+h^2\frac{d}{dx}\left(\frac{d}{dx} (xf) \right)=
-h^2x\frac{d^2f}{dx^2}+h^2\frac{d}{dx}\left(f+x\frac{df}{dx} \right)=
-h^2x\frac{d^2f}{dx^2}+h^2\frac{df}{dx}+
h^2\frac{d}{dx}\left(x\frac{df}{dx}\right)=\\
-h^2x\frac{d^2f}{dx^2}+h^2\frac{df}{dx}+
h^2\frac{df}{dx}+ h^2x\frac{d^2f}{dx^2}=2h^2\frac{df}{dx}.$$
Equivalently
$$[x,p^2](f)(x)=2hip(f)(x)$$
or
$$[x,p^2](f)=2hip(f)$$
as expected.
