MathGroup Archive 2005

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

Search the Archive

Re: lists of variables

  • To: mathgroup at
  • Subject: [mg58230] Re: lists of variables
  • From: dh <dh at>
  • Date: Thu, 23 Jun 2005 05:34:24 -0400 (EDT)
  • References: <d9630u$q1t$>
  • Sender: owner-wri-mathgroup at

Hi Heath,
You already got many answers, but I think the solution to create a 
variable name as a string and using ToExpression  is not the appropriate 
  way to do this.
Array[..] is made for this purpose. But you must know how to deal with 
it. Especially, you should not use the same name used inside "Array" for 
other purposes. Lets make some examples:
gives : {t[1], t[2], t[3]}
Do not use the same name on the left side and inside Array, you would 
get an infinit recursion. Now set up any function you like. If you 
define the arguments as a list, you may directly use ts:
you can now say:
giving: Cos[t[1] + t[2] - t[3]] as requested.
if F is defined with three arguments like:
you would use Sequence:

If you want to give numerical values, e.g.
t[1]=0.1; t[2]=0.2; t[3]=0.3;
F[ts] would give:
Cos[0.1+0.2-0.3] -> 1.

sincerely, Daniel

Heath Gerhardt 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]]
> thanks in advance
> Heath

  • Prev by Date: Re: a small problem from a newbee...
  • Next by Date: Synergetics section 260.42
  • Previous by thread: Re: lists of variables
  • Next by thread: Re: lists of variables