Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to apply a series expansion on a function x[t1,t2,], with an expansion parameter a. For n=2, the function is x[t1,t2], and this is my series expansion:

solRule2 = x -> (Sum[a^i Subscript[x, i][#1, #2], {i, 0, 2}] &);
x[t1, t2] /. solRule2

The result is given correctly as

Subscript[x, 0][t1, t2] + a Subscript[x, 1][t1, t2] + a^2 Subscript[x, 2][t1, t2]

This works also with derivatives, and this matters to me:


(Subscript[x, 0]^(2, 0))[t1, t2] + a (Subscript[x, 1]^(2,0))[t1, t2] + a^2 (Subscript[x, 2]^(2, 0))[t1, t2]

Now, I can manually extend the rule to n = 3,

solRule3 = x -> (Sum[a^i Subscript[x, i][#1, #2, #3], {i, 0, 3}] &);

but what I want to do is to extend it to the generic n. I tried this

solRuleN = x -> (Sum[a^i Subscript[x, i][##], {i, 0, Length[{##}]}] &);

This works well with the function x[t1,t2] and in general with x[t1,t2, ..., tn], but it fails with the derivatives:

(x^(1, 1))[t1, t2]/.solRuleN

gives output 0. I don't understand why this happens.

share|improve this question
Have a look at Sequence. – b.gatessucks Jul 9 '13 at 12:19

1 Answer 1

The problem boils down to the fact that

Derivative[1][f[##] &]

0 &

Which is, in my opinion unexpected. More in: Derivative of a pure function with SlotSequence

The fix is to inject a sequence of Slots (#1, #2...) of length equal to the number of arguments our function accepts:

series[n__] := With[{
    l = Length[{n}],
    slots = Array[Slot, Length[{n}]]
  Sum[a^i Subscript[x, i] @@ slots, {i, 0, l}] &

solRuleN = {
   x[t__] :> series[t],
   Derivative[n__][x] :> Derivative[n][series[n]]

Derivative[1, 1, 1][x][t1, t2, t3] /. solRuleN
(Subscript[x, 0]^(1,1,1))[t1,t2,t3]+a (Subscript[x, 1]^(1,1,1))[t1,t2,t3]+a^2 (Subscript[x, 2]^(1,1,1))[t1,t2,t3]+a^3 (Subscript[x, 3]^(1,1,1))[t1,t2,t3]
share|improve this answer

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.