Commutator of $p^2$ and $x$ I need to calculate $[p^2,x]$, with $p=-i\hbar\frac{d}{dx}$
This is what I've done:
$$[p,x]=-i\hbar$$
$$[p^2,x]=[p,x]p + p[p,x]$$
$$[p^2,x]=-i\hbar p - pi\hbar$$
Now here's my question: I've seen solutions to this problem doing $pi\hbar=i\hbar p$, so $[p^2,x]=-2i\hbar p$. But how can you do that if $p$ is an operator? Wouldn't we have
$pi\hbar=-i\hbar\frac{d}{dx}(i\hbar)=0$, resulting in $[p^2,x]=-i\hbar p$?
 A: $p$ and $x$ are operators, meaning that they are functions acting on a wavefunction $\Psi(x)$. So when you write $[p,x]$, you need to think of this as $$\begin{align}[p,x]\Psi(x)&=px\Psi(x)-xp\Psi(x)\\&=-i\hbar\frac d{dx}(x\Psi(x))+i\hbar x\frac d{dx}\Psi(x)\\&=-i\hbar(\frac d{dx}x)\Psi(x)-i\hbar x\frac d{dx}\Psi(x)+i\hbar x\frac d{dx}\Psi(x)\\&=-i\hbar\Psi(x)\end{align}$$
With this in mind:$$\begin{align}[p^2,x]\Psi(x)&=p^2x\Psi(x)-xp^2\Psi(x)\\&=p(px-xp)\Psi(x)+pxp\Psi(x)-xp^2\Psi(x)\\&=-i\hbar p\Psi(x)+(px-xp)p\Psi(x) \end{align}$$
Note that I can introduce temporarily a new function $\chi(x)=p\Psi(x)$ and the commutator $[p,x]$ acting on $\chi(x)$ will yield $-i\hbar\chi(x)$. Therefore $$[p^2,x]\Psi(x)=-2i\hbar p\Psi(x)$$
We can write this in short hand, ignoring $\Psi$ as $$[p^2,x]=-2i\hbar p$$
A: Writing in more details, the commutator relation is $$[p,x]=-i\hbar I$$ where $I$ is the identity operator. So $pi\hbar$ should be understood as $pi\hbar I$, the composition of the two operators $p$ and $i\hbar I$. It is not "$p$ applied to the function $i\hbar$".
