Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Typesetting bug

11 views
Skip to first unread message

replic...@gmail.com

unread,
Feb 13, 2009, 3:40:25 AM2/13/09
to
Dear Group,

I don't know whether this "feature" is widely known or not, but it
surely gave me an hour of scratching my head, buried deep inside a
calculation:

In[7]:= n = .5;
x = 1;

ax = 1;
{(ax^n), x^n, ax^n - x^n}

Out[10]= {1, 1, 0}

In[11]:= max = 1;
{(max^n), x^n, max^n-x^n}

Out[12]= {1, 1, -1}


This inconsistency happens only if exponents are typed in as real
superscripts with Ctrl+^. A FullForm reveals an underlying Times in
the last case, which ultimately is responsible for the wrong answer.
Furthermore, max^n does not work as intended if typed and evaluated in
one call, as follows:
max <Ctrl+^> n <enter> x <Shift+Enter>
because it is interpreted as a product of max^n and x.

Istvan Zachar


replic...@gmail.com

unread,
Feb 14, 2009, 3:07:32 AM2/14/09
to
For those who are interested:

It does happen in v6 and v7 as well, 5.2 I can not test. It happens
even with a fresh kernel. The problem boils down to the fact that when
max^n is typed in with n as a superscript, any *new line* of input in
the same cell will be treated as a factor in a product with max^n. So
to reproduce, one has to input max^n with the Ctrl+^ combination. Can
anyone confirm this bug?

I copy the lines here, although note that simply pasting it to a
notebook won't replace ^n with a real superscript. Also note that the
output is not two outputs, as I would expect it, but Times[...]

In[3]:= max^n
x

Out[3]= max^n x

While the following code returns output as expected:

In[2]:= ax^n
n

Out[2]= ax^n

Out[3]= n


With fresh kernel, as I have stated.

Istvan


David Park

unread,
Feb 14, 2009, 3:08:47 AM2/14/09
to
I would say that it's a bug. Also you shouldn't have to put parentheses
around the first max^n. It's as if Mathematica is using 'max' internally in
such a way to conflict with user expressions. They also use 'comment'
internally and let it leak out.


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/

dh

unread,
Feb 14, 2009, 3:11:07 AM2/14/09
to

Hi Istvan,

I can not reproduce your result. I guess it depends on the version. I

have version7 / Windows and there it is o.k.

regards Daniel

Fred Simons

unread,
Feb 15, 2009, 3:19:41 AM2/15/09
to
To answer your question: yes.

I think that your bug is closely related to a bug that I reported many years ago to WRI and that still exists.

Type in an input cell max^n + 4, with n as a superscript, and evaluate. Then the result is 4 * max^n.

The same happens with max replaced with min, but not with Max, Min, mAx, mIn, etc, and not with e.g. sin.

Of course all this weird but very irrelevant.

Kind regards,

Fred Simons
Eindhoven University of Technology


replic...@gmail.com

unread,
Feb 15, 2009, 3:22:42 AM2/15/09
to
Hi David,

can you say more on this internal 'comment' bug? I couldn't find any
info about it.
Perhaps it would be worth to look for all the possible interfering
words, that shouldn't be used as variable names, and then inform WRI.
I certainly know about a "K" that is not mentioned in the
documentation, but still is a System' symbol (covered at
http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread=
/thread/f5d74f6c0ca98774/62974b25f30bb546?hl=en&lnk=gst&q=strange+%22=
K%22#62974b25f30bb546).

Istvan

On Feb 14, 9:08 am, "David Park" <djmp...@comcast.net> wrote:
> I would say that it's a bug. Also you shouldn't have to put parentheses

> around the first max^n. It's as if Mathematica is using 'max' internally =


in
> such a way to conflict with user expressions. They also use 'comment'
> internally and let it leak out.
>
> David Park

> djmp...@comcast.nethttp://home.comcast.net/~djmpark/

David Park

unread,
Feb 16, 2009, 6:53:11 AM2/16/09
to
Istvan,

In the Presentations package I have formatting routines named 'comment' and
'command'. I used small 'c's deliberately to avoid any conflicts with
Mathematica names. The package loads properly without any shadowing in a
notebook, but one person loads the package in his init.m file and that gives
a shadowing error - in Version 7. I have no idea why that happens and I'm
not going to try to figure it out. Names that begin small case are supposed
to be safe.

From: replic...@gmail.com [mailto:replic...@gmail.com]

Hi David,

can you say more on this internal 'comment' bug? I couldn't find any
info about it.
Perhaps it would be worth to look for all the possible interfering
words, that shouldn't be used as variable names, and then inform WRI.
I certainly know about a "K" that is not mentioned in the
documentation, but still is a System' symbol (covered at
http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread=
/thread/f5d74f6c0ca98774/62974b25f30bb546?hl=en&lnk=gst&q=strange+%22=
K%22#62974b25f30bb546).

Istvan

On Feb 14, 9:08 am, "David Park" <djmp...@comcast.net> wrote:

> I would say that it's a bug. Also you shouldn't have to put parentheses

> around the first max^n. It's as if Mathematica is using 'max' internally =


in
> such a way to conflict with user expressions. They also use 'comment'
> internally and let it leak out.
>
> David Park

> djmp...@comcast.nethttp://home.comcast.net/~djmpark/

m...@inbox.ru

unread,
Feb 16, 2009, 6:52:38 AM2/16/09
to

Remove "max" from the LimitsPositioningTokens list (Edit|Preferences|
Advanced|Open Option Inspector|Formatting Options|Expression
Formatting|Display Options); otherwise "max" with a superscript is
being treated as an operator.

Maxim Rytin
m...@inbox.ru

Curtis Osterhoudt

unread,
Feb 16, 2009, 4:40:51 PM2/16/09
to
Agreed: probably a bug. However, on my system ["7.0 for Linux x86 (32-bit) (November 11, 2008)"] the two answers are the same.

C.O.

On Friday 13 February 2009 01:40:38 am replic...@gmail.com wrote:
> Dear Group,
>
> I don't know whether this "feature" is widely known or not, but it
> surely gave me an hour of scratching my head, buried deep inside a
> calculation:
>
> In[7]:= n = .5;
> x = 1;
>
> ax = 1;
> {(ax^n), x^n, ax^n - x^n}
>
> Out[10]= {1, 1, 0}
>
> In[11]:= max = 1;
> {(max^n), x^n, max^n-x^n}
>
> Out[12]= {1, 1, -1}
>
>
> This inconsistency happens only if exponents are typed in as real
> superscripts with Ctrl+^. A FullForm reveals an underlying Times in
> the last case, which ultimately is responsible for the wrong answer.
> Furthermore, max^n does not work as intended if typed and evaluated in
> one call, as follows:
> max <Ctrl+^> n <enter> x <Shift+Enter>
> because it is interpreted as a product of max^n and x.
>
> Istvan Zachar
>
>
>

--
==========================================================
Curtis Osterhoudt
cfo@remove_this.lanl.and_this.gov
PGP Key ID: 0x4DCA2A10
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
==========================================================

0 new messages