11

If I have something like $\phi\circ \psi(x)$ this means first apply $\psi$ and then $\phi$. Going right to left is pretty contrary to my intuition.

In computer science some programming languages (and many compilers) use reverse Polish notation, where this would be written $x\psi\phi$.

I occasionally see algebraic texts using this type of notation (Glass' Partially Ordered Groups is one example); I suspect because this notation fits better with the idea of groups.

  1. Is there a name for this notation in algebra or is it just called Reverse Polish Notation there too?
  2. And why do we have the bizarre right to left function notation? Wikipedia cites Euler on several pages, but doesn't explain how he came up with it or why people stuck with it. Even if he had just decided to write it like $(x)f=x^2$ that would've been better.

EDIT: to explain why this is confusing, suppose I was explaining an algorithm to someone like "first double a number, then square it, then take the sine of that." If I wrote this in the usual math notation I would write it in the opposite order of my instructions: $$(x\mapsto \sin x)\circ (x\mapsto x^2)\circ (x\mapsto 2x)(x)$$ instead, it would be easier if I did it in the same order as my instructions: $$(x)(x\mapsto 2x)\circ (x\mapsto x^2)\circ (x\mapsto \sin x)$$

Xodarap
  • 6,303
  • 1
    FYI, Herstein's Topics in Algebra, arguably the best known advanced undergraduate level abstract algebra textbook in the last 50 years, uses the reverse notation that you like. – Dave L. Renfro Sep 18 '14 at 14:42

3 Answers3

7

In abstract algebra, we don't refer to it as Polish notation, but "prefix notation" and "postfix notation" do seem to be apt names for talking about these two things.

The two notations $(x)f$ and $f(x)$ have both been used historically; however, I think the latter is far more prevalent today. There may be some concrete anthropological reason we prefer the former, but it is probably driven mostly by tradition and history, like a lot of notation.

Each of these leads naturally to more notation as function composition occurs: $((x)f)g)$ and $g(f(x))$. The former can be abbreviated to $(x)fg$ and the latter to $gf(x)$. But really, they define exactly the same function, just written with two different conventions.

Actually, both notations come in handy for noncommutative algebra. When we have a homomorphism $f$ of right $R$ modules, it's conveninent to write $f$ on the left, for then the rule of homogeneity for homomorphisms becomes $f(x\cdot r)=f(x)\cdot r$. If we had used the other convention, then it would look like $(x\cdot r)f=(x)f\cdot r$, which is somewhat less appealing.

But if we are talking about a homomorphism of left $R$ modules, then we would prefer to write $f$ on the right, so that $(r\cdot x)f=r\cdot(x)f$. Arranging things this way is just an aesthetic convenience.

rschwieb
  • 160,592
2

Consider it (and call it, if you need a name) the composition of functions (after all, permutations are functions). Remember:

$$(\phi\circ \psi)(x) = \phi(\psi(x))$$

We work from inside out to determine $(\phi\circ \psi)(x) = \phi(\psi(x))$:

First determine $\psi(x)$, then you can determine $\phi(\psi(x))$.

This is no different than how we approach the notation $(f\circ g)(x) = f(g(x))$, and I've never heard this referred to as "reverse Polish notation."

To me, seems counter-intuitive to interpret $(f\circ g)(x)$ by first finding $f(x)=y$ and then taking $g(y)$.

amWhy
  • 210,739
  • A way of reading this left-to-right by the way is $\phi$ after $\psi$. – AlexR Sep 18 '14 at 14:10
  • "First determine ψ(x), then you can determine ϕ(ψ(x))" - this is right-to-left...? (In case it wasn't obvious, I'm aware how to evaluate functions. I'm just wondering about the notation.) – Xodarap Sep 18 '14 at 14:20
  • What I'm comparing this to is function notation. Is function composition notation counter-intuitive? Is evaluating expressions enclosed in parentheses counter-intuitive? E.g., $12/(3+1)$ is evaluated from right-to-left, in part. The parentheses serve as a notational cue to this effect, just as the $\circ$ between to functions serves as a notational cue that we are defining a composition of functions, and to apply the function closest to the variable first... – amWhy Sep 18 '14 at 14:25
  • 1
    Notation is a matter of convention, and convention historically evolves, and is also influenced by culture. – amWhy Sep 18 '14 at 14:28
  • That makes sense, but please see my edit – Xodarap Sep 18 '14 at 14:28
1

A possible reason of your confusion might be that you are mentally considering functions as acting on the right on their arguments as illustrated by the arrows in your example $$ x \xrightarrow{sin} sin(x) \xrightarrow{x^2} sin^2(x) $$ Now, when you have a right action of a semigroup $S$ on a set $P$, it is indeed simpler to use this kind of notation. Formally, a right action of semigroup $S$ on a set $P$ is a map \begin{align} P \times S &\to P \\ (p,s) &\to ps \end{align} such that for all $s,t \in S$, $$ (ps)t = p(st) \quad (1) $$ a condition that looks natural with this notation.

Now, consider the dual definition of a left action of a semigroup $S$ on a set $P$. It is easier this time to define it as a map \begin{align} S \times P &\to P \\ (s,p) &\to sp \end{align} satisfying, for all $s,t \in S$, $$ t(sp) = (ts)p \quad (2) $$ This is the point of view used with the notation $\circ$ for the composition of functions: if you consider a function $f$ as acting on the left on the variable $x$ to produce $f(x)$, this defines an action of the semigroup of functions under composition and the formula $(f \circ g)(x) = f(g(x))$ is similar to (2) and not to (1).

J.-E. Pin
  • 42,871