Message Boards Message Boards

0
|
7001 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Avoid anomalous behavior of Remove["Global`*"]? with Quit[]?

Posted 7 years ago

I want to use standard engineering notation, so I use Symbolize[] to define a symbol q'' (q double prime) for the heat flux (heat transfer rate per unit area) as a composite of the letter q and double prime (actually two aliased single quotes: [Esc]'[Esc] [Esc]'[Esc]). I also want to use subscripts to denote the heat flux at different locations, e.g., the heat flux through a liquid film is represented by

\!\(\*SubsuperscriptBox[\(q\), \(film\), \(\[Prime]\[Prime]\)]\)

My example code is appended below.

The problem arises when I rerun the notebook using either Shift-Enter or Evaluate Notebook. The first time I run the code, I get the expected answer

\!\(\*SubsuperscriptBox[\(q\), \(film\), \(\[Prime]\[Prime]\)]\))^2

If I run the code a second time, I get the same result again (as expected). A third time, same result.

However, if I run the code a fourth time, Mathematica seems to ignore the Remove[], and I get the unexpected result:

f[\!\(\*SubsuperscriptBox[\(q\), \(film\), \(\[Prime]\[Prime]\)]\)]=625

The problem disappears if I append Quit[] as the final statement.

I'm running Mathematica 11.1.1.0.

Questions:

  1. Why does Mathematica ignore Remove[].
  2. Why does it wait until the fourth time through the code to do so?
  3. Why is Quit[] required to get the correct behavior?

I'm not completely sure if this is a problem with Notation, with Remove, or some interaction of the two.

Thanks.

Example code:

Remove["Global`*"]
Needs["Notation`"];

Symbolize[
ParsedBoxWrapper[
SuperscriptBox["q", "\[Prime]\[Prime]"]]];
Symbolize[
ParsedBoxWrapper[
SubsuperscriptBox["q", "_", "\[Prime]\[Prime]"]]];

f[\[Xi]_] := \[Xi]^2
f[
\!\(\*SubsuperscriptBox[\(q\), \(film\), \(\[Prime]\[Prime]\)]\)]
\!\(
\*SubsuperscriptBox[\(q\), \(film\), \(\[Prime]\[Prime]\)] = 25. \)
POSTED BY: Glenn Carlson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract