# How to evaluate a series of derivatives?

Consider the function $$f(\mathbf{x}) = \sum_{n=0}^{N} a_n \left( (\mathbf{b}-\mathbf{x})\cdot \nabla \right)^n \frac{1}{r}$$ where $r = |\mathbf{x}| = \sqrt{(x-x_0)^2 + (y-y_0)^2}$ and $a_n$ and $\mathbf{b}$ are well-known.

Is there any good way to evaluate this function numerically (for fairly large N)?

My problem is that I don't have a general expression for $$\left( (\mathbf{b}-\mathbf{x})\cdot \nabla \right)^n \frac{1}{r}.$$ Is there a smarter way than just recursively do numerical derivatives of $1/r$? I am quite scared of this method since multiple derivatives could lead to numerical errors accumulating.

Thanks in advance.

## 1 Answer

You can convert $\mathbf{b}-\mathbf{x}$ into polar coordinates, and do the dot product in this system. This changes $((\mathbf{b}-\mathbf{x})\cdot\nabla)^n\frac{1}{r}$ to $$\left((\mathbf{b}-\mathbf{x})_r\frac{\partial}{\partial r} + (\mathbf{b}-\mathbf{x})_{\theta}\frac{1}{r}\frac{\partial}{\partial \theta}\right)^n\frac{1}{r}$$ Here, I am using the subscripts $r$ and $\theta$ to indicate the $r$ and $\theta$ components, respectively, of the difference. You can ignore the second term of this entirely, as it involves derivatives with respect to $\theta$ and you only have a dependence on $r$, which further simplifies the term to $$(\mathbf{b}-\mathbf{x})_r^n\frac{\partial^n}{\partial r^n}\frac{1}{r}$$ Now use the fact that $$\frac{\partial^n}{\partial r^n} \frac{1}{r} = (-1)^n\frac{n!}{r^{n+1}}$$ You now have a nice analytical derivative that you can use in your summation. Your final equation will look like

$$f(\mathbf{x})=\sum_{n=0}^{N}(-1)^n a_n(\mathbf{b}-\mathbf{x})_r^n\frac{n!}{r^{n+1}}$$

• Can this idea be used for $\left( \mathbf{b}\cdot \nabla \right)^n \frac{1}{|\mathbf{c}-\mathbf{x}|}$ ? Commented Feb 12, 2015 at 10:11
• @Jolle: The idea can be used for anything that only depends on one independent variable (e.g., only depends on $r$ or only on $\theta$). So assuming that $|\mathbf{c}-\mathbf{x}|$ is the magnitude of (or the $r$ component of) $\mathbf{c}-\mathbf{x}$, then yes, the idea will work. You will have to get a new expression for the derivative, though. Commented Feb 12, 2015 at 13:49