MathOverflow is a question and answer site for professional mathematicians. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let $g(x) = \exp(f(x))$. Assuming numerical (or symbolic) values of $f(x), f'(x), f''(x), \ldots, f^{(n)}(x)$ are known, is there a way to compute $g'(x), g''(x), \ldots g^{(n)}(x)$ (or even the single value $g^{(n)}(x)$) for large $n$ that is faster than explicitly generating and evaluating the expanded symbolic derivative, a polynomial which has $p(n)$ (partition function) terms?

share|cite|improve this question
1… – Steve Huntsman Jul 28 '10 at 0:07
For a particular n the relevant polynomial is essentially the cycle index polynomial of S_n:… . So knowing how to do this computation for arbitrary f is essentially equivalent to knowing the cycle index polynomial, which encodes a lot of information. – Qiaochu Yuan Jul 28 '10 at 0:13
Thanks, this is the terminology I'm looking for. So I guess the question is: is there a better way than the naive one to evaluate this polynomial (the naive method being to generate the expanded polynomial and evaluate it term by term)? – Fredrik Johansson Jul 28 '10 at 1:18

Yes, you can. For example, the normal evaluation for $n=6$ requires 33 multiplications and 10 additions. But by using an optimized straight-line program which takes care of common subexpression elimination, you can reduce that to 17 multiplications, 10 additions and 4 assignments. For $n=8$, the reduction in multiplications goes from 84 down to 37, and at $n=12$, it goes from 397 down to 114.

Note that multiplication by constants (like $10f'(x)$) counts as a multiplication too.

You can experiment with these things by using the codegen package in Maple (especially the functions codegen[optimize] with the tryhard option, as well as codegen[cost]). If there is interest, I can post the details of the computation here.

Unfortunately, at this point, I do not immediately see a pattern in the results, so I am not sure how to automate this and produce optimized versions directly. But the answer to your original question is definitely 'yes'.

share|cite|improve this answer
Excellent! This doesn't really solve the problem for arbitrary n, though. – Fredrik Johansson Sep 9 '10 at 11:48
Indeed - and I did mention that in my answer. But I believe that at this point, you're all set for a bit of "experimental mathematics" where you stare at the results for sufficiently many n, see patterns, make conjectures, prove them, repeat. I would even be interested in helping such a project along - I just can't lead it, I've got too many other things already on the go. – Jacques Carette Sep 9 '10 at 12:25

I feel that I should post an answer, for the benefit of any potential readers from the future...

For simultaneous computation of the first $n$ derivatives, the problem is really computing the exponential of a power series, and it is a classical result that this can be done in $O(M(n))$ arithmetic operations (which most likely is optimal).

See: Brent and Kung, Fast algorithms for manipulating formal power series, Journal of the ACM, 1978. There are more recent papers reducing the implied constant factors.

I'm still not aware of any result to the effect that the $n$th derivative alone can be computed faster than $O(M(n))$.

share|cite|improve this answer

Try automatic differentiation, which is exact but not symbolic. See also The Arithmetic of Differentiation by L. B. Rall.

share|cite|improve this answer
I don't see how AD helps here. Rather, AD of nth order requires that the symbolic nth derivatives of atomic functions are already known. – Fredrik Johansson Jul 28 '10 at 1:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.