I have a standard mathematical problem that I was wondering how to solve efficiently by mathematica. Here is the problem.

I have two power series expansions of a function F[x,y] = sum1 = sum2

A1 = (a/4)^2 (x^2 + y^2 + z^2); 
A2 =  (a/4)^3 x y z;
sum1 = Sum[A1^i * A2^j * P[i, j], {i, 0, 6}, {j, 0, 6}] /. {z -> -x - y}
sum2 = Sum[(a/4)^(i + j) (x^i y^j)/(i! j!) Q[i, j], {i, 0, 6}, {j, 0, 6}]

Basically I want to express one type of coefficients P[i,j] in terms of Q[i,j].

  • $\begingroup$ sum1 contains x-y terms with lowest total degree>0 of two, no terms linear in x or y. However sum2 contains terms linear in x or y. How can sum1 == sum2 be? $\endgroup$ Commented Jun 22, 2023 at 19:16
  • $\begingroup$ Doesn't that mean some of the particular coeffs i.e. P[i,j] or Q[i,j] are zero? $\endgroup$ Commented Jun 22, 2023 at 19:52
  • $\begingroup$ Maybe another way of putting it : sum1 is a restricted sum with 2 i + 3 j = n where n is a natural number. $\endgroup$ Commented Jun 22, 2023 at 19:56

1 Answer 1


In sum2, the powers of x and y are less than or equal to 6, whereas in sum1, the powers go up much higher. For that reason, we'll have to truncate sum1.

Perhaps this is what you're looking for:

Thread /@ Thread[CoefficientList[sum1, {x, y}][[;; 7, ;; 7]] == CoefficientList[sum2, {x, y}]] // Flatten;
Solve[%, Flatten@Array[Q, {7, 7}, 0]]

This generates the set of coefficients for each power of $x^ny^m$, sets them equal to each other for the two sums (up to degree 6 in each variable), and then solves for the Q's in terms of the P's.

  • $\begingroup$ That's perfect! I just wanted P[i, j] = # Q[i, j], but that's not so relevant. I think I understand the complication you mentioned, since I was struggling with the same. But I am yet to understand the resolution. Thanks a lot! $\endgroup$ Commented Jun 23, 2023 at 2:10
  • $\begingroup$ On second thought, it's not so trivial to obtain P[i, j] = # Q[i, j]. Please let me know if you have any way to solve directly for P[i, j]. Thanks! $\endgroup$ Commented Jun 24, 2023 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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