Is divergence operator non-associative in QM? In A Condensed Course of Quantum Mechanics by P. Cejnar, page 38, there is an equation which says:
$$
    \left[ \hat{\vec{p}} - q \vec{A}(\hat{\vec{x}}) \right]^2
    =
    \underbrace{\hat{\vec{p}}^2}_{-\hbar^2 \Delta}
    \underbrace{-q \left[ \hat{\vec{p}} \cdot \vec{A}(\hat{\vec{x}}) + \vec{A}(\hat{\vec{x}}) \cdot \hat{\vec{p}} \right]}_{\begin{array}{l}
        + i \hbar q \left[ \vec{\nabla} \cdot \vec{A} + \vec{A} \cdot \vec{\nabla} \right] = \\[2pt]
        + i \hbar q \left[ (\vec{\nabla} \cdot \vec{A}) + 2\vec{A} \cdot \vec{\nabla} \right]        
    \end{array}}
    + q^2 \vec{A}(\hat{\vec{x}})^2.
$$
The part
$$\vec{\nabla} \cdot \vec{A} + \vec{A} \cdot \vec{\nabla} = \left( \vec{\nabla} \cdot \vec{A} \right) + 2 \vec{A} \cdot \vec{\nabla}$$
seems really weird to me, at least notation-wise. I understand how this follows from the chain rule
$$
\left( \vec{\nabla} + \vec{A} \right)^2 \psi = \Delta\psi + \left(\vec{\nabla}\cdot\vec{A}\right)\psi + 2 \vec{A}\cdot\vec{\nabla}\psi + A^2\psi
$$
but I really struggle to make sense of the refinement in the sense of operators, without the $\psi$. The way I would approach this would be saying that “$\vec{\nabla}\cdot$” is the divergence operator (which should be a linear operator afaik) and saying that “$\vec{A}$” is an operator in the sense of multiplication by scalar. These operators would act on the following spaces:
$$
\vec{\nabla}\cdot: \mathcal{H}^3 \to \mathcal{H} \\
\vec{A}: \mathcal{H} \to \mathcal{H}^3
$$
The first obvious observation then would be that they are not associative:
$$
\vec{\nabla}\cdot \left( \vec{A} \psi \right) \neq \left( \vec{\nabla} \cdot \vec{A} \right) \psi,
$$
since
$$
\mathrm{div}(\vec{A} \psi) \neq \mathrm{div}(\vec{A}) \psi.
$$
This shouldn't ever happen to linear operators, right? What am I missing?
The next weird thing is that “$\vec{\nabla}\cdot\vec{A}$” and “$(\vec{\nabla}\cdot\vec{A})$” don't mean the same thing. While the first denotes an operator mapping $\psi \mapsto \mathrm{div}(\vec{A}\psi)$, the second is supposed to mean $\psi \mapsto \mathrm{div}(\vec{A})\psi$. I guess it could be formalized that for operators $A, B$ the composition $AB$ really means $\psi \mapsto A(B\psi)$ and since most operators are associative, we wouldn't notice. But still, it seems weird and I can't think of a way to write $\vec{\nabla}\cdot\vec{A}$ without this glaring abuse of notation…
 A: Introduction
Quantum Mechanics has many different mathematical objects that are written the same way in the typical physicist's notation. This is not a problem if both the writer and the reader know what meaning was intended, but it can be quite difficult for the freshmen to interpret. Disambiguating all the different meanings is so tiresome that not even mathematical physicists do it properly, but I'll try to be very pedantic in order to highlight all the nuances.
Pedantic notation
It is clear from the equation, that the wavefunction is defined on some part of the 3-dimensional space $\Omega \subseteq \mathbb{R}^3$. Therefore, the Hilbert space we'll be working with is $\mathcal{H} = L^2(\Omega)$. We will use the notation $\mathscr{L}(\mathcal{H})$ to signify the set of all operators from (a dense subspace of) $\mathcal{H}$ to $\mathcal{H}$.
First, we will introduce the multiplication operator. Let $f \in C^\infty(\Omega)$. We define an operator $\hat M_f \in \mathscr{L}(\mathcal{H})$ by
$$
\big( \, \hat M_f \, \psi \, \big)(x) = f(x) \, \psi(x) \: .
$$
There's really nothing special about it, the operator just takes a function $\psi$ and multiplies it by another function $f$. A common physicist would write this just as $f$ or $\hat f$. However, $\hat M_f$ will help us better differentiate between functions and operators.
The multiplication operator has an interesting commutation relation with a the derivative:
$$
\Big[ \frac{\partial}{\partial x}, \; \hat{M}_f \Big]
= \frac{\partial}{\partial x} \hat{M}_f
- \hat{M}_f \frac{\partial}{\partial x}
= \hat{M}_{\frac{\partial}{\partial x} f}
$$
You can check this by applying it to $\psi$.
The equation in question is complicated by the fact that we go from scalars to vectors and back. To properly distinguish the objects, we will give the letters nice hats and arrows:
$$
\begin{align*}
B &\in \mathcal{H} \text{ or } C^\infty(\mathbb{\Omega}) \\[5pt]
\vec{B} &\in \mathcal{H}^3 \text{ or } C^\infty(\mathbb{\Omega})^3 \\[5pt]
\hat{B} &\in \mathscr{L}(\mathcal{H}) \\[5pt]
\hat{\vec{B}} &\in \mathscr{L}(\mathcal{H})^3
\end{align*}
$$
The multicomponent operator $\hat{\vec{B}}$ is really just a triplet of operators $\big( \hat B_x, \hat B_y, \hat B_z \big)$.
It is quite straightforward to generalize the multiplication operator to vectors. Let $\vec A \in C^\infty(\mathbb{\Omega})^3$, we define an operator $\hat{\vec M}_{\vec A} \in \mathscr{L}(\mathcal{H})^3$ by
$$
\hat{\vec M}_{\vec A} = \begin{pmatrix}
  \hat M_{A_x} \\
  \hat M_{A_y} \\
  \hat M_{A_z}
\end{pmatrix}
$$
We also extend the dot product to operators:
$$
\hat{\vec{A}} \cdot \hat{\vec{B}} = \begin{pmatrix} \hat{A}_x \\ \hat{A}_y \\ \hat{A}_z \end{pmatrix} \cdot \begin{pmatrix} \hat{B}_x \\ \hat{B}_y \\ \hat{B}_z \end{pmatrix} = \hat{A}_x\hat{B}_x + \hat{A}_y\hat{B}_y +  \hat{A}_z\hat{B}_z,
$$
but now, instead of multiplication, the end result means composition of operators. The notation $\hat{\vec{B}}\vphantom{B}^2$ obviously means $\hat{\vec{B}} \cdot \hat{\vec{B}}$. Finally, we define the operator $\hat{\vec\nabla}$ as
$$
\hat{\vec\nabla} = \begin{pmatrix}
  \frac{\partial}{\partial x} \\
  \frac{\partial}{\partial y} \\
  \frac{\partial}{\partial z}
\end{pmatrix}
$$
Simplifying the equation
Now we're well equipped for the equation in question.
Since $\vec{A}$ is a (smooth) vector field, not an operator, we need to replace it by $\hat{\vec{M}}_{\vec A}$. Then we get:
$$
\begin{align*}
\left( \hat{\vec{\nabla}} + \hat{\vec{M}}_{\vec A} \right)^2 &=
\left( \hat{\vec{\nabla}} + \hat{\vec{M}}_{\vec A} \right) \cdot
\left( \hat{\vec{\nabla}} + \hat{\vec{M}}_{\vec A} \right)
\\
&= \hat{\vec{\nabla}} \!\cdot\! \hat{\vec{\nabla}} \;+\; \hat{\vec{\nabla}} \!\cdot\! \hat{\vec{M}}_{\vec A} \;+\; \hat{\vec{M}}_{\vec A} \cdot\! \hat{\vec{\nabla}} \;+\; \hat{\vec{M}}_{\vec A} \cdot\! \hat{\vec{M}}_{\vec A}
\\
\hphantom{|}
\\
\hat{\vec{\nabla}} \cdot \hat{\vec{\nabla}} &= \frac{\partial}{\partial x}\frac{\partial}{\partial x} + \frac{\partial}{\partial y}\frac{\partial}{\partial y} + \frac{\partial}{\partial z}\frac{\partial}{\partial z} = \hat{\Delta}
\\
\hphantom{|}
\\
\hat{\vec{M}}_{\vec A} \cdot \hat{\vec{M}}_{\vec A} &= \hat{M}_{A_x} \hat{M}_{A_x} + \hat{M}_{A_y} \hat{M}_{A_y} + \hat{M}_{A_z} \hat{M}_{A_z} = \hat{M}_{\left\|\vec{A}\right\|^2}
\\
\hphantom{|}
\\
\hat{\vec{M}}_{\vec A}\cdot\hat{\vec{\nabla}} &= \hat{M}_{A_x} \frac{\partial}{\partial x} + \hat{M}_{A_y} \frac{\partial}{\partial y} + \hat{M}_{A_z} \frac{\partial}{\partial z}
\end{align*}
$$
Since there is no point in expanding $\hat{\vec{M}}_{\vec A}\cdot\hat{\vec{\nabla}}$, as there is clearly no way to simplify it further, we chose to denote it with $\hat\nabla_{\!\vec A}$. If you think about it for a bit, it is the directional derivative operator in the direction of $\vec A$. Now to the last part:
$$
\begin{align*}
\hat{\vec{\nabla}} \cdot \hat{\vec{M}}_{\vec A}
&= \frac{\partial}{\partial x}\hat{M}_{A_x} + \frac{\partial}{\partial y}\hat{M}_{A_y} + \frac{\partial}{\partial z}\hat{M}_{A_z}
\\
&= \left( \hat{M}_{\frac{\partial}{\partial x} A_x} + \hat{M}_{\frac{\partial}{\partial y} A_y} + \hat{M}_{\frac{\partial}{\partial z} A_z} \right) + \left(\hat{M}_{A_x}\frac{\partial}{\partial x} + \hat{M}_{A_y}\frac{\partial}{\partial y} + \hat{M}_{A_z}\frac{\partial}{\partial z} \right).
\end{align*}
$$
This follows from the commutation relation of $\hat M_f$ and a derivative. Now we recognize that on the left side, there's the divergence of the vector field $\vec{A}$, while on the right side that's our familiar $\hat\nabla_{\!\vec A}$. Thus we conclude:
$$
\hat{\vec{\nabla}}\cdot\hat{\vec{M}}_{\vec A} = \hat{M}_{\operatorname{div} \vec{A}} + \hat\nabla_{\!\vec A}.
$$
Finally, putting all this together results in:
$$
\left( \hat{\vec{\nabla}} + \hat{\vec{M}}_{\vec A} \right)^2 =
\hat{\Delta} + \hat{M}_{\operatorname{div} \vec{A}} + 2\,\hat\nabla_{\!\vec A} + \hat{M}_{\left\|\vec{A}\right\|^2} \: ,
$$
which is our desired result.
So no, divergence is not non-associative. There are just two very different operators – directional derivative $\hat\nabla_{\!\vec A}$ and multiplication by divergence $\hat{M}_{\operatorname{div} \vec{A}}$ – which are written the same way due to imperfect notation.
A: This should help you:
$$\nabla\cdot(\varphi \vec{A}) = (\nabla\varphi) \cdot \vec{A} + \varphi (\nabla\cdot\vec{A})$$
The problem is that the book is a bit confusing. Put a $\varphi$ do right side of your expression and u will understand why $$(\nabla \cdot \vec{A})\neq \nabla \cdot \vec{A}$$
A: 
The part $$\vec{\nabla} \cdot \vec{A} + \vec{A} \cdot \vec{\nabla} =
 \left( \vec{\nabla} \cdot \vec{A} \right) + 2 \vec{A} \cdot
 \vec{\nabla}$$ seems really weird to me, at least notation-wise.

Put a $\psi$ on the side and you will understand for sure. The textbook is unfortunately very unclear while explaining the notations and this here is a classical example. Let me redo the calculation again.
$$
\left( \vec{\nabla} + \vec{A} \right)^2 \psi$$
$$=\left( \vec{\nabla} + \vec{A} \right)\left( \vec{\nabla} + \vec{A} \right) \psi$$
$$=\left( \vec{\nabla} + \vec{A} \right)\left( \vec{\nabla}\psi + \vec{A}\psi \right) $$
$$=\vec{\nabla}\left( \vec{\nabla}\psi + \vec{A}\psi \right) + \vec{A}\left( \vec{\nabla}\psi + \vec{A}\psi \right) $$
$$= \nabla^2\psi + \vec{\nabla}\cdot\left(\vec{A}\psi\right) + \vec{A}\cdot\left(\vec{\nabla}\psi\right) + A^2\psi$$
$$= \nabla^2\psi + \underbrace{\left(\vec{\nabla}\cdot\vec{A}\right)\psi+\vec{A}\cdot\left(\vec{\nabla}\psi\right)}_{\vec{\nabla}\cdot\left(\vec{A}\psi\right)} + \vec{A}\cdot\left(\vec{\nabla}\psi\right) + A^2\psi$$
$$= \nabla^2\psi + \left(\vec{\nabla}\cdot\vec{A}\right)\psi + 2\vec{A}\cdot\left(\vec{\nabla}\psi\right) + A^2\psi$$
That is, without the $\psi$, speaking clearly in just operator language, we get
$$\left( \vec{\nabla} + \vec{A} \right)^2= \nabla^2 + \left(\vec{\nabla}\cdot\vec{A}\right) + 2\vec{A}\cdot \vec{\nabla} + A^2$$
This is what the author tried to convey here.
Hope this helps you.
