How to expand $(x^{n-1}+\cdots+x+1)^2$ (nicely) sorry if this is a basic question but I am trying to show the following expansion holds over $\mathbb{Z}$:
$(x^{n-1}+\cdots+x+1)^2=x^{2n-2}+2x^{2n-3}+\cdots+(n-1)x^n+nx^{n-1}+(n-1)x^{n-2}+\cdots+2x+1$.
Now I can show this in by sheer brute force, but it wasn't nice and certainly wasn't pretty. So I am just wondering if there are any snazzy ways to show this? If it helps, I am assuming $x^m=1$ for some $m>n-1$.
 A: If you want a proof "prettier" in terms of visualization, you can proceed by the standard (pencil and paper) algorithm for multiplication:
$$\begin{matrix}& & x^{n-1} & x^{n-2} & \ldots & x^2 & x & 1\\
& \times & x^{n-1} & x^{n-2} & \ldots & x^2 & x & 1\\\hline
& & x^{n-1} & x^{n-2} & \ldots & x^2 & x & 1\\
& x^n & x^{n-1} & x^{n-2} & \ldots & x^2 & x &\\
x^{n+1} & x^n & x^{n-1} & x^{n-2} & \ldots & x^2 & &\\
& & &\vdots\\\hline
x^{2n-2}& 2x^{2n-3} & 3x^{2n-4} & \ldots & 4x^3 & 3x^2 & 2x & 1
\end{matrix}$$
Just take into account that this, as it is, lacks some rigour.
A: A kind of graphical proof: Consider the case of $(1+x+x^2+x^3+x^4+x^5)^2$ expanded in a square array in this way:
$$\begin{array}{|l||l|l|l|l|l|}
\hline
&\color{red}{1}&\color{red}{x}&\color{red}{x^2}&\color{red}{x^3}&\color{red}{x^4}&\color{red}{x^5}\\ 
\hline
\color{red}{x^5}&x^5&x^6&x^7&x^8&x^9&x^{10}\\
\hline
\color{red}{x^4}&x^4&x^5&x^6&x^7&x^8&x^{9}\\
\hline
\color{red}{x^3}&x^3&x^4&x^5&x^6&x^7&x^{8}\\
\hline
\color{red}{x^2}&x^2&x^3&x^4&x^5&x^6&x^{7}\\
\hline
\color{red}{x}&x&x^2&x^3&x^4&x^5&x^{6}\\
\hline
\color{red}{1}&1&x&x^2&x^3&x^4&x^{5}\\
\hline
\end{array}$$
Terms $x^k$ with the same exponent $k$ are situated "in a natural way" on a same diagonal and the "population" of these diagonals linearly increase:
$$1, \ 2 x, \ 3 x^2, \ 4 x^3, \ 5 x^4, \ 6 x^5, \ 5 x^6, \cdots 2 x^9, \ 1x^{10},$$
with a maximum along the main diagonal, then linearly decrease...
Remark: one mimicks here the (discrete) convolution of a uniform distribution with itself giving a "tent" function, as it is called in signal processing, with an evident application : the law of the sum of two dies (here with faces numbered $0$ to $5$) with a maximal probability for result 5.
A: Well, for starters you can do induction. That might look a little better than brute force.
Also, note that $(x^{n-1} + \ldots 1)^2 = x^{2n-2}(1 + y + \ldots + y^{n-1})^2$, where $y = \frac{1}{x}$. Whatever expression you have for $(x^{n-1} + \ldots 1)^2$, you can use it for $(1 + \ldots + y^{n-1})^2$ and it should be the same after multiplication by $x^{2n-2}$, so this tells you it should be symmetric about $x^{n-1}$. So all you need are the co-efficients of $1$ to $x^n$. It should be clear that coeff of $x^{i}$ is $i+1$. Because the ways to achieve an exponent of $i$ with sum of two integers is $0 + i, 1 + (i - 1), 2 + (i - 2), \ldots i + 0$, so there are $i+1$ number of partitions.
You can maybe also do something with $\left(\frac{x^n - 1}{x - 1}\right)^2$, but not sure.
A: $$\left(\sum_{i=0}^{n-1} x^i\right)^2=\left(\sum_{i=0}^{n-1} x^i\right)\left(\sum_{j=0}^{n-1} x^j\right)=\sum_{i=0}^{n-1}\sum_{j=0}^{n-1} x^{i+j}.$$
By grouping the terms with constant $i+j$ (parallels to the diagonal of the square), this is
$$\sum_{k=0}^{2n-2}\min(k+1,2n-k-1)x^k.$$
A: HINT.-Why not using $x^{n-1}+\cdots+x+1=\dfrac{x^n-1}{x-1}$ and dividing
$x^{2n}-2x^n+1$ by $x^2-2x+1$?
You will easily find successively the coefficients $$1,2,3,4,\cdots,(n-2),(n-1) ,n,(n-1),(n-2)\cdots,4,3,2,1$$ with a symmetry like the binomial coefficients.
A: Induction is the best way to do it:
Base case: $(x+1)^2 = x^2 + 2x + 1$.
Assume $(x^{n-1} + ... + 1)^2= x^{2n-2} + 2 x^{2n-3} + 3 x^{2n-4} + .... +nx^{n-1} + (n-1)x^{n-2} +.....+3x^2 + 2x + 1$
Then $(x^{n} + ... + 1)^2= [ x^{n} + (x^{n-1} + ... 1)]^2=$
$x^{2n} + 2x^n(x^{n-1} + ... 1) + (x^{n-1} + ... 1)^2] =$
$x^{2n} +[2x^{2n-1} + 2x^{2n-1} +..... + 2x^n] + (x^{2n-2} + 2 x^{2n-3} + 3 x^{2n-4} + .... +nx^{n-1} + (n-1)x^{n-2} +.....+3x^2 + 2x + 1)= 
$x^{2n} +2x^{2n-1} + [2x^{2n-2} +..... + 2x^n] + [x^{2n-2} + 2 x^{2n-3} + 3 x^{2n-4} + .... (n-1)x^n] + [nx^{n-1} + (n-1)x^{n-2} +.....+3x^2 + 2x + 1] = $
$x^{2n}+ 2x^{2n-1} + [(1+2)x^{2n-2} + ....+(n-1+2)x^n]+ [nx^{n-1} + (n-1)x^{n-2} +.....+3x^2 + 2x + 1] = $
$x^{2n} + 2x^{2n-1} + [3x^{2n-1} + ... + (n+1) x^n] +[nx^{n-1} + (n-1)x^{n-2} +.....+3x^2 + 2x + 1] = $
$x^{2n} + 2x^{2n-1} + 3x^{2n-1} + ... + (n+1) x^n +nx^{n-1} + (n-1)x^{n-2} +.....+3x^2 + 2x + 1 $
So by induction thepattern holds.
