Say I have a vector
X[n_] := Table[Subscript[x, i], {i, 1, n}]
and a matrix of connections:
W[n_, w_, \[Omega]_] := IdentityMatrix[n]*w + (1 - IdentityMatrix[n])*\[Omega]
And I define the following expressions
v = X[10]
connections = W[10, w, \[Omega]]
s = Total[v]
And now I want to calculate the sum of the matrix product Wv
:
Collect[Total[connections.v], {\[Omega], w}, FullSimplify]
This will output
w (x_1+x_2+x_3+x_4+x_5+x_6+x_7+x_8+x_9+x_10)+9 \[Omega] (x_1+x_2+x_3+x_4+x_5+x_6+x_7+x_8+x_9+x_10)
However, I know that s=x_1+x_2+...+x_10
...
So how do I make Mathematica substitute the sum by s? Yielding
w s + 9 \[Omega] s