Re: Defining function with indexed variables
- To: mathgroup at smc.vnet.net
- Subject: [mg99339] Re: [mg99300] Defining function with indexed variables
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 3 May 2009 05:21:33 -0400 (EDT)
- Reply-to: hanlonr at cox.net
Clear[f, x]
f[x__] := Module[{xl = Flatten[{x}]}, xl.xl]
f[Superscript[x, #] & /@ Range[3]]
Superscript[x, 1]^2 + Superscript[x, 2]^2 +
Superscript[x, 3]^2
f[Superscript[x, #] & /@ Range[100]] ==
f[Sequence @@ (Superscript[x, #] & /@ Range[100])]
True
Bob Hanlon
---- Paul Smith <phhs80 at gmail.com> wrote:
=============
Dear All,
How can one define the function
f(x1,x2,...,x100) := x1^2 + x2^2 + ... + x100^2
using superscripts?
Thanks in advance,
Paul