1

What is the number of solutions for $x+y+z = n^2$ for $x,y,z$ non-negative integers?

I thought to use generating functions. I know that the generating function for $x_1+x_2+...+x_k= n$ when $x_i \in S_i$ for $i \in \{1,2,...k\}$ is $$\sum_{n=0}^{\infty}a_nx^n=\prod_{i=0}^{k}(\sum_{n\in S_i}x^n) $$ based in that can I say that the generating function for the number of solutions for $x_1+x_2+...+x_k= n^2$ is $$\sum_{n=0}^{\infty}a_nx^n=(\prod_{i=0}^{k}(\sum_{n\in S_i}x^n))^2 $$

If not, is there a different way to find the number of solutions for the equation above?

EDIT:

I added another variable, so now the number of solutions for this equation, because I wanted to ask about the general case

amWhy
  • 209,954

1 Answers1

0

This can be solved with generating functions but here is a simpler way. You are searching for the number of weak compositions of $n^2$ into $k=3$ parts ($x$, $y$, and $z$). The answer is given by stars and bars:

$$ \binom{n^2 + k - 1}{k - 1} = \binom{n^2 + 2}{2} $$

Alex
  • 535