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$?