Following up on how to define symbolic vectors
Let x be an n-dimensional symbolic vector, where n is a positive integer large enough to be a massive pain in the butt.
n = 42;
xs = Array[Indexed[x, #] &, n]
If I were to evaluate a function on x with some value, I would replace each element by hand using the shorthand notation for ReplaceAll
.
For example, if I take the sum of squares on x at the zero vector, I would type
Transpose[xs] . xs /. { \
xs[[1]] -> 0, xs[[2]] -> 0, xs[[3]] -> 0, xs[[4]] -> 0, xs[[5]] -> 0, \
xs[[6]] -> 0, xs[[7]] -> 0, xs[[8]] -> 0, xs[[9]] -> 0, xs[[10]] -> 0, \
xs[[11]] -> 0, xs[[12]] -> 0, xs[[13]] -> 0, xs[[14]] -> 0, xs[[15]] -> 0, \
xs[[16]] -> 0, xs[[17]] -> 0, xs[[18]] -> 0, xs[[19]] -> 0, xs[[20]] -> 0, \
xs[[21]] -> 0, xs[[22]] -> 0, xs[[23]] -> 0, xs[[24]] -> 0, xs[[25]] -> 0, \
xs[[26]] -> 0, xs[[27]] -> 0, xs[[28]] -> 0, xs[[29]] -> 0, xs[[30]] -> 0, \
xs[[31]] -> 0, xs[[32]] -> 0, xs[[33]] -> 0, xs[[34]] -> 0, xs[[35]] -> 0, \
xs[[36]] -> 0, xs[[37]] -> 0, xs[[38]] -> 0, xs[[39]] -> 0, xs[[40]] -> 0, \
xs[[41]] -> 0, xs[[42]] -> 0}
Is there a shortcut to ReplaceAll the elements in the vector?
Transpose[xs] . xs /. Thread[xs -> 0]
orTranspose[xs] . xs /. _Indexed ->0
? $\endgroup$xs /. Indexed[x, _] -> 0
$\endgroup$