Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

lists of variables

  • To: mathgroup at
  • Subject: [mg58252] lists of variables
  • From: Paul Abbott <paul at>
  • Date: Fri, 24 Jun 2005 03:28:42 -0400 (EDT)
  • Organization: The University of Western Australia
  • Sender: owner-wri-mathgroup at

Heath Gerhardt <heathgerhardt at> wrote:

> I need to make lists of variables, for example
> {t1,t2,t3}
> but have not been able to figure out how to make Mathematica do this. 
> Tried using
> Array[t,3]
> which gives
> {t[1],t[2],t[3]}
> but then I don't know how to set the t[i]'s in expressions similar to
> F[t[1]_,t[2]_,t[3]_]:=Cos[t[1]+t[2]-t[3]]

Apart from the suggestions of other respondents, there is another 
approach to this sort of problem. If your goal is to define a function 
that performs some operation on a list of variables, list operations 
instead. For example, defining

  f[x_List] := Cos[x[[1]] + x[[2]] - x[[3]]] /; Length[x]==3

Then both

  f[{t1, t2, t3}]


  f[Array[t, {3}]]

work. Indeed you can also use subscripted variables as arguments. 

Moreover, if your list operations treat all elements on an equal 
footing, then the definitions are simpler. For example, defining

  g[x_List] := Cos[Tr[x]]

then your F is just g[t1, t2, -t3].


Paul Abbott                                      Phone: +61 8 6488 2734
School of Physics, M013                            Fax: +61 8 6488 1014
The University of Western Australia         (CRICOS Provider No 00126G)    

  • Prev by Date: Re: Numerical solution of quadratic equations set.
  • Next by Date: Re: General 3-state stochastic matrix
  • Previous by thread: Re: Re: lists of variables
  • Next by thread: Re: lists of variables