MathGroup Archive 2009

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

Search the Archive

Re: Defining function with indexed variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99401] Re: Defining function with indexed variables
  • From: Paul Smith <phhs80 at gmail.com>
  • Date: Tue, 5 May 2009 05:39:44 -0400 (EDT)
  • References: <gth5g1$ev0$1@smc.vnet.net> <gtnk2f$3ku$1@smc.vnet.net>

On May 4, 9:43 pm, Peter Pein <pet... at dordos.net> wrote:
> 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
>
> Pardon, I forgot the case checking for exactly 100 arguments:
>
> In[1]:= f100[args__]:=Total[Superscript[#,2]&/@{args}]/;Length[{args}=
]==100
> In[2]:= f100[x,y,z]
> Out[2]= f100[x,y,z]
> In[3]:= f100@@(x/@Range[200,299])//Short
> Out[3]//Short= x[200]^2+x[201]^2+<<96>>+x[298]^2+x[299]^2

I would like to thank all of you for your answers, which have solved
solved my problem, and helped me a lot.

Paul


  • Prev by Date: Re: atoi equivalents?
  • Next by Date: Making a user interface
  • Previous by thread: Re: Defining function with indexed variables
  • Next by thread: ListPointPlot3D colors from data