Mathematics should learn from programming standards

I have no idea if this is true, but I suspect that math is written the way that it is due to history.

Historically, a lot of math was done by etching or scratching into clay, wax, or other mediums. Even after this period, with the introduction of paper and pens, those materials were still somewhat expensive, difficult to use, and unforgiving of error.

If you are writing text, one surmises, this isn’t so bad. We’re built for language and, with practice, can come to write fluently in a single go, without too horrible of a result.

With math, a lot of the work is work. You have to develop an idea, go down lots of rabbit holes, cross a lot of stuff off, etc. You don’t just sit down and plonk out your new paper every day like a columnist can do with his articles.

There’s a value, in historic times, for brevity of written material and far moreso - potentially - for mathematics.

That, I suspect, has tempered the culture of the field and stayed as a relic of that past.

In programming, if you named your variables ‘a’, ‘b’, and ‘m’, everyone would take you out into the parking lot and shoot you out of a cannon to get you as far away from them as possible. These sorts of names simply make it harder to follow and understand the material. (I have had to work with code like that. It sucked.)

Trying to read a math paper, you’ll come across a formula and have to spend 5 minutes scouring the text to try and find where they introduce the variable, what it signifies, what type it is, what restrictions there are on it, and how it has been initialized. Occasionally, that all seems to be absent all together.

To be fair, there are certainly areas of pure mathematics where one might say that a named variable would have the danger of implying a certain understanding or way of thinking that misleads the reader away from a more “pure” view of the mathematics, I don’t know. But I suspect that for most professional math, that’s an argument that isn’t particularly valid. And I further suspect (but admit to having no knowledge) that many math papers are founded on work done in Python or R, probably following standard programmatic convention and using full, meaningful variable names. And yet - if that’s true - the resulting paper will probably end up with the single letter names again. If so, then clearly that’s silly that there’s the discrepancy.

Teaching kids is almost certainly strongly hampered by this tradition.

F = MV is just nonsense. The letters are clearly chosen to represent concrete realities of our world. It is not pure mathematics. This isn’t to say that all nor even most kids would remember force = mass X velocity, but it probably would be slightly more who did than today and there would probably be less of an overall sense of impenetrability and obfuscatory intent on the part of the people who work in that field. People might be just a little more open to going that direction.

Perl and regexes are things that, with experience, you can come to understand natively without having to think about it too much. There is some minor gain in power because of the brevity.

But you’ll notice how much real work gets done using something else and how much people grumble at having to use those languages, simply because they are purposefully obtuse and ambiguous to anyone who isn’t a grizzled expert. And there really isn’t that much gain for the cost. Regexes are fine as a tiny subpart of a larger application but they have that whole application around them that’s actually readable and usually the regex isn’t something that you need to care about the specifics of, just the general purpose it’s filling.

With a math paper, like an application with some regexes embedded in it, we’re reading plain English as our principle meat and potatoes of the matter with a few pieces of arcane nonsense placed occasionally.

English is not a particularly technical medium. If you have to use plain English to explain the bulk of your math, that’s strange. In a program, only very little needs to be English for a person to follow along. That mathematicians have to resort to English rather than something more on the level of Java or Python is possibly somewhat telling that there may be a high level mathematical language gap.

In a program, the extra arcane bit is generally inconsequential. It’s not core logic. But with a math paper, the arcane formulas using mystery variables are the most important thing to be able to understand and yet, as said, they’re dependent on a bunch of setup written in plain English and, frequently, that’s largely insufficient to explain what we’re talking about. I’ll be told that Ξ is the day (of the month? Of the year? Of some test period??) but then, never see that letter in any formula. After investigation, one might determine that the author has used the following in the formulas:

ξ[sub]k-1[/sub][sup]p[sub]3[/sub][/sup] :rolleyes:

The emoji may or may not be a part of the formula.

I say to thee:

https://perl.plover.com/obfuscated/tpj.pl

Of course it’s nonsense. It’s actually F=ma. Or sometimes F=d/dt(mv).

I can somewhat see why using single-letter variables can be confusing. I don’t think there’s much issue when dealing with short formulae. In a long formula, it might just not be practical to use longer variable names. The actual constants usually do get more specific names.

It does get confusing when the same letter is used for representing different concepts, especially in physics. Is P pressure, power, momentum?

Beyond that, I don’t really know what you’re suggesting as a solution.

The answer to “why don’t we change something with hundreds of years of tradition and a huge body of already existing work to make it newer and more convenient?” is always that it has hundreds of years of tradition and a huge body of already existing work.

The TL;DR is something like: Computer programmers are encouraged to use descriptive variable names, and people who write mathematical equations and formulas should be encouraged to do the same, instead of using single letters and symbols that don’t indicate what they stand for. Is that about it?

My response: In some cases, you may be right.

In some cases, the abstraction is the point. Either the variables could stand for anything, or we don’t want the distraction of worrying about what they stand for while we’re doing the actual math on them.

In some cases, mathematical work—the work involved in actually solving an equation—involves many lines of handwritten work, which would be much harder to write and to work with if the x’s and epsilons were words or phrases.

Imagine what the quadratic formula would look like if, instead of a, b, and c, it were written in terms of secondDegreeeTermCoefficient, firstDegreeTermCoefficient, and constantTerm.

Even worse, imagine what the derivation of the quadratic formula would look like if you had to complete the square on

secondDegreeTermCoefficient * variable^2 + firstDegreeTermCoefficient * varianble + constantTerm = 0

In programming languages, “terseness”, and “eliminating boilerplate” are also considered good properties to have.

Consider C++:



std::vector<BarType> ret(foo.size());
std::transform(foo.begin(), foo.end(), ret.begin(), 
    [](const FooType& foo_element) { 
        return GetBar(foo_element);
    });


vs same in Scala:



val ret = foo.map(GetBar)


The latter is more readable in no small part simply because it cuts out the information that isn’t relevant at that moment. Math’s terseness is the same principle.

I think this is the real problem, not single-letter names.
If there was a convention that every equation has a clear table next to it explaining all the variables, there wouldn’t be a problem.

I think with academic papers, there’s something of a cultural factor IMO that everyone wants to be taken seriously and a paper needs to take some time to “solve”.
(just my impression as a non-mathematician but who occasionally has to digest math / physics / comp sci papers)

One thing to think about: nowadays, most mathematicians also need to write code. When they do so, do they use meaningful variable names?

That didn’t bother the chess authorities at all. A few years ago they were perfectly happy to replace “descriptive notation”, in use for hundreds of years and with thousands of books written using it), with an abortion called “algebraic notation”, seemingly because they wanted change for change’s sake.

And I could see no improvement in either clarity or convenience.

Most mathematicians nowadays do not “need to write code” (why would they?), though many can and do. It’s not like a computer program where there may be dozens of variables (one hopes), and the goal is to be clear while avoiding excessive subscripts and superscripts. A mathematical article may have mind-blowing identifications like, “Let p be a prime number…”, “Let X be a scheme… Pic(X) the Picard group of X…”, “Let G be a group and H a normal subgroup”, etc. And you want some sort of notation: for instance, you don’t want to write out “square root of x” in full each time it appears, or “equal” instead of “=” all the time.

For an excellent sample of mathematical notation before and after it has been cleaned up, see the notes on “Mathematical Writing” by Knuth et al. There should be a free web version floating around somewhere, as well as videos of the classes.

I’m willing to be convinced. Show me a bit of published mathematics and then show me how much clearer it is written the way you think it should be.

It doesn’t even have to be published. Rewrite this post with descriptive variable names. If it is notably clearer then I’ll jump on your bandwagon.

Isn’t the simplest way to tell if a mathematical formulation is wrong is to note that it’s written in words instead of math?

Well, it can’t all be Principia Mathematica.

I would venture to say that in most math papers where you’re complaining that you don’t know what the variables are, this is probably the least of your challenges. The biggest challenge would be understanding the concept and context. Once you get that far, then comprehending the variables becomes a non-issue.

There are certain computing trends that prioritize English readability over programmatic terseness. IMO this has been a disease to the programming community in recent years (Ruby/Rails, looking at you). My response to the OP is the same.

  1. Are you sure… absolutely certain that you picked the best idiom for your fancy English-readable code?
  2. Have you thought through how much behind-the-scenes context needs to be established to make your idioms work? Are you prepared to maintain that?
  3. What are non-English speakers supposed to do? Go pound sand? How about people who speak English, but a slightly different version than you?
  4. Of the thousands of programming languages in existence, which one would you believe solves your problem the best?

This seems a solution in search of a problem to me.

Often, in math, descriptive variable names are impossible, because the variables aren’t describing anything in particular. Maybe there are a thousand different real-world situations that equation could be describing. Maybe nobody’s ever found any real-world situation that would be described by that equation. Maybe there are exactly two known real-world situations described by that math. The only time that descriptive names would really make sense would be when there’s exactly one real-world situation described by a particular bit of math, and that’s quite rare.

Hard to take a suggestion seriously from someone who makes such glaring errors.

In mathematics texts the length of a book (like, for example, a textbook) there is sometimes an index of notation in the back next to the subject index, so if you are trying to remember what X[sup]+[/sup] represented, versus X[sup]++[/sup] , four chapters before, it’s quick enough to find out.

Computer programs need descriptive variable names because computer programs have a much higher likelihood to be need to be read by people who don’t already understand what it is they do. If you don’t understand a math paper because you don’t understand what the variable names mean, it’s highly unlikely that you’ve studied the subject enough to understand the concepts; only if people use intentionally obtuse variable names, or conventions differ between academic groups, does it become a problem that the target audience is unable to read and comprehend a paper because of bad variable names.

Why do computer programs need to be understood by people who don’t already understand them? Because they are actually used in the production of things, and may be embedded in mission-critical applications for much longer than the original programmers will be with the company. Mathematics papers are just academic papers. I’m fairly sure that if one looks at a CS academic paper, they use basically the same sort of variable naming as in Mathematics. It’s only on production programming that the descriptive variable names get used.

The topic of variable names reminds me of watching some lectures on quantum mechanics where an equation central to the theory had an “m” as the mass of the particle in question, and later in the development of angular momentum they use “m” to stand for the magnitude of one component of angular momentum and then go on to say how “only this part of the equation depends on m” when the other part of the equation clearly has an m in it as well. However, no one even bats an eye at this, because everyone knows the first m appears in one specific place and isn’t used elsewhere, and anyone studying it for long enough would never be confused because it wouldn’t make any sense for those two m’s to stand for the same thing. Similar things go on with the base of the natural logarithms and the charge of the electron both being written “e”; everyone knows which “e” is which because of the role it plays in the equation. You have no reason to ever put a complex (as in, not a member of the real numbers) variable in the exponent of the charge of the electrion. It should be at most a 2 or some higher integer or an expression that clearly resolves to an integer. If the exponent is complex, it’s obvious that the e is the standard base for exponentials. Similar, any e where there is nothing in the exponent is clearly not the base of natural logarithms; while occasionally in math it might come out of an integral or something, that’s not going to be the case in physics. Only people totally clueless about the subject would think they would be standing for the same thing.

That’s all fair enough, but I don’t think we can really condone as good style notation in which identical symbols, or ones not easily distinguishable, stand for different things. Surely that is avoidable.

In addition to all of the other reasons, computer programs need multi-character variable names, because source code generally uses only a small number of characters – in ancient times because only ASCII text files were supported, but even with modern compilers that can use unicode source files, those files tend to be typed on keyboards upon which typing ASCII characters is much easier than any other type.

Mathematics has a long tradition of using characters from multiple alphabets and multiple typefaces to encode the same kind of meaning that longer variable names are used for in programming.

  1. There is an entire class of people who, by definition, don’t know the concepts: Students.
  2. Mathematician creates paper. Engineer implements formula. Engineer sad. As said, there is a thing as non-pure mathematics. I don’t know for sure, but I suspect that the grand majority of math is done professionally for purposes of real world application. I’ve personally implemented the RSA algorithm, both the encoding portion and they key generation portion (including prime tests). Similarly, I have implemented a bunch of 3D math (quaternion multiplication, etc.) and some regression analysis. All of those required reading and trying to establish basic things like “what the hell is the meaning of this stupid variable”? Turning a formula into code should be, in essence, a 1:1 conversion. If you’re going to use to use the gamma function, being able to load your “paper” into an IDE and having it take me into a library for complex numbers when I right click the Γ would be horribly useful, in terms of identifying what I am looking at. If I just see the Γ, I have no idea if it’s a thing that this person has declared or is a mathematical standard. If the latter, is it a Greek character or Hebrew or what? The time spent tracking down the formula makes a person lose track and forget what the original topic was or how this fit in at all. If a math paper could be written in something like an IDE this would be immensely useful for the practical usage of the output of mathematicians. And, I do suspect, it would be useful for mathematicians as well since, as said, plain English is not a particularly good medium.
  3. Mathematics is almost certainly growing at a compounding rate. Consequently, it’s breaking into subfields and those subfields are certainly going to be as obtuse to those outside of it as math is to the general public. And yet, the product of every field is liable to be useful to every other field. Programs build on libraries and must explicitly include those libraries, otherwise they are carte blanche. As said above, with the gamma function, it would be in a library. For a mathematician, looking at some math in another field, he’s going to have the same issues as an engineer. He may think that this paper has relevance to what he’s doing, but that doesn’t mean that he wants to learn the entirety of a new field of mathematics. For his purposes, he wants to know what he needs to know, minimally, and if he could simply look at which items from which are imports are used, he can investigate that limited subsection of the field before proceeding to try and read the paper.

The assumption that everyone is an expert and that only experts would want to know things is not a good one. It’s certainly not the right technique to bring others in nor to share with others.

Mathematics isn’t purely a hobby. It is also and principally for real human use.