Re: Variables names

• To: mathgroup at smc.vnet.net
• Subject: [mg15032] Re: [mg15002] Variables names
• From: "Clemens Frey" <Clemens.Frey at uni-bayreuth.de>
• Date: Wed, 9 Dec 1998 04:12:18 -0500
• Sender: owner-wri-mathgroup at wolfram.com

-----Urspr|ngliche Nachricht-----
Von: Kim Allemand <kim.allemand at epfl.ch> An: mathgroup at smc.vnet.net
<mathgroup at smc.vnet.net> Datum: Samstag, 5. Dezember 1998 10:09
Betreff: [mg15002] Variables names

>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
>

Hi,

You can use it to compute the quadratic function symbolically (here:
N=2) like in

X = Array[x,2];
Q = Array[q,{2,2}];

which gives you

x[1] (q[1,1] x[1]+q[1,2] x[2])+x[2] (q[2,1] x[1]+q[2,2] x[2])

as well as numerically (N=100)

Xnum = Table[Random[],{100}];
Qnum = Table[Random[],{100},{100}];

Hope that helped

Clemens



• Prev by Date: Reversing the axis of a plot
• Next by Date: mathematica and statistics
• Previous by thread: Re: Variables names
• Next by thread: Re: Variables names