Creating and defining a family of functions with indexed variables?

I am trying to do the following: Create a list as

Table[Subscript[\[Beta], i] _, {i, 1, dim}]

And then use this list to define a function:

F[Table[Subscript[\[Beta], i] _, {i, 1, dim}]] := something in term of beta_i

But this is not working. My main objective is to define and use a family of functions in terms of $$\{\beta_1 ,\dots , \beta_n\}$$ like $$F_1(\{b_1,\dots ,\beta_n\}), \dots ,F_m(\{b_1,\dots ,\beta_n\})$$.

How can I do that?

• why not F[i_][vars_]:=... ? Oct 24 '21 at 6:18
• Subscript is not a valid pattern name. Instead of $\{b_1,b_2,\ldots\}$ why not use b as the name of a vector. You can use then b[], b[], etc. Oct 24 '21 at 12:20

as far as I know, you can't define functions inside Table or a Do loop. Unless there is a hack to do it.

My main objective is to define and use a family of functions

Why not define the function F itself to take its id as part of the definition? As a meta function. Like this

F[i_,Subscript[β_,i_],Subscript[b_,i_]]:=Subscript[β,i]+i+i*Subscript[b,i]

And now, if you wan to call $$F_2$$ for example, you do

i = 2;
F[i, Subscript[β, i], Subscript[b, i]] If you want to make different definitions for each \$F_i, depending on the value of i, you can do something like this

F[i_Integer, Subscript[β_, i_], Subscript[b_, i_]] := Module[{},
Which[i == 1, Subscript[β, i] + i + i*Subscript[b, i],
i == 2, Subscript[β, i] + 3*i - i*2*Subscript[b, i]
(*add more F_i special definitions here*)
]
]

Which looks like this And now can do and so on. btw, the sooner you avoid subscripted variable, the better it is. I never found any use for them and they cause more trouble than worth it.

• Yeah. I've managed to do the following: I generate the following list g = Table[ToExpression[(Alphabet[][[k]]) <> "_"], {k, 1, dim}]; and then I use this to declare a funcion f[g]:=... Oct 24 '21 at 14:26
• Ah, I discovered I can create an endless supply of variables with q[x_]:=(x<>"_");ToExpression/@(q/@(StringJoin/@Drop[Subsets[Alphabet[],2],1])) Oct 24 '21 at 14:55