MathGroup Archive 2008

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

Search the Archive

Re: Subscript Bug?

Aaron Fude wrote:

>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.
The first time you execute the cell, the assignment

H = Subscript[H, 1] + Subscript[H, 2];

sets H to 110 + 90, which is 200. Then, Tanh[Subscript[200,1]] is what 
you get.

The second time you execute the cell, H is 200, so Subscript[200,1] is 
set to 110 and Subscript[200,2] is set to 90. Then, H is set to 200 
again. Now, Subscript[H,1] is Subscript[200,1] which equals 110, so you 
get Tanh[110].

If you want to do these kinds of manipulations with Subscript, then I 
recommend that you give Subscript the HoldFirst attribute.

Carl Woll
Wolfram Research

>A second execution, yields the correct answer:
>Is this a feature that I don't understand or a bug?

  • Prev by Date: Re: Bug in multiple integrals with delta function
  • Next by Date: Re: How to stop execution within a cell?
  • Previous by thread: Re: Subscript Bug?
  • Next by thread: Re: Subscript Bug?