Re: Using subscripts in function-parameter names
- To: mathgroup at smc.vnet.net
- Subject: [mg71802] Re: Using subscripts in function-parameter names
- From: "Norbert Marxer" <marxer at mec.li>
- Date: Wed, 29 Nov 2006 02:56:53 -0500 (EST)
- References: <ekbkts$elo$1@smc.vnet.net>
Hello Instead of using the list of subscripted variables as argument of your function you could use a variable representing a whole sequence of values (i.e. t__). Then using this variable your first command in the function definition sets all the desired arabic or greek subscripted values. This method requires the same amount of typing. But you can avoid a lot of trouble. For your example: F[t__] := ({Subscript[x, 1], Subscript[x, 2], Subscript[x,3]} = {t}; Sum[Subscript[x, i], {i, 1, 3}]) Best Regards Norbert Marxer www.mec.li eriwik at student.chalmers.se schrieb: > I'm quite new to using Mathematica and I'll probably not use it much in > the future either, but right now I need to use it to calculate some > values for comparison. My problem is that I can't get seem to get a > function to work if the parameters have a subscript in the name. The > following demonstrates the problem (copied from the notebook-file): > > (F[\(x\_1\) _, \(x\_2) _] := \[Sum]\+\(i = 1\)\%2 x\_i;\) > > Or put another way, a function F that takes two arguments > Subscript[x,1] and Subscript[x,2] and runs a summation over > Subscript[x,i] from i = 1 to 2. > > Now, this is quite a contrived example and could easily be expanded by > hand, but what I need it for is much harder, with 8 parameters and > nested summations. As I understand perhaps Utilities`Notation` could be > used, but I don't understand how to use it. Could someone give a short > demonstration (if that is the solution), perhaps on the above example? > > -- > Erik Wikström