MathGroup Archive 2004

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

Search the Archive

Re: symbol replace

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51242] Re: symbol replace
  • From: "Steve Luttrell" <steve_usenet at _removemefirst_luttrell.org.uk>
  • Date: Sun, 10 Oct 2004 01:57:13 -0400 (EDT)
  • References: <ck88ee$9pk$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The problem is that your subscripted variable is a symbol which happens to 
have a subscript attached. What you want is for the whole 
symbol-with-subscript to be treated as a symbol. This is what the Notation 
package is for. There is another problem where you are using the symbol E 
which is reserved in Mathematica to represent the base of natural 
logarithms, which might cause you unexpected problems if you use it as a 
standard symbol.

The following Cell Expression shows how to use the Notation package to solve 
your problem. Copy and paste { ... } into Mathematica.

{

Cell[CellGroupData[{
Cell[BoxData[
    RowBox[{
      RowBox[{"e", "*",
        SubscriptBox["e", "o"]}], "/.",
      RowBox[{"e", "\[Rule]",
        SubscriptBox["e", "o"]}]}]], "Input"],

Cell[BoxData[
    RowBox[{
      SubscriptBox["e", "o"], " ",
      SubscriptBox[
        RowBox[{"(",
          SubscriptBox["e", "o"], ")"}], "o"]}]], "Output"]
}, Open  ]],

Cell[BoxData[
    RowBox[{"<<", "Utilities`Notation`"}]], "Input"],

Cell[BoxData[
    RowBox[{"Notation", "[",
      RowBox[{
        TagBox[
          SubscriptBox["e", "o"],
          NotationBoxTag,
          TagStyle->"NotationTemplateStyle"], " ",
        "\[DoubleLongLeftRightArrow]", " ",
        TagBox["e0",
          NotationBoxTag,
          TagStyle->"NotationTemplateStyle"]}], "]"}]], "Input"],

Cell[CellGroupData[{

Cell[BoxData[
    RowBox[{
      RowBox[{"e", "*",
        SubscriptBox["e", "o"]}], "/.",
      RowBox[{"e", "\[Rule]",
        SubscriptBox["e", "o"]}]}]], "Input"],

Cell[BoxData[
    SubsuperscriptBox["e", "o", "2"]], "Output"]
}, Open  ]]
}


Steve Luttrell

"symbio" <symbio at h0tmail.com> wrote in message 
news:ck88ee$9pk$1 at smc.vnet.net...
>I am facing 2 problems with Mathematica:
> 1st problem)
> With replace all command,  when I use it with subscripts I get an 
> unintended
> effect, this is what I do:
> E * (Eo) /. E -> (Eo)
> I intend to replace only E with Eo, but Mathematica instead replaces all 
> E's
> with (Eo) and I get this instead:
> (Eo) * (Eo)o
> Please note the 'o' in Eo is supposed to be a subscript here and reads 
> Enot.
> Can anyone please help?
> here is the Mathematica code:
>
> In[1]:=
> \!\(E\ *\ E\_0\ /. \ E -> \ E\_0\)
> Out[1]=
> \!\(\[ExponentialE]\_0\ \((\[ExponentialE]\_0)\)\_0\)
>
> 2nd problem)
> I like to use descriptive names for my variables with Underscore to 
> separate
> the names, it's really easier to read, but of course underscore is a 
> special
> character in Mathematica unfortunately, so is there an alternative??   For
> example, I like to use variable Dynamic_Energy_of_Stars_With_Sand = 123; 
> Is
> there something else equally as obvious as Underscore that maybe used for
> purpose of separting words in a variables names??
>
> Thanks a lot for your help
> 



  • Prev by Date: Re: Re: Re: Conveniently Restarting Notebooks
  • Next by Date: Re: symbol replace
  • Previous by thread: Re: Re: symbol replace
  • Next by thread: Factor 2 error in Inverse Laplace Transform