MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Subscript Bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90138] Re: Subscript Bug?
  • From: dh <dh at metrohm.ch>
  • Date: Mon, 30 Jun 2008 04:54:05 -0400 (EDT)
  • References: <g47l28$t66$1@smc.vnet.net>


Hi Aaron,

the second line defines H as 200. Parsing the third line from left to 

right, Subscript[H,1] is encountered, that has no value. Therefore, it 

is parsed further and H is replaced by 200.  Therefore, 

Tanh[Subscript[H,1]] gives Tanh[Subscript[200, 1]].

The second time the first line is executed, H is replaced by 200 and you 

define Subscript[200,1]= 110; You may check this by: Subscript[200,1]. 

Parsing the third line, Mathematica sees Subscript[H,1, this now have a value of 

110. Therefore, you get: Tanh[110]

The pitfall here is, that you gave a value to the name of a subscripted 

variable. If you want to do this, it is better if you use H1 instead of 

Subscript[H,1] in your calculations and eventually specify a format 

like: Format[H1]=Subscript["H",1] for the print out.

hope this helps, Daniel



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?

> 





-- 



Daniel Huber

Metrohm Ltd.

Oberdorfstr. 68

CH-9100 Herisau

Tel. +41 71 353 8585, Fax +41 71 353 8907

E-Mail:<mailto:dh at metrohm.com>

Internet:<http://www.metrohm.com>




  • Prev by Date: Re: A set of several questions
  • Next by Date: Controling the color of line segments in a Log plot
  • Previous by thread: Re: Subscript Bug?
  • Next by thread: Ticks question