# Numerical evaluation of partial derivatives

I need to evaluate the following derivative:

$$\frac{1}{\prod_i \xi_i!}\frac{1}{\prod_j \eta_j!} \left.\frac{\partial^{\xi_1 + \cdots + \xi_m}}{\partial\alpha_1^{\xi_1}\ldots\partial\alpha_m^{\xi_m}} \frac{\partial^{\eta_1 + \cdots + \eta_n}}{\partial\beta_1^{\eta_1}\ldots\partial\beta_n^{\eta_n}} \exp\left(\sum_{ij} a_{ij} \alpha_i \beta_j\right) \right|_{\alpha_1 = \cdots = \alpha_m = \beta_1 = \cdots = \beta_n = 0}$$

where the $\xi_i$ and $\eta_j$ are non-negative integers, with $i = 1...m$ and $j = 1...n$, and the $a_{ij}$ are non-negative real numbers.

Is there a good numerical algorithm to do this? Is it efficient?

## 2 Answers

Do it by hand or, if you're lazy, do it symbolically with Maple or Mathematica. This is certainly going to be more accurate than trying to do high-order derivatives numerically.

• $m$ and $n$ are large numbers. And I need to evaluate this expression iteratively many times, with different values of $\xi_i$ and $\eta_j$. I think symbolically would be too slow. – becko Jun 28 '13 at 3:42
• Calculating derivatives numerically becomes increasingly inaccurate as the order of the derivative increases, and expensive as both the order and number of variables increases. Automatic differentiation would probably also break down. A spectral approach with the right sort of basis could be accurate, but given the number of variables and high order derivatives, you probably require too many points to be practical. Symbolically is probably the best bet in terms of a combination of accuracy and speed, even for large $m$ and $n$, when the expression is simple and closed-form. – Geoff Oxberry Jun 28 '13 at 7:26
• Well, it is closed form. Take the beta-derivatives and you get something of the form polynomial in alpha times existing exponential. That is easy to take the alpha-derivative of. – Wolfgang Bangerth Jun 28 '13 at 12:53
• @GeoffOxberry okay. I'll try it symbolically. I'll let you know if it works. – becko Jul 1 '13 at 12:36

Here's the easy part. Define $$A = \prod_i A_i = \prod_i \frac{1}{\xi_i!} \left(\frac{\partial}{\partial \alpha_i} \right)^{\xi_i}$$ $$B = \prod_j B_j = \prod_j \frac{1}{\eta_j!} \left(\frac{\partial}{\partial \beta_j} \right)^{\eta_j}$$ $$f = \exp \sum_{ij} a_{ij} \alpha_i \beta_j = \prod_{ij} f_{ij} = \prod_{ij} e^{a_{ij} \alpha_i \beta_j}$$ We have $$\frac{\partial}{\partial \alpha_k} f_{ij} = \begin{cases} a_{ij} \beta_j f_{ij} & i=k \\ 0 & i \ne k \end{cases}$$ $$A_i f = \frac{f}{\xi_i!}\left(\sum_j a_{ij} \beta_j \right)^{\xi_i}$$ $$A f = f \prod_i \frac{\left(\sum_j a_{ij} \beta_j \right)^{\xi_i}}{\xi_i!}$$ Unfortunately, the next step is harder. :)