\section{Derivatives of the potential}
\label{sec:pot_derivatives}

For completeness, we give here the full expression for the first few
derivatives of the potential that are used in our FMM scheme. We use
the notation $\mathbf{r}=(r_x, r_y, r_z)$, $r = |\mathbf{r}|$, $u=r/H$
and $x=2r/r_s$. We also assume $H \ll r_s$. We can construct the higher order derivatives by
successively applying the "chain rule". We show representative
examples of the first few relevant ones here split by order. We start
by constructing derivatives of the truncated potentials:

\begin{align}
  \alpha(x) &= \left(1 + e^x\right)^{-1}  \nonumber \\
  \chi(r, r_s) &= 2\left(1 - e^{2r/r_s}\alpha(2r/r_s) \right) \nonumber \\
  \chi'(r, r_s) &= \frac{2}{r_s}\left(2\alpha(x)^2 - 2\alpha(x)\right) \nonumber \\
  \chi''(r, r_s) &= \frac{4}{r_s^2}\left(4\alpha(x)^3 - 6\alpha(x)^2 + 2\alpha(x)\right) \nonumber \\
  \chi^{(3)}(r, r_s) &= \frac{8}{r_s^3} \left(12\alpha(x)^4 - 24\alpha(x)^3 + 14\alpha(x)^2 -2 \alpha(x)\right) \nonumber \\
  \chi^{(4)}(r, r_s) &= \frac{16}{r_s^4} \left(48\alpha(x)^5 - 120\alpha(x)^4 + 100\alpha(x)^3 -30 \alpha(x)^2 + 2\alpha(x)\right) \nonumber \\ 
  \chi^{(5)}(r, r_s) &= \frac{32}{r_s^5} \left(240\alpha(x)^6 - 720\alpha(x)^5 + 780\alpha(x)^4 - 360\alpha(x)^3 + 62\alpha(x)^2 - 2\alpha(x) \right) \nonumber
\end{align}
We can now construct common quantities that appear in derivatives of
multiple orders:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{align}
  \mathsf{\tilde{D}}_{1}(r, r_s, H) =
  \left\lbrace\begin{array}{rcl}
  \left(-3u^7 + 15u^6 - 28u^5 + 21u^4 - 7u^2 + 3\right)\times  H^{-1} & \mbox{if} & u < 1,\\
  %r^{-1} & \mbox{if} & u \geq 1,
  \chi(r, r_s) \times r^{-1} & \mbox{if} & u \geq 1,
  \end{array}
  \right.\nonumber
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{align}
  \mathsf{\tilde{D}}_{3}(r, r_s, H) =
  \left\lbrace\begin{array}{rcl}
  -\left(21u^5 - 90u^4 + 140u^3 -84u^2 +14\right)\times  H^{-3}& \mbox{if} & u < 1,\\
  %-1 \times r^{-3} & \mbox{if} & u \geq 1,
  \left(r\chi'(r, r_s) - \chi(r, r_s)\right) \times r^{-3} & \mbox{if} & u \geq 1, 
  \end{array}
  \right.\nonumber
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{align}
  \mathsf{\tilde{D}}_{5}(r, r_s, H) =
  \left\lbrace\begin{array}{rcl}
  \left(-105u^3 + 360u^2 - 420u + 168\right)\times  H^{-5}& \mbox{if} & u < 1,\\
  %3\times r^{-5} & \mbox{if} & u \geq 1,
  \left(r^2\chi''(r, r_s) - 3r\chi'(r, r_s) + 3\chi(r, r_s) \right)\times r^{-5} & \mbox{if} & u \geq 1, 
  \end{array}
  \right.\nonumber
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{align}
  \mathsf{\tilde{D}}_{7}(r, r_s, H) =
  \left\lbrace\begin{array}{rcl}
  -\left(315u - 720 + 420u^{-1}\right)\times  H^{-7} & \mbox{if} & u < 1,\\
  %-15\times r^{-7} & \mbox{if} & u \geq 1,
  \left(r^3\chi^{(3)}(r, r_s) - 6r^2\chi''(r, r_s)+15r\chi'(r, r_s)-15\chi(r, r_s)\right) \times r^{-7} & \mbox{if} & u \geq 1, 
  \end{array}
  \right.\nonumber
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{align}
  \mathsf{\tilde{D}}_{9}(r, r_s, H) =
  \left\lbrace\begin{array}{rcl}
  \left(-315u^{-1} + 420u^{-3}\right)\times  H^{-9}& \mbox{if} & u < 1,\\
  %105\times r^{-9} & \mbox{if} & u \geq 1.
  \left(r^4\chi^{(4)}(r, r_s) - 10r^3\chi^{(3)} + 45r^2\chi''(r, r_s) - 105r\chi'(r, r_s) + 105\chi(r, r_s) \right) \times r^{-9} & \mbox{if} & u \geq 1
  \end{array}
  \right.\nonumber
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{align}
  \mathsf{\tilde{D}}_{11}(r, r_s, H) =
  \left\lbrace\begin{array}{rcl}
  -\left(315u^{-3} - 1260u^{-5}\right)\times  H^{-11}& \mbox{if} & u < 1,\\
  %-945\times r^{-11} & \mbox{if} & u \geq 1.
  \left(r^5\chi^{(5)}(r, r_s) - 15r^4\chi^{(4)}(r, r_s) + 105r^3\chi^{(3)}(r, r_s) - 420r^2\chi''(r, r_s) + 945r \chi'(r, r_s) - 945\chi(r, r_s)\right) \times r^{-11} & \mbox{if} & u \geq 1.
  \end{array}
  \right.\nonumber
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Starting from the potential (Eq. \ref{eq:fmm:potential},
reproduced here for completeness), we can now build all the relevent derivatives
\begin{align}
  \mathsf{D}_{000}(\mathbf{r}) = \varphi (\mathbf{r}, r_s, H) =
    \mathsf{\tilde{D}}_{1}(r, r_s, H) \nonumber
\end{align}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent\rule{6cm}{0.4pt}
\begin{align}
  \mathsf{D}_{100}(\mathbf{r}) = \frac{\partial}{\partial r_x} \varphi (\mathbf{r}, r_s, H) =
    r_x \mathsf{\tilde{D}}_{3}(r, r_s, H) \nonumber
\end{align}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent\rule{6cm}{0.4pt}
\begin{align}
\mathsf{D}_{200}(\mathbf{r}) = \frac{\partial^2}{\partial r_x^2} \varphi (\mathbf{r}, r_s, H) = 
r_x^2 \mathsf{\tilde{D}}_{5}(r, r_s, H) +
\mathsf{\tilde{D}}_{3}(r, r_s, H)\nonumber
\end{align}

\begin{align}
\mathsf{D}_{110}(\mathbf{r}) = \frac{\partial^2}{\partial r_x\partial r_y} \varphi (\mathbf{r}, r_s, H) = 
   r_x r_y \mathsf{\tilde{D}}_{5}(r, r_s, H) \nonumber
\end{align}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent\rule{6cm}{0.4pt}
\begin{align}
\mathsf{D}_{300}(\mathbf{r}) = \frac{\partial^3}{\partial r_x^3} \varphi (\mathbf{r}, r_s, H) = 
  r_x^3 \mathsf{\tilde{D}}_{7}(r, r_s, H)
  + 3 r_x \mathsf{\tilde{D}}_{5}(r, r_s, H) \nonumber
\end{align}

\begin{align}
\mathsf{D}_{210}(\mathbf{r}) = \frac{\partial^3}{\partial r_x^2 r_y} \varphi (\mathbf{r}, r_s, H) = 
r_x^2 r_y \mathsf{\tilde{D}}_{7}(r, r_s, H) +
r_y \mathsf{\tilde{D}}_{5}(r, r_s, H) \nonumber
\end{align}

\begin{align}
\mathsf{D}_{111}(\mathbf{r}) = \frac{\partial^3}{\partial r_x\partial r_y\partial r_z} \varphi (\mathbf{r}, r_s, H) = 
  r_x r_y r_z \mathsf{\tilde{D}}_{7}(r, r_s, H) \nonumber
\end{align}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent\rule{6cm}{0.4pt}
\begin{align}
  \mathsf{D}_{400}(\mathbf{r}) &= \frac{\partial^4}{\partial r_x^4}
  \varphi (\mathbf{r}, r_s, H) =
  r_x^4 \mathsf{\tilde{D}}_{9}(r, r_s, H)+
  6r_x^2 \mathsf{\tilde{D}}_{7}(r, r_s, H) +
  3 \mathsf{\tilde{D}}_{5}(r, r_s, H)
  \nonumber
\end{align}

\begin{align}
  \mathsf{D}_{310}(\mathbf{r}) &= \frac{\partial^4}{\partial r_x^3
    \partial r_y} \varphi (\mathbf{r}, r_s, H) =
  r_x^3 r_y \mathsf{\tilde{D}}_{9}(r, r_s, H) +
  3 r_x r_y \mathsf{\tilde{D}}_{7}(r, r_s, H)
  \nonumber
\end{align}

\begin{align}
  \mathsf{D}_{220}(\mathbf{r}) &= \frac{\partial^4}{\partial r_x^2
    \partial r_y^2} \varphi (\mathbf{r}, r_s, H) =
    r_x^2 r_y^2 \mathsf{\tilde{D}}_{9}(r, r_s, H) +
    r_x^2 \mathsf{\tilde{D}}_{7}(r, r_s, H) +
    r_y^2 \mathsf{\tilde{D}}_{7}(r, r_s, H) +
    \mathsf{\tilde{D}}_{5}(r, r_s, H)
  \nonumber
\end{align}

\begin{align}
  \mathsf{D}_{211}(\mathbf{r}) &= \frac{\partial^4}{\partial r_x^2
    \partial r_y   \partial r_z} \varphi (\mathbf{r}, r_s, H) =
    r_x^2 r_y r_z \mathsf{\tilde{D}}_{9}(r, r_s, H) +
    r_y r_z \mathsf{\tilde{D}}_{7}(r, r_s, H)
  \nonumber
\end{align}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent\rule{6cm}{0.4pt}
\begin{align}
  \mathsf{D}_{500}(\mathbf{r}) &= \frac{\partial^5}{\partial r_x^5}
  \varphi (\mathbf{r}, r_s, H) =
  r_x^5 \mathsf{\tilde{D}}_{11}(r, r_s, H) +
  10r_x^3\mathsf{\tilde{D}}_{9}(r, r_s, H) +
  15r_x\mathsf{\tilde{D}}_{7}(r, r_s, H)
  \nonumber
\end{align}

\begin{align}
  \mathsf{D}_{410}(\mathbf{r}) &= \frac{\partial^5}{\partial r_x^4
    \partial r_y} \varphi (\mathbf{r}, r_s, H) =
  r_x^4 r_y \mathsf{\tilde{D}}_{11}(r, r_s, H) +
  6 r_x^2 r_y \mathsf{\tilde{D}}_{9}(r, r_s, H) + 
  3 r_y \mathsf{\tilde{D}}_{7}(r, r_s, H)
  \nonumber
\end{align}

\begin{align}
  \mathsf{D}_{320}(\mathbf{r}) &= \frac{\partial^5}{\partial r_x^3
    \partial r_y^2} \varphi (\mathbf{r}, r_s, H) =
  r_x^3 r_y^2 \mathsf{\tilde{D}}_{11}(r, r_s, H) +
  r_x^3 \mathsf{\tilde{D}}_{9}(r, r_s, H) +
  3 r_x r_y^2 \mathsf{\tilde{D}}_{9}(r, r_s, H) + 
  3 r_x \mathsf{\tilde{D}}_{7}(r, r_s, H)
  \nonumber
\end{align}

\begin{align}
  \mathsf{D}_{311}(\mathbf{r}) &= \frac{\partial^5}{\partial r_x^3
    \partial r_y \partial r_z} \varphi (\mathbf{r}, r_s, H) =
  r_x^3 r_y r_z \mathsf{\tilde{D}}_{11}(r, r_s, H) +
  3 r_x r_y r_z \mathsf{\tilde{D}}_{9}(r, r_s, H)
  \nonumber
\end{align}

\begin{align}
  \mathsf{D}_{221}(\mathbf{r}) &= \frac{\partial^5}{\partial r_x^2
    \partial r_y^2 \partial r_z} \varphi (\mathbf{r}, r_s, H) =
  r_x^2 r_y^2 r_z \mathsf{\tilde{D}}_{11}(r, r_s, H) +
  r_x^2 r_z \mathsf{\tilde{D}}_{9}(r, r_s, H) +
  r_y^2 r_z \mathsf{\tilde{D}}_{9}(r, r_s, H) +
  r_z \mathsf{\tilde{D}}_{y}(r, r_s, H)
  \nonumber
\end{align}





















%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{comment}

\noindent\rule{6cm}{0.4pt}

\begin{align}
\mathsf{D}_{100}(\mathbf{r}) = \frac{\partial}{\partial r_x} \varphi (\mathbf{r},H) = 
\left\lbrace\begin{array}{rcl}
-\frac{r_x}{H^3} \left(21u^5 - 90u^4 + 140u^3 - 84u^2 + 14\right) & \mbox{if} & u < 1,\\
-\frac{r_x}{r^3} & \mbox{if} & u \geq 1, 
\end{array}
\right.\nonumber
\end{align}

\noindent\rule{6cm}{0.4pt}

\begin{align}
\mathsf{D}_{200}(\mathbf{r}) = \frac{\partial^2}{\partial r_x^2} \varphi (\mathbf{r},H) = 
\left\lbrace\begin{array}{rcl}
\frac{r_x^2}{H^5}\left(-105u^3+360u^2-420u+168\right) -
\frac{1}{H^3} \left(21u^5 - 90u^4 + 140u^3 - 84u^2 + 14\right) & \mbox{if} & u < 1,\\
3\frac{r_x^2}{r^5} - \frac{1}{r^3} & \mbox{if} & u \geq 1, 
\end{array}
\right.\nonumber
\end{align}

\begin{align}
\mathsf{D}_{110}(\mathbf{r}) = \frac{\partial^2}{\partial r_x\partial r_y} \varphi (\mathbf{r},H) = 
\left\lbrace\begin{array}{rcl}
\frac{r_xr_y}{H^5}\left(-105u^3+360u^2-420u+168\right) & \mbox{if} & u < 1,\\
3\frac{r_xr_y}{r^5} & \mbox{if} & u \geq 1, 
\end{array}
\right.\nonumber
\end{align}

\noindent\rule{6cm}{0.4pt}

\begin{align}
\mathsf{D}_{300}(\mathbf{r}) = \frac{\partial^3}{\partial r_x^3} \varphi (\mathbf{r},H) = 
\left\lbrace\begin{array}{rcl}
-\frac{r_x^3}{H^7} \left(315u - 720 + 420u^{-1}\right) +
\frac{3r_x}{H^5}\left(-105u^3+360u^2-420u+168\right) & \mbox{if} & u < 1,\\
-15\frac{r_x^3}{r^7} + 9 \frac{r_x}{r^5} & \mbox{if} & u \geq 1, 
\end{array}
\right.\nonumber
\end{align}

\begin{align}
\mathsf{D}_{210}(\mathbf{r}) = \frac{\partial^3}{\partial r_x^3} \varphi (\mathbf{r},H) = 
\left\lbrace\begin{array}{rcl}
-\frac{r_x^2r_y}{H^7} \left(315u - 720 + 420u^{-1}\right) +
\frac{r_y}{H^5}\left(-105u^3+360u^2-420u+168\right) & \mbox{if} & u < 1,\\
-15\frac{r_x^2r_y}{r^7} + 3 \frac{r_y}{r^5} & \mbox{if} & u \geq 1, 
\end{array}
\right.\nonumber
\end{align}


\begin{align}
\mathsf{D}_{111}(\mathbf{r}) = \frac{\partial^3}{\partial r_x\partial r_y\partial r_z} \varphi (\mathbf{r},H) = 
\left\lbrace\begin{array}{rcl}
-\frac{r_xr_yr_z}{H^7} \left(315u - 720 + 420u^{-1}\right) & \mbox{if} & u < 1,\\
-15\frac{r_xr_yr_z}{r^7} & \mbox{if} & u \geq 1, 
\end{array}
\right.\nonumber
\end{align}

\noindent\rule{6cm}{0.4pt}

\begin{align}
  \mathsf{D}_{400}(\mathbf{r}) &=
  \nonumber
\end{align}

\begin{align}
  \mathsf{D}_{310}(\mathbf{r}) &=
  \nonumber
\end{align}

\begin{align}
  \mathsf{D}_{220}(\mathbf{r}) &=
  \nonumber
\end{align}

\begin{align}
  \mathsf{D}_{211}(\mathbf{r}) &=
  \nonumber
\end{align}

\end{comment}
