I have
sx = Sum[Indexed[x, i], {i, 1, 10}]^2 // Expand
It expands in sum of 55 terms, from which
- $x_i^2$ - 10 terms, actual representation: $x_1^2+x_2^2+x_3^2+...$
- $2 \cdot x_i \cdot x_{i+1}$ - 9 terms, actual representation: $2 x_1 x_2 + 2 x_2 x_3 + ...$
- $2 \cdot x_i \cdot x_{i+l}, l>1$ - all the rest, actual representation: $2 x_1 x_3 + 2 x_2 x_4 + ...$
For my calculations I need to replace terms
- => $p \cdot (1-p)$
- => 0
- => $2 \cdot p^2 \cdot (1-p)^2$
I tried to perform straight-forward
sx1 = sx /. $\{x_1^2 -> 1\}$
but nothing happened at all.
What I would like to achieve: some small easy to maintain rule formula to perform such substitutions. I saw Wolfram Mathematica is very difficult with values with subscripts. Is it possible, or should I look for some another alternative?
Thanks.