MathGroup Archive 1998

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

Search the Archive

Re: Re: Variables names

  • To: mathgroup at
  • Subject: [mg15092] Re: [mg15048] Re: [mg15002] Variables names
  • From: Andrzej Kozlowski <andrzej at>
  • Date: Sat, 12 Dec 1998 03:58:57 -0500
  • Sender: owner-wri-mathgroup at

On Wed, Dec 9, 1998, Jens-Peer Kuska <kuska at>

>Hi Kim,
>the best way is to use x[i] instead of x1, x2, ...
>You can still generate the names with
>Hope that helps
>  Jens
>Kim Allemand wrote:
>> Hi,
>> I have a square matrix Q of dimension N and would like to generate the
>> quadratic function $\sum_{i,j}q_{ij}x_i x_j$. The problem is how to say
>> to Mathamatica that the variables names are x1, x2, etc. Is it possible
>> to generate variables names in an automatic way? A possibility would be
>> to generate manually a vector NN={x1, x2, x3, ....} of dimension N and
>> then to pick NN[[i]] for the ith variable name, but imagine when
>> N=1000... !!
>> Thanks, Kim

I think it may be interesting to point out the two approaches are not
really equivalent.  The difference between them, i.e. between x1, x2,
x3 etc. and x[1],x[2], x[3] is that in the first case we have genuine
variable names, in the second values of a function x. This means that
in the first case pattern matching on the indices will have no effect
on the "variables" , while in the second case it will. Compare the
following two examples:

  3     3
x1  + x2
    3       3
x[1]  + x[3]

I can imagine cases where one or the other behaviour is more desirable,
so I do not think one can definitely say that one of these aproaches is
superior to the other.

Andrzej Kozlowski
Toyama International University

  • Prev by Date: Re: Monte Carlo simulations on a Mac??
  • Next by Date: Block and Module
  • Previous by thread: Re: Variables names
  • Next by thread: error from MathLink, plotting results from a c++ simulation