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.
 A: 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.
A: You treat $x$ like a scalar when in fact it is an operator. Let's write it as $\hat{x}$ instead. Then $[\hat{x}, p^2]$ is also an operator, so let's see what happens when we apply an arbitrary function $\psi$ to it.
\begin{align}
[\hat{x},p^2]\psi&=\left(\hat{x}p^2-p^2\hat{x}\right)\psi \\
&=-xh^2\frac{\mathrm{d}^2}{\mathrm{d}x^2}\psi+h^2\frac{\mathrm{d}^2}{\mathrm{d}x^2}(x\psi) \\
&=-xh^2\frac{\mathrm{d}^2}{\mathrm{d}x^2}\psi+h^2x\frac{\mathrm{d}^2}{\mathrm{d}x^2}\psi+2h^2\frac{\mathrm{d}}{\mathrm{d}x}\psi \\
&=2h^2\frac{\mathrm{d}}{\mathrm{d}x}\psi \\
&=2hi\frac{h}{i}\frac{\mathrm{d}}{\mathrm{d}x}\psi=2hip\psi
\end{align}
so that $[\hat{x},p^2]=2hip$.
A: You can calculate the commutator for 3 different operators, say $\hat{A}$, $\hat{B}$ and $\hat{C}$: $ [\hat{A},\hat{B }\hat{C}]$. Defining the following operator, $\hat{D}\equiv\hat{B}\hat{C}$, so, the original commutator turns out to be:
$$[\hat{A},\hat{D}]=\hat{A}\hat{D}-\hat{D}\hat{A}$$
Coming back to $\hat{B}\hat{C}$, the commutator we want originally is,
$$[\hat{A},\hat{B }\hat{C}]=\hat{A}\hat{B }\hat{C}-\hat{B }\hat{C}\hat{A}$$
Now, "summing" a zero to the expression: $\hat{B }\hat{A}\hat{C}-\hat{B }\hat{A}\hat{C}$.
$$[\hat{A},\hat{B }\hat{C}]=\hat{A}\hat{B }\hat{C}-\hat{B }\hat{C}\hat{A}+\hat{B }\hat{A}\hat{C}-\hat{B }\hat{A}\hat{C}$$
But,
$$-\hat{B }\hat{C}\hat{A}+\hat{B }\hat{A}\hat{C}=\hat{B }(\hat{A}\hat{C}-\hat{C}\hat{A})=\hat{B }[\hat{A },\hat{C }]$$
and,
$$\hat{A}\hat{B }\hat{C}-\hat{B }\hat{A}\hat{C}=(\hat{A}\hat{B }-\hat{B }\hat{A})\hat{C}=[\hat{A },\hat{B }]\hat{C }$$
We conclude by replacing the last two equations into our original commutator that,
$$[\hat{A},\hat{B }\hat{C}]=\hat{B }[\hat{A },\hat{C }]+[\hat{A },\hat{B }]\hat{C }$$
Now defining: $\hat{A}\equiv\hat{X}$ and $\hat{B }\hat{C}\equiv\hat{P}^2$.
$$[\hat{X},\hat{P}^2]=\hat{P}[\hat{X},\hat{P }]+[\hat{X },\hat{P}]\hat{P}$$
As $[\hat{X },\hat{P}]=i\hbar$, we find.
$$[\hat{X},\hat{P}^2]=2i\hbar\hat{P}$$
A: Another way to calculate that commutator using $[x,p]=i\hbar$ and introducing intermediate commutators:
$$\begin{align} 
[x,p^2] 
& =xp^2-px^2=xp^2-ppx+pxp-pxp\\  
&=xp^2-pxp+p(xp-px)\\  
& =xp^2-pxp+p[x,p]\\  
& =xp^2 -pxp+i\hbar p\\  
&= xp^2-pxp+xpp-xpp+i\hbar p\\ 
&=xp^2-xp^2+(xp-px)p+i\hbar p\\  
& = 2i\hbar p
\end{align}$$
A: You can 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$
But that will not be equal to zero, since (1): $x h^2{d^2 \over dx^2}$ is not equal to (2): $h^2 {d^2 \over dx^2}x$.
It's clear that in (1), the differential operator is not operating on anything. But in (2), it's operating on $x$. So, we can write it in the form:
$[x,p^2]=x p^2 - p^2x = - x h^2{d^2 \over dx^2} + h^2 {d^2 \over dx^2}x = -xh^2{d^2\over dx^2} + h^2$. 
