Mathematica 9 is now available
Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: symbol replace

  • To: mathgroup at
  • Subject: [mg51242] Re: symbol replace
  • From: "Steve Luttrell" <steve_usenet at>
  • Date: Sun, 10 Oct 2004 01:57:13 -0400 (EDT)
  • References: <ck88ee$9pk$>
  • Sender: owner-wri-mathgroup at

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.


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

      SubscriptBox["e", "o"], " ",
          SubscriptBox["e", "o"], ")"}], "o"]}]], "Output"]
}, Open  ]],

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

    RowBox[{"Notation", "[",
          SubscriptBox["e", "o"],
          TagStyle->"NotationTemplateStyle"], " ",
        "\[DoubleLongLeftRightArrow]", " ",
          TagStyle->"NotationTemplateStyle"]}], "]"}]], "Input"],


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

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

Steve Luttrell

"symbio" <symbio at> wrote in message 
news:ck88ee$9pk$1 at
>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