Re: Defining function with indexed variables
- To: mathgroup at smc.vnet.net
- Subject: [mg99367] Re: Defining function with indexed variables
- From: Peter Pein <petsie at dordos.net>
- Date: Mon, 4 May 2009 05:59:12 -0400 (EDT)
- References: <gth5g1$ev0$1@smc.vnet.net>
Paul Smith schrieb: > Dear All, > > How can one define the function > > f(x1,x2,...,x100) := x1^2 + x2^2 + ... + x100^2 > > using superscripts? > > Thanks in advance, > > Paul > f[args__] := Total[Superscript[#, 2] & /@ {args}] writes the desired sum of superscripts for any positive number of arguments; e.g: In[2]:= f[x1,x2,x3,y] Out[2]= x1^2+x2^2+x3^2+y^2 Peter