Solution (source code)

= Solution

Expand the proposed product rule without interchanging any operator factors:
$$
[A,B]C+B[A,C]=(AB-BA)C+B(AC-CA)=ABC-BCA=[A,BC].
$$
Applying this <commutator> identity with $A=x$ and $B=C=p_x$ gives
$$
\boxed{[x,p_x^2]=[x,p_x]p_x+p_x[x,p_x]=2i\hbar p_x.}
$$
For a differentiable multiplication potential, apply the other <commutator> to a test function:
$$
[p_x,V(x)]f=-i\hbar\frac d{dx}(Vf)+i\hbar Vf'=-i\hbar V'f.
$$
Therefore
$$
\boxed{[p_x,V(x)]=-i\hbar V'(x).}
$$
These operator equalities are understood on a common domain where the indicated products and derivatives are defined, with the boundary conditions appropriate to the state.