Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Re: RandomReal gets stuck

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100730] Re: [mg100687] Re: RandomReal gets stuck
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Thu, 11 Jun 2009 21:45:08 -0400 (EDT)
  • References: <200906061025.GAA04602@smc.vnet.net> <h0fvjl$rb1$1@smc.vnet.net>
  • Reply-to: drmajorbob at bigfoot.com

> And Mathematica does not recognizes
> input Subscript[a,i] as equivalent to a[i].

You mean something like zero doesn't come from

a[1] - Subscript[a, 1]

for instance?

and

a[1] === Subscript[a, 1]

False

That's true, but when using this trick I never actually type or use the  
subscripted form; I only see it. So there's no chance the conflict can  
occur for me.

Subscripts also disappear if you assign values, such as in

a[2] = 3; a[2]

3

a[j] displays subscripted for any j where a[j] is undefined.

Maybe you won't find it useful, but maybe you will. I don't know.

Bobby

On Thu, 11 Jun 2009 06:07:36 -0500, Alexey <lehin.p at gmail.com> wrote:

> On 7 =C9=C0=CE, 13:00, DrMajorBob <btre... at austin.rr.com> wrote:
>> If you want to use subscripted variables, it might help to use this  
>> code:
>>
>> subFunction::usage = "subFunction[a] causes inputting a[i] or \
>> \!\(\*SubscriptBox[\"a\", \"i\"]\) to be synonymous, while always \
>> displaying the latter in outputs."
>>
>> "subFunction[a] causes inputting a[i] or \!\(\*SubscriptBox[\"a\", \
>> \"i\"]\) to be synonymous, while always displaying the latter in \
>> outputs."
>>
>> subFunction[a_Symbol]:=Block[{aa=ToString[a]},MakeExpression[Subscrip=
> tBox[ToString@a,i_],f_]:=MakeExpression[RowBox[{ToString@a,"[",i,"]"}]];MakeBoxes[a[i_],f_]:=SubscriptBox[MakeBoxes[a,f],MakeBoxes[i,f]]]
>>
>> The result is that you can refer to a[i] or Subscript[a,i]
>> interchangeably, but it always displays in the subscripted form. I find  
>> it
>> much easier to use a[i] while typing formulas, so I'm getting the best  
>> of
>> both worlds.
>>
>> Not sure if that addresses everything brought up on the thread, of  
>> course.
>>
>> Bobby
>
>
> It is very interesting, thank you. But as I understand the definition
> aa=ToString[a]
> inside Block is not necessary. And Mathematica does not recognizes
> input Subscript[a,i] as equivalent to a[i]. There seems to be some
> errors in the code.
>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: Re: problem writing debugging utility function
  • Next by Date: Re: perturbation methods example from stephen lynch's book?
  • Previous by thread: Re: RandomReal gets stuck
  • Next by thread: Re: Re: RandomReal gets stuck