Why do mathematicians use single-letter variables?

24.6k Views Asked by At

I have much more experience programming than I do with advanced mathematics, so perhaps this is just a comfort thing with me, but I often get frustrated when I try to follow mathematical notation. Specifically, I get frustrated trying to keep track of what each variable signifies.

As a programmer, this would be completely unacceptable no matter how many comments you added explaining it:

float A(float P, float r, float n, float t) {
  return P * pow(1 + r / n, n * t);
}

Yet a mathematician would have no problem with this:

$A = P\ \left(1+\dfrac{r}{n}\right)^{nt}$

where
$A$ = final amount
$P$ = principal amount (initial investment)
$r$ = annual nominal interest rate (as a decimal)
$n$ = number of times the interest is compounded per year
$t$ = number of years

So why don't I ever see the following?

$\text{final_amount} = \text{principal}\; \left(1+\dfrac{\text{interest_rate}}{\text{periods_per_yr}}\right)^{\text{periods_per_yr}\cdot\text{years}}$

21

There are 21 best solutions below

4
On

We are very, very lazy. I am very, very serious about this.

NB1: The history is told in Florian Cajori's book on the history of notation. In very old times, there were no variables (and no formulas, really) and everything was incredibly verbose. Cajori's book beautifully shows the very long and tortuous way from that to modern day notation for variables; there are several sections regarding the notation of unknowns and of their powers.

NB2: Additionally, we usually deal with very complicated expressions, so using verbose names for variables you render things almost impossible. Writing down the formula for Gaussian curvature in terms of $E$, $F$, $G$ and the Christoffel symbols if we wrote $\mathsf{Christoffel}^i_{jk}$ instead of $\Gamma^{i}_{jk}$ would turn differential geometry into a dead subject very soon :P

2
On

I can't imagine writing full words when solving equation and rewriting it 10 times, when programming you usually don't write it so much, you can use functions, classes, copy/paste, programs which automatically insert variables etc.

10
On

My linear algebra professor (J. Komlos) said something that has always stuck with me: we should always use the same letters to denote certain variables, and different letters for different (math) subjects. In this way, our brains are able to build mental pathways so that when we see certain letters we can remember lots of other things we know about that subject because we associate those letters with certain facts, theorems, etc.

I actually think it's mostly a cultural phenomenon, comp-sci people like to use acronyms in part because it's more clear to program with an acronym than a single letter. But similarly, chemists like to use Latin words, physicists make up descriptive names for things, and mathematicians make up new words no one has ever heard of before.

1
On

It's a convention like any other; never underestimate the power of historical inertia! Different disciplines have different conventions.

I would also guess (and I have no evidence to support this) that a big reason it is currently still around is that typesetting equations was expensive and time-consuming before the rise of modern typesetting (e.g. TeX) and writers of textbooks were probably encouraged to keep their notation as concise as possible. This would explain the disparity between mathematicians and programmers since the latter, after all, have the benefit of a history of using computers.

0
On

A few thoughts:

  • It is not true that one does not see formulae as you wrote in the very last line, something like $$ \mathrm{velocity} = \frac{\mathrm{displacement}}{\mathrm{time}} $$ In fact, I was taught algebra that way: start with word problems and write down mathematical expressions with words and labels, instead of numbers. I believe this kind of notation is also often used in textbooks.
  • Like Mariano and Templar said in their answers, one of the main advantage of the short single letter notation is ease of copying. For computations it is much easier to write (by hand) single letters than whole strings.
  • Another issue similar to the above is that it is easier to visually recognize identical terms when you use single letters. Take the expression for the "final amount" you wrote down. I happen to think that using the string "periods_per_yr" makes it harder to notice that the same term appear both in the denominator inside the brackets and in the exponent outside. Algebraically it is perhaps easier to keep track of structures using single letters.
  • Also, what about when performing abstract arguments where the variables do not refer to anything specific and concrete? Is the phrase "take three points in the plane, point_one, point_two, and point_three..." more easily to understand than "take three points $P,Q,R$ in the plane..."?
  • Lastly, in my PhD dissertation I have several computations involving expressions that span close to half a page when printed. I shudder to think what would happen if I use verbose names for all the terms: is it worth it to make individual variables more "legible" at the expense of making each equation span 3 pages? Does that actually improve overall legibility?
1
On

I don't think that substituting single-letter variables with more letters would do much positive in most mathematics, because most theorems (and such) are short enough so that remembering a few variables isn't a problem. And if you forget, it is just to look at the start of the theorem. Also, there is conventions for what variable-letters to use in different circumstances. And last, it is a way to make it easier to separate words from variables.

In programming, the ability to have more letters for one variable, is a huge advantage because a program often consists of thousands of lines, and hundreds of variables.

8
On

Perhaps the most compelling reason for using single character variables is that it enables the usual convention of omitting the multiplication sign in products. This enables great conciseness in notating polynomials - which is important since polynomials are ubiquitous in mathematics, so any convention that simplifies their notation, comprehension, etc is surely worthwhile. Thus we can write $\rm\ xyz\ $ to mean $\rm\ x\cdot y\cdot z\ $ without any worry that it will be mistaken for a variable name.

While having to insert the multiplication signs doesn't reduce conciseness much for a monomial, it can greatly increase complexity for a polynomial of many terms. For it may cause equations to overflow the line/page length, etc, greatly hindering comprehension. Moreover, as many cognitive studies show, humans read words by their shape (e.g. cover up the top/bottom half of a line of text and note how you can still easily read it), so any convention that alters shapes (or increases their visual complexity) may inhibit visual parsing, pattern-matching, and global inference of key structural characteristics.

1
On

Because a variable is just a number and they all behave equally, different variables dont have any different meaning or interpretation in math, you dont gain any additional information by writing "final_amount" instead of x. Its only confusing and unproffesional. Even if you try to follow this path, there can be intermediate steps in solving an equation in which these words can not be interpreted in any sensible physical or informal way. For instance it can be convenient to introduce imaginary numbers even when solving equations with real solutions.

9
On

I think one reason is that often one does not want to remember what the variable names really represent.

As an example, when we choose to talk about the matrix $(a_{ij})$ instead of the matrix $(\mathrm{TransitionProbability}_{ij})$, this expresses the important fact that once we have formulated our problem in terms of matrices, it is perfectly safe to forget where the problem came from originally -- in fact, remembering what the matrix "really" describes might only be unnecessary psychological baggage that prevents us from applying all linear-algebraic tools at our disposal.

(As an aside, have you ever seen code written by a mathematician? It very often looks exactly like your first example.)

0
On

A number of excellent explanations have been given, ranging from laziness of mathematicians to convention. I'd like to add one more that may be slightly more debatable than others.

I dare to say I experience some sort of freedom when assigning variable names. This freedom is very typical to math: ideas are not bound by physical reality, the only constraints are your own imagination and the consistency of your thoughts. This freedom suffers if you're thinking about your math too concretely.

Here are a few remarks to explain my point of view:

  1. Somewhere in the 15th century ($\pm$ a few centuries) people realised they didn't have to discribe their equations in words, they could just assign letters to their quantities and let the formulae speak for themselves. Suddenly people realised it was not necessary for algebraic equations to have a direct geometric meaning. If people had kept writing $\rm area = length\cdot width$ until the end of days, this might never have happened.
  2. Let's say we were thinking about distance. We might write $$ \rm distance = \sqrt{horizontal\ displacement^2 + vertical\ displacement^2}.$$ However, would you ever dare to write $\rm distance = |horizontal\ displacement| + |vertical\ displacement|$? Maybe you would, but write this on the blackboard of an average high-school physics teacher (no offence meant) and they might try to hit you with something. This is because they're thinking about the physical reality, not about the abstract properties of such a formula or it's consequences in a more abstract setting. Therefore if you ever want to define the concept of a metric space and study it's properties in full generality, it's probably safer to denote distance simply by "d". (Choosing 'd' as a small mnemonic to where it all started.)
  3. Let's say we're thinking about a curve this time. At some point you may come to realise there's actually an interesting group structure on your curve. If you're refering to your curve simply as "curve" everywhere, it's probably a giant leap to suddenly rebaptize your curve into "curve that is actually a group as well". You'll probably still call your curve "curve" all the time and you may unconsciously make it harder for yourself to realise the importance and usefullness of it's group structure.

In conclusion: math is an abstract science, assigning the name all to concrete names to objects will constrain your imagination, which is always a bad thing in math.

5
On

Actually, I think the reason why single letter identifiers are popular in math, and not so popular in programming is Intelisense. Today, every profesional developer would flinch if shown something like return P * pow(1 + r / n, n * t), but we have been spoiled by the ease of use of automatic filling of long names.

As I remember, 10-15 years ago it was more common to use single or double letter names for any local variable, because the developer would have to write each character himself, by hand. Right now, I just press a few keys, and the IDE does the rest.

BTW, the name of the function used in the example (pow for Power) fits nicely with the explanation.

1
On

When doing algebra by hand with pencil and paper, it's a lot easier - and a lot faster - to work with something like

PV=nRT

instead of

(pressure)(volume) = (number of moles of gas) (gas constant) (temperature).

And this matters a lot when you're doing a timed exam.

0
On

I write: Solutions of quadratic equation $ax^2 + bx + c=0$ are $(-b\pm\sqrt{b^2-4ac})/(2a)$. I would not want to write this with time in place of $x$ and acceleration_of_gravity in place of $a$ and so on!

3
On

You're sort of comparing apples and oranges.

Mathematical papers are written in verbose, descriptive language (e.g. English); equations and such are introduced to introduce precision and brevity when needed.

A computer program, however, is written in a very precise language. The role of some coding style guidelines (e.g. long identifier names) are to introduce the verbose, descriptive language where needed.

Also, mathematics is "executed" -- humans have to manipulate them.

Computer programs, however are almost never executed. Even in an interpreted language, your program will get tokenized and parsed, and the interpreter will operate on the result.

2
On

I think mathematicians continue to use such terse notation because they don't have to maintain their creations under time pressure. Mathematics is essentially a write-once language and it only runs inside another mathematician's very forgiving brain. You can spend an hour rereading the same paragraph in a math paper until you understand it, taking time to absorb and reabsorb the sundry meanings of the Greek and Roman characters arrayed before you, and nothing bad will happen in the meantime. In an IT operating environment, we don't have that luxury. If I were ever rolled out of bed at 0300 to deal with a computer system problem and I had to deal with scripts/logs written anything like a typical math theorem, the person/idiot responsible for those scripts/logs would be strangled/fired before sunup.

0
On

If we saw something like the above, then the alphabet implicitly used in mathematics would consist of words. So, then the individual letters of that alphabet basically require another language to get understood in the first place. In other words if you have something like "velocity=distance/time" then you have "velocity", "distance", and "time" at least as implied as existing in some language as part of its alphabet. But, of course, you're wanting those symbols also to represent English words which have meaning also. Thus, you need two alphabets working together at once, as well as two languages working together at once, and it's not at all clear that you'll avoid ambiguity in principle when you do this. You will have character strings which consist of a word in one language and a letter of the alphabet in the other language at the same time.

On the other hand the more common way just requires one alphabet and one language. In principle, one doesn't need any understanding of any natural languages to have v=(d/t) mathematically speaking. You just need "v", "d" and "t" as variables in your alphabet... and to perhaps make this clearer you could write the same formula mathematically as 6=(7/8) given 6, 7, and 8 as variables in your alphabet for some language. But, then we wouldn't seek to use "6", "7", and "8" to denote numbers, because then we would have two languages working simultaneously.

Basically, it comes as simpler to have v=(d/t) than to have velocity=(distance/time).

0
On

Its quite self explanatory if you read of how Cardan wrote polynomials:

Instead of

$$x^4+6x^2+36 = 60x$$

He'd write

$$1\overline{q}d\overline{q}d. p: 6\overline{q}d. p:36 \text{ aequalia. } 60 pos.$$

or to write

$$x^4+(2y+12)x^2 +y^2+12y+36 = (2y+6)x^3+60x+y^2+12y$$

He'd put

$$1\overline{q}d\overline{q}d. p:2 pos.p:12 \overline{q}d \text{ R }p:1\overline{q}d.p:1 pos. \text{ additi numeri } p:36 \text{ aequalia. } $$ $$2 pos.6\overline{q}drator\overline{u},p:60 pos.p:1 \overline{q}d. p:12 pos. \text{ numeri additi }$$

3
On

Because the intellisense & autocompletion on my piece of paper is turned off. :)

(So is the context sensitive color highlighting.)

Holy cow, imagine a sheaf cohomology commutative diagram chase with camel casing and vaguely Java like method syntax for all operations. Or even just the chain rule:

derivative(firstSmoothFunction.composedWith(secondSmoothFunction)) = derivative(firstSmoothFunction).composedWith(secondSmoothFunction) * derivative(secondSmoothFunction)

In many cases the more concise notation may make it harder to remember what stands for what, but well chosen notation makes the relations between things much more apparent.

2
On

I'm a programmer as well. Note that your initial phrasing would be better as "As an imperative programmer, ..."

If you look at functional programming languages like F# or Lisp, the single letter variable paradigm is quite common for many of the reasons mentioned in the other answers. Take the functions:

let square x = x * x;;
let power x y = x ^ y;;

These are common and accepted ways to write your functional functions. This is mostly due to stateless/immutability differences in variables, but if we can skip the why explanations I'll just assert that the functional programming style parallels mathematical thinking far better than imperative.

Now imperative programming (by far the majority of programming) is more like a list of instructions, what I would compare in mathematics to a proof. If you remember back to 'doing proofs,' you state your reason for making each step along the way; in some cases rather verbosely.

0
On

I am a retired software engineer and a math person. I am going to answer your question based on my own personal experience and observation.

The coding style in your first example is unacceptable today but was common in old days. The FORTRAN programs written in 60's and 70's are like that.

The programmers deal with real life problems. The reasons programmers use long variable names are mostly for readability and easy to debug. Programmers are asked to use long names because they were having difficulty understanding code written by others and debugging code written in short names. I was once shown a piece of code written by myself and could not figure out what I was doing.

On the other hand, mathematicians mostly deal with abstractions. The formula in your example generally will be present with the explanation you provided. Later on in the literature, the author can use t, which is the number of years, wherever it is needed without repeated explanations. Most mathematicians follow certain conventions, say they usually use x for an unknown, c for a constant without explanation. This sometimes will give the readers some trouble understanding the text if unusual conventions were used. Also, the reader will have to get used to the notation the author adopts. Sometimes it's a pain.

In either case, there is a compiler there. In the programming case, you have a compiler to help generating machine code for the computer to understand. In the math case, your brain is the compiler to generate the knowledge.

0
On

Yet another aspect...


In fact not all symbols consist of only one letter:

I have to get pretty creative within my publications not to exhaust all symbols within the one publication - including capitalization, other fonts and greek letters. I am not at all able to stay consistent within my entire body of work precisely because there are not enough letters. So, I actually use - at times - symbols with more than one letter. Thanks to that I have the iron rule to always use a dot for multiplication.

However, I try to avoid it, because of many of the mentioned reasons. It also helps to think hard before introducing a new symbol. This leads me to think whether I really need this new symbol or whether there is an underlying principle that allows me to abstract multiple concepts into a single concepts. This makes me a better researcher and actually leads to new publications by itself. (You could say the publications write themselves :-P.)

However, most publications in general do not need that many symbols and even I do not even nearly need as many symbols as I do while programming.