Let $A : D(A) \rightarrow H$ and $B : D(B) \rightarrow H$ be two unbounded self-adjoint operators that are densely defined on a Hilbert space $H$. Suppose we know that $D(A) = D(B)$. Are there sufficient conditions for the equality $D(A^k) = D(B^k)$ to be true for positive integers all integers $k \in \mathbb{Z}_+$? Is there an example where this equality fails?
I guess this is true if $A$ and $B$ also commute with each other. But is there a more general sufficient condition?
I realized there is an example why this could be generally hard.
Let $A :D(A) \rightarrow L^2(0,1)$ with $D(A) = \lbrace u \in H^2(0,1); u_x(0)=u_x(1)=0 \rbrace$ where $H^2(0,1)$ is the set of elements $L^2(0,1)$ that are least twice weakly differentiable. Additionally, for an element $a \in L^{\infty}(0,1)$ we define the multiplication operator $M_a : L^2(0,1) \rightarrow L^2(0,1)$ as $(M_af)(x)= a(x)f(x)$ for a.e $x \in (0,1)$. Then $D(A) = D(A-M_a) \subset H^2(0,1)$. Additionally, $D(A)^2 \subset H^4(0,1)$ but $D((A-M_a)^2) \not\subset H^4(0,1)$. For example, if $\mathbf{1}$ is the function taking value $1$ everywhere on $(0,1)$, then $\mathbf{1} \in D(A) = D(A-M_a)$, and $\mathbf{1} \in D(A^2)$. But $\mathbf{1} \notin D((A-M_a)^2)$ if $a$ is non-differentiable. The situation doesn't change if we replace $A$ by $A+\mathbb{I}$ with $\mathbb{I}$ being the identity operator.