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

What is the precedence wrt Mathematica infix operators

88 views
Skip to first unread message

congruenti...@yahoo.com

unread,
Oct 31, 2007, 7:24:51 AM10/31/07
to
Hello Mathematica UG:

I cannot find operator precedence documented anywhere. With the
operators from Fortran (in the old days) this was always clear, i.e
'/' before '-'.

I have been reading some code in the Trott Guidebooks which has
constructions like 'Head @@ face[[i]] / order'. I can guess that Part
has precedence in this expression, but what about Apply vs. Times?

Looking at the OutputForm shows that Apply has precendence. But,...

- Is this documented somewhere?
- Do all Mathematica operators take precedence over arithmetic operators?

TIA.

Regards..


Murray Eisenberg

unread,
Nov 1, 2007, 6:08:21 AM11/1/07
to
I believe this question has arisen in this group before with respect to
Mathematica 6. In any case, if you do some searching in the
Documentation Center, eventually you'll find the tutorial:

tutorial/InputSyntax

In the section "Operator Input Forms" there you'll find a long table
that lists the operators in order of precedence along with additional
explanation.

--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

Szabolcs Horvát

unread,
Nov 1, 2007, 6:12:25 AM11/1/07
to

This is again proof that a hand-made book index can be much more useful
than any kind of full-text search!

I found the relevant sections immediately in the Mathematica 5.2 help.
It took me somewhat more time to look up the same sections in the v6
documentation, even tough I know their title ... :

tutorial/TheSyntaxOfTheMathematicaLanguage
tutorial/InputSyntax (scroll down to Operator Input Forms)

--
Szabolcs

Norbert Marxer

unread,
Nov 1, 2007, 6:14:27 AM11/1/07
to

Hello

Enter "tutorial/InputSyntax" in the text field in the Documentation
Center and hit return.
Then scroll down to the section "Operator Input Forms".
There you will find a long table with operators in decreasing
precedence. One column also tells you how these operators are grouped.

Another way to find out about precedence is clicking in the expression
and repeatedly enlarge the selection with Ctrl . (i.e. pres Ctrl and
the point) or clicking the left mouse button repeatedly (fast).

I hope this helps.

Best Regards
Norbert Marxer


Jean-Marc Gulliet

unread,
Nov 1, 2007, 6:17:29 AM11/1/07
to
congruenti...@yahoo.com wrote:

About operator precedences, there exists nothing better than the good
old Mathematica Book!

The following section contains a long table listing the operators in
order of decreasing precedence:

"A.2.7 Operator Input Forms"
http://documents.wolfram.com/mathematica/book/section-A.2.7

The following two (short) sections contain additional material,
explanations and useful examples.

"2.1.3 Special Ways to Input Expressions"
http://documents.wolfram.com/mathematica/book/section-2.1.3

"2.9.16 Defining Output Formats"
http://documents.wolfram.com/mathematica/book/section-2.9.16

Regards,
--
Jean-Marc

Thomas Dowling

unread,
Nov 1, 2007, 6:21:32 AM11/1/07
to
Hello,

There is an undocumented function, Precedence, which can be useful:

Precedence /@ {Plus, Minus, Times, Power, Apply, Map}

gives the output:

{310., 480., 400., 590., 620., 620.}

I can't remember where I got this info, but it may have been in a
presentation by Kris Carlson.

Tom Dowling

On 10/31/07, congruenti...@yahoo.com <congruenti...@yahoo.com>
wrote:
>
> Hello Mathematica UG:
>


> I cannot find operator precedence documented anywhere. With the
> operators from Fortran (in the old days) this was always clear, i.e
> '/' before '-'.
>
> I have been reading some code in the Trott Guidebooks which has
> constructions like 'Head @@ face[[i]] / order'. I can guess that Part
> has precedence in this expression, but what about Apply vs. Times?
>
> Looking at the OutputForm shows that Apply has precendence. But,...
>
> - Is this documented somewhere?
> - Do all Mathematica operators take precedence over arithmetic operators?
>

> TIA.
>
> Regards..
>
>
>


Jens-Peer Kuska

unread,
Nov 1, 2007, 6:26:38 AM11/1/07
to
Hi,

in "The Mathematica Book", Fourth Edition, page 1012

Regards
Jens

John Fultz

unread,
Nov 1, 2007, 6:47:13 AM11/1/07
to

If you search for Input Syntax in the help viewer, the first hit includes a
table with all of the operators (infix, prefix, and postfix) listed in order of
decreasing precedence (in the "Operator Input Forms" section). I agree that
this should be easier to find.

Sincerely,

John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.

0 new messages