Re: Re: subscripted function variables
- To: mathgroup at smc.vnet.net
- Subject: [mg50325] Re: [mg50302] Re: [mg50287] subscripted function variables
- From: DrBob <drbob at bigfoot.com>
- Date: Fri, 27 Aug 2004 02:57:47 -0400 (EDT)
- References: <200408261050.GAA16323@smc.vnet.net>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
I use the following utility function when I use subscripted variables (which is rare). It makes u[i] and Subscript[u,i] synonymous, and that makes the OP's problem easy to solve: subFunction::usage = "subFunction[symbol] \ formats a[i] as \!\(a\_i\),\n and converts \ an input \!\(a\_i\) into a[i]."; subFunction[a_Symbol] := (MakeExpression[SubscriptBox[ToString[a], i__], f_] := MakeExpression[ RowBox[{ToString[a], "[", i, "]"}]]; MakeBoxes[a[i_], f_] := SubscriptBox[ MakeBoxes[a, f], MakeBoxes[i, f]]; MakeBoxes[a[i__], f_] := SubscriptBox[ MakeBoxes[a, f], MakeBoxes[{i}, f]]) subFunction[u] f[u[i_]] := Subscript[u, i]^2 f[u[i]] u[i]^2 I think this is something Ted Ersek posted years ago, modified just a little. Bobby On Thu, 26 Aug 2004 06:50:44 -0400 (EDT), David Park <djmp at earthlink.net> wrote: > Christopher, > > You can use the Notations package, or you can use Ted Ersek's > SubscriptSymbols package from MathSource at the WRI site. Ted's package uses > the Notation package and does all the setup for you so makes it easier. > > David Park > djmp at earthlink.net > http://home.earthlink.net/~djmp/ > > From: Christopher Grinde [mailto:christopher.grinde at hive.no] To: mathgroup at smc.vnet.net > To: mathgroup at smc.vnet.net > > Is there a way to use subscriptewd variable names in functions? > > I have tried > > f[Subscript[u,1]_]:=Subscript[u,1]^2 > > but I am not able to make this work. > > Any tip would be highly appreciated as I have a code that generates a high > number of functions using Subscript[u,1]->Subscript[u,n] as variables. > > Christopher Grinde > > > > > > -- DrBob at bigfoot.com www.eclecticdreams.net
- References:
- Re: subscripted function variables
- From: "David Park" <djmp@earthlink.net>
- Re: subscripted function variables