Re: Subscript Bug?

*To*: mathgroup at smc.vnet.net*Subject*: [mg90123] Re: Subscript Bug?*From*: David Bailey <dave at Remove_Thisdbailey.co.uk>*Date*: Mon, 30 Jun 2008 04:51:14 -0400 (EDT)*References*: <g47l28$t66$1@smc.vnet.net>

Aaron Fude wrote: > Hi, > > I have this code in a cell: > > Subscript[H, 1] = 110; Subscript[H, 2] = 90; > H = Subscript[H, 1] + Subscript[H, 2]; > Tanh[Subscript[H, 1]] > > The first time I execute the cell, I get > > Tanh[Subscript[200, 1]] > > which of course is nonsense. > > A second execution, yields the correct answer: > > Tanh[110] > > Is this a feature that I don't understand or a bug? > Well I guess you should class it as a feature you don't understand! The first time though you make the following assignments: Subscript[H, 1] = 110 Subscript[H, 2] = 90 H0 The second time through, H has a value, so make the assignment: Subscript[200, 1] = 110 Subscript[200, 2] = 90 H0 Therefore on the second execution Subscript[200, 1] evaluates to 110. The moral of this story is that if you want to define Subscript[var,n], it doesn't make mush sense to proceed to give a value to var itself! David Bailey http://www.dbaileyconsultancy.co.uk