# Create list of elements with dependence on a variable

I'm aware that we can make a list of elements:

x = Table[Symbol["x" <> ToString@i], {i, n}];


This returns x = {x1,x2,x3} when n = 3. What I want is to be able to turn each of these variables x1,x2,x3 into functions of t (e.g. I want y = {x1[t],x2[t],x3[t]}).

Any ideas would be appreciated.

• Look up Through: Through @ x[t] – Carl Woll Mar 7 '18 at 16:19
• Thanks. Worked perfectly. – Gregory Mar 7 '18 at 16:47

Indexed variables are usually much easier to work with.

Format[x[n_Integer]] := Subscript[x, n]

Format[a[n_Integer]] := Subscript[a, n]

X[t_, n : _Integer?Positive : 3] := Array[x[#][t] &, n]


Using default value for n

X[t]


Specifying a value for n

X[t, 5]


X[t, 5].Array[a, 5]