Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: Readability confuses mathematica?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44565] Re: Readability confuses mathematica?
  • From: Jason Harris <jasonh at wolfram.com>
  • Date: Fri, 14 Nov 2003 04:43:12 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Andrzej,

[Notation example snipped]

>  On my system this example just fails miserabley (the
>  definiton of transmissionCoefficient does not parse) although it once
>  used to work. (Actually, I would like to hear from other people,
>  because either the Notation package is no longer working or something
>  is wrong with my installation).

I know these things can appear frustrating at times, but the Notation
package is working fine. In the example you have given, you have
managed to include the box wrapper twice in your Symbolize statement.
(You likely did this through copying the k subscript including box
wrapper and pasted it into a new Symbolize statement.)


>  Anyway, if this works on your system than the problem is solved. You
>  can symbolize subscripted variables and use them as if they were
>  symbols. On the other hand, in the past, when this package used to work
>  on my system, I got myself into a huge mess when I tried to evaluate
>  again a notebook that had previously worked correctly.

If there is some notebook corruption going on then we definitely want
to know about this. In the example you have given it is extremely
likely that you inadvertently caused the error with a copy and paste
from one symbolize statement to another. (I know notation statements
can be tricky and it is not all that hard to "hang yourself".)


>  Because of that I finally decided that relying on a package like this is
>  just too risky if you are doing any serious work.

Hmm... Actually I personally think its just the opposite. If you are
really doing serious work you need to know about typesetting and how
to enter expressions in notations which are familiar to
Mathematicians, physicists, and other users and have these notations
function correctly.

First a general comment:
When you are troubleshooting problems with setting up notations it is
often necessary to look at the underlying boxes representing the
typeset expression. You can do this through either the command key
shortcut of cmd-shift-E (OSX) and I think cntrl-shift-E (Win), or
through the menu item "Format" -> "Show Expression..."

Looking at the underlying boxes shows you how the typeset expression
is represented. As a Mathematica programmer you no doubt use FullForm
at times to examine how a certain pattern is structured. Its really
not too different with typesetting in that Mathematica functions through
MakeBoxes and MakeExpression which operate on these box structures. If
you don't have the correct structures, the boxes will not be
interpreted as they should be.

In a Symbolize statement waiting to be filled in the underlying
structure is

Cell[BoxData[
     RowBox[{"Symbolize", "[",
       TagBox["\[Placeholder]",
         NotationBoxTag,
         TagStyle->"NotationTemplateStyle"], "]"}]], "Input"]

To see this load the notation package, type Esc-symb-Esc and then show
the underlying expression. The box structure to be symbolized must be
the first argument of this TagBox.

The tag box wrapper, NotationBoxTag, is necessary so you can enter
typeset expressions into Mathematica that are not currently
syntactically valid. Then once the Notation package gets a hold of
them, it compiles / translates these into corresponding rules for
MakeExpression and MakeBoxes that do what you instructed. The tag box
wrapper inertizes the box structure so it becomes syntactically valid
Mathematica input.

You can see this by copying out the box wrapper into a new cell and
entering some syntactically invalid input into the wrapper, say "x"
followed by "*", and then viewing how it is interpreted by
Mathematica. E.g. after loading the notation package paste the
following cell into Mathematica and interpret it:

Cell[BoxData[
     TagBox[
       RowBox[{"x", "*"}],
       NotationBoxTag,
       TagStyle->"NotationTemplateStyle"]], "Input"]

Then evaluate this interpreted cell. Then start a new cell and
evaluate FullForm[%]. The answer will be

NotationBoxTag[RowBox[List["x", "*"]]]

Thus the TagBox wrapper, NotationBoxTag, has allowed us to enter
something that is syntactically invalid and get the box structure into
the kernel. (Incidentally you can programmatically create symbolize
and notation statements this way.) The TagBox wrapper NotationBoxTag
can do this miraculous feat because it itself has a corresponding
notation. (The TagStyle option is set so you can get some visual
indication of where these tag box wrappers occur.)

So anyway getting back to your example if you look at the underlying
boxes you will see that instead of having

Cell[BoxData[
     RowBox[{"Symbolize", "[",
       TagBox[
         SubscriptBox["k", "_"],
         NotationBoxTag,
         TagStyle->"NotationTemplateStyle"], "]"}]], "Input"]

You had

Cell[BoxData[
     RowBox[{"Symbolize", "[",
       TagBox[
         TagBox[
           SubscriptBox["k", "_"],
           NotationBoxTag,
           TagStyle->"NotationTemplateStyle"],
         NotationBoxTag,
         TagStyle->"NotationTemplateStyle"], "]"}]], "Input"]

i.e. the wrapper was in there twice. Fixing this mistake resolves your problem.

Cheers,
   Jason

-------------
Jason Harris
Wolfram Research


  • Prev by Date: Re: Cartesian[(x, y, z)] is not a valid coordinate system specification
  • Next by Date: I have put "==" in every equation I have in NDSolve, why it keeps telling me they are not equations
  • Previous by thread: Re: Readability confuses mathematica?
  • Next by thread: Re: Readability confuses mathematica?