I have the following polynomial which depends on $n$:
poly = (Sum[(i - 1) y[i], {i, 1, n, 1}])^2 - Sum[(i - 1)^2 y[i]^2, {i, 2, n, 1}] // Expand;
The Mathematica Length
command can be used to determine the length of poly
for an arbitrarily chosen value of $n$.
For instance for $n=5$:
n=5; poly
4 y[2] y[3] + 6 y[2] y[4] + 12 y[3] y[4] + 8 y[2] y[5] + 16 y[3] y[5] + 24 y[4] y[5]
which yields for the length
Length[poly]
6
Similarly for $n=4$
n = 4; poly
4 y[2] y[3] + 6 y[2] y[4] + 12 y[3] y[4]
which yields for the length
Length[poly]
3
But here comes the problem. For $n=3$, poly takes the following form
n = 3; poly
4 y[2] y[3]
which yields for the length
Length[poly]
3
as opposed to 1. Since there is now only 1 term, it is counting each sub-term and taking that to be the length. What could be done to correct for this? I need it to only count the total number of terms for all values of $n$. Thank you!