Why are named variables / indices, symbols not more widespread

index-notationnotation

In computer programming, named parameter are common and often preferred – for pretty obvious readability advantages. Why is the concept no more (or at all) widespread in math?

For example, for $x_{i,t,k}$ instead of writing

$$
x_{2,1,3}
$$

somewhere in the text, to write

$$
x_{i=2,t=1,k=3}
$$

which – granted – is longer, but makes it clear which indices are what. The same can go for $y(i=1,j=2)$ of course.

Two prominent examples of the usage of $=$ are, in equations and in conditions.
For example in the set builder notation

$$
\{x_i\in\mathbb R\mid i=3 \}
$$

as a simple example it is used as a condition.
Or in
\begin{align}
& g(z) = \begin{cases} \quad z \cdot x_i & \quad i = 2 \\[6pt]
\quad z + x_i & \text{otherwise.}
\end{cases}
\end{align}

we use it as a condition.
I would consider $y(i=1,j=2)$ to be very similar to this as in

$$
y(i=1,j=2) = y(i,j), \text{ where } i=1, j=2
$$

I understand that in most formulas we do not actually assign any value to the variables/indices/parameters and often, when we do, it is clear what we mean – especially if there is only one variable as in $f(x)$.
But in some situation, e.g. when function have many variables, it might be really helpful to have named variable assignment, so why is it basically never seen?

Best Answer

Math has the advantage that we can actually accomplish things in the "comments" (that is, in the narrative passages between formulas). Math also tends toward notations that are compact rather than self-documenting, perhaps because the "documentation" is already so baked into mathematical writing styles.

There are also some relatively firm mathematical conventions for subscripts and function parameters, one of which is that there is a first subscript/parameter, a second subscript/parameter, etc.

So if (for example), $i=2,t=1,k=3$, then $x_{i,t,k}$ is not generally the same thing as $x_{k,i,t}$, unless it happens in the case in hand that $x_{2,1,3} = x_{3,2,1}.$

Function parameters, for example $f(i,t,k),$ follow similar rules. Position is everything. The parameters don't generally need names.

In contrast, functions in software programs often have too many parameters with no obvious sequence to help you remember which is which. They often have parameters you use only sometimes; the rest of the time those parameters take default values implicitly. These are strong motivations for using named parameters.

On the other hand, there is a mathematical notation that is something like a named parameter. For example, suppose we define

$$ F = 3x^2 + y^3. $$

Then we could write

$$ F \bigr\rvert_{x=2,y=4} = 3(2^2) + 4^3. $$

If you want to read the left-hand side aloud, you can say, "$F$ evaluated at $x=2,y=4$."

There are some other mathematical conventions that rely on similar ideas. For example, every time you see someone write a partial derivative in a form like

$$ \frac{\partial f}{\partial x}, $$

they are using $x$ as a named parameter, that is, the implicit assumption is that $x$ represents one of the parameters of the $n$-parameter function $f$ and that (at least in principle) we know which of those parameters it represents (for example, the first parameter).

But I have noticed that the $\frac{\partial f}{\partial x}$ causes many people to have difficulty understanding how partial derivatives actually work. (See this question for some more discussion.) When you start naming variables in math the results often aren't particularly happy. This may help explain why it doesn't happen more often.

But if you look long enough I am sure you will find some mathematical work somewhere in which named parameters are used explicitly in a way similar to the named parameters of a programming language, in some case where a function has many parameters or where it is hard to remember what the first parameter means as opposed to what the second parameter means. Mathematical notation is extremely flexible (as long as you tell the reader what you're doing when you introduce something new) and can be redefined to suit any needs, unlike almost any programming language.

Related Question