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: [mg99368] Re: Defining function with indexed variables
  • From: Peter Pein <petsie at dordos.net>
  • Date: Mon, 4 May 2009 05:59:23 -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
> 

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

Peter


  • Prev by Date: Bug with Hypergeometric2F1?
  • Next by Date: problems with DSolve
  • Previous by thread: Re: Defining function with indexed variables
  • Next by thread: Re: Defining function with indexed variables