Re: Subscripted variables and function definitions

*To*: mathgroup at smc.vnet.net*Subject*: [mg65203] Re: Subscripted variables and function definitions*From*: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>*Date*: Fri, 17 Mar 2006 05:45:43 -0500 (EST)*Organization*: Uni Leipzig*References*: <dvdida$a26$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi, you should use Symbolize[] from the Notation package, if you need Subscript[_,_] in a function pattern. and X[1] is a *function* call to the function X[] with the arguments 1 while X[[1]] is the Part[], i.e., the first element of the value of X, and the value of X should be a list. You mix up both and that cause your problems. Regards Jens "Geico Caveman" <spam at spam.invalid> schrieb im Newsbeitrag news:dvdida$a26$1 at smc.vnet.net... | Hi | | I am trying to define a function (using the front end - I will be using | latex syntax in this post to make clear what I am doing) : | | A[k_s_,r_t_,r_k_]:=... | | Now after this, if I try to output A[1,1,1], it just throws A[1,1,1] back. | However, if I define : | | A[ks_,rt_,rk_]:=... | | it gives the right answer. Two questions : | | 1. Why aren't subscripted variable names treated the same as other variable | names in this context ? | | 2. Is there a way to coax Mathematica into doing what I am trying to do | above ? | | Mathematica is a nice system, but it has these highly irritating quirks. | | | Another (unrelated) question : | | I have a 4x4 matrix which is a function of some variables : | | A:=... (function of r1,r2,r3, ...) | | f:=... (function of the same variables) | | X:=Inverse[A] . f | | Now, I want to extract a ratio : | | X[1]/(X[3]+X[4]) and assign it to a function : | | g[r1_,r2_,r3_]:=X[1]/(X[3]+X[4]) | | A test evaluation of g[1,1,1] throws g[1,1,1] back. Makes no sense at all to | me. What am I missing, and why is Mathematica so unintuitive here ? |