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?

  • 1
    $\begingroup$ why not F[i_][vars_]:=... ? $\endgroup$ Oct 24, 2021 at 6:18
  • 2
    $\begingroup$ 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[[1]], b[[2]], etc. $\endgroup$
    – yarchik
    Oct 24, 2021 at 12:20

1 Answer 1


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


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

i = 2;
F[i, Subscript[β, i], Subscript[b, i]]

Mathematica graphics

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

Mathematica graphics

And now can do

Mathematica graphics

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.

  • $\begingroup$ 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]:=...`` $\endgroup$
    – Red Banana
    Oct 24, 2021 at 14:26
  • $\begingroup$ Ah, I discovered I can create an endless supply of variables with q[x_]:=(x<>"_");ToExpression/@(q/@(StringJoin/@Drop[Subsets[Alphabet[],2],1])) $\endgroup$
    – Red Banana
    Oct 24, 2021 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.