What does LaTeX understand as an operator?

I haven't really got how does LaTeX understand the objects created through \operatorname{…}/\DeclareMathOperator. I know that it typesets them in upright roman, but how the system treats it?

When should I use those commands in order that LaTeX treats that functions as operators.

1. $d(x,y)$
2. $\operatorname{d}(x,y)$
3. $\mathit{Var}(x)$
4. $\operatorname{Var}(x)$
5. $P(X=x)$
6. $\operatorname{P}(X=x)$
7. $E[X]$
8. $\operatorname{E}[X]$
9. $\mathit{Bin}(n,p)$
10. $\operatorname{Bin}(n,p)$
11. $B(\ell,\varepsilon)$
12. $\operatorname{B}(\ell,\varepsilon)$
13. $O(x)$
14. $\operatorname{O}(x)$
15. \sigma = \mathit{id}
16. \sigma = \operatorname{id}

d(x,y) means the distance, Var the variance of a distribution, P the probability, E the average (or mean of a distribution), Bin the binomial distribution, B the ball with center l and radius epsilon, O the Big O notation.

In those examples, which ones should be treated by LaTeX as operators? And then be typeset upright.

May be my problem is that I don't really understand what an operator is (apart from it's meaning in LaTeX).

EDIT: well, as @cgnieder says, this can be off topic. The problem, why I thought this wasn't off topic is that I've never thought about operators and upright roman out of the LaTeX world. Basically because I don't change the shape when I handwrite math. Therefore, I do think this is (La)TeX related. Sorry for editing instead of adding a comment, but my connection doesn't allow me to do so.

EDIT2: I didn't want to include the differential operator in the list, as it has its own question.

-
I guess that operator is some symbol (\int for example) or some string (\max for example) which needs (or expect to) some argument after it. For example, \max of what? Or \int of what function? Of course, you can use these commands without argument but I believe that they need extra space after them. – Sigur Jan 26 '13 at 14:47
IMHO you should treat the ones as operators that are indeed operators. Which ones these are is not really a (La)TeX question ... (but maybe someone can prove me wrong) – clemens Jan 26 '13 at 14:49
@Manuel Well, questions are only off-topic if the community decides so :) I'm a bit undecided myself – clemens Jan 26 '13 at 16:37
@cgnieder I know. Just saying my point. – Manuel Jan 26 '13 at 17:13
I think this is a very good question. What is the difference between an operator and a function? Wikipedia says an operator is a special case of a function where the domain and codomain are vector spaces; see here: en.wikipedia.org/wiki/Operator_(mathematics) – EthanAlvaree Dec 7 '14 at 9:49

Mathematically an operator (in this context) is a function used in standard prefix form as opposed to a binary operator such as + that comes between its arguments ((or a postfix operator beloved of group theorists that comes after its arguments.

To TeX an operator is any expression that (after expansion) has been surrounded by the \mathop{...} primitive, or is a character token or \chardef-ed token of math class 1 (large operator).

So to get mathematically meaningful typesetting the idea is to make these two notions match up as well as possible.

Although there are a few wrinkles, notably that a single primitive mathop is vertically centred on the math axis which usually works out OK for symbols in display mode, but often isn't needed for alphabetic operators such as d or D especially in inline math, so sometimes you need to use \mathord rather than \mathop for those, or ensure the mathop atom never just has a single letter by including {} as in \mathop{d{}} (This is what the AMS \DeclareMathOperator does. It's also conventional to use a roman font for multi-letter operator names, although TeX itself doesn't consider the font choice to be part of the mathop specification, the default font for \mathop is the same as that in the rest of the expression.

The spacing given to an atom depends on its class (ordinary or mathop in the current case) but also on the class of the following atom. Your question has a lot of examples, just picking the Bin one You don't really see the effect of mathop spacing when it is followed by ( as that has \mathopen class however if you follow it by an mathord character such as X then you will see the difference more clearly.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

$\mathit{Bin}(n,p)$

$\operatorname{Bin}(n,p)$

$\mathrm{Bin}(n,p)$

$\mathop{\mathrm{Bin}}(n,p)$

$\mathrm{Bin} X$

$\mathop{\mathrm{Bin}} X$

\end{document}


-
Thanks for the answer. But, according to your first paragraph, what differentiates them from a usual function? – Manuel Jan 26 '13 at 17:29
Nothing, operator/function mean the same thing. – David Carlisle Jan 26 '13 at 17:47
Then, when should I tell LaTeX to typeset the function upright and when italic. Again, this may seem off topic, but I think there's no place apart from the LaTeX world where anyone differentiate between italic and upright operators. – Manuel Jan 26 '13 at 17:54
On the contrary LaTeX really doesn't care but it's quite common to use different fonts for different catagories of function eg \mathfrac for groups (or groups of functions) and \mathbf for vectors and vector functions etc A general default is often to use math italic for one-letter names and math roman for mult-letter names, but this is often changed depending on the conventions of the mathematical area, or specified in the current document. – David Carlisle Jan 26 '13 at 18:30
Okey, to sum up, there's nothing which stops me putting upright or italic indifferently to one letter functions (I was trying to find some universal rule, but I will continue using my intuition). And the only thing that LaTeX does to \operatorname{…}, apart from putting it upright, is adding (in case it's necessary) space before and after the operator. – Manuel Jan 26 '13 at 21:16