I've never thought of this issue until recently when I've been using Haskell to build a substantial project. In Haskell (and functional programming languages in general), most so-called "variables" are actually mathematical variables, which seem to be immutable by definition.

This made me quite confused. "Variables" in imperative programming languages make perfect sense because they indeed are mutated often. However, such a denomination seems very weird when the thing it represents is actually invariable.

Since the word "variable" originated from mathematics and has been in use for several decades, I'm curious how such an apparent self-contradiction came into existence in the beginning. Did people have a different idea in mind when they first invented the word, and it evolved over time to its current meaning? Was immutability not an important concern at that time such that it was overlooked? Or did I just get it wrong and "variables" in mathematics are actually not totally immutable after all?

  • 4
    $\begingroup$ It'd help if you give an example of the "immutable variable" you are speaking of, now I can't think of any. $\endgroup$ – BigbearZzz Oct 11 '15 at 9:35
  • 2
    $\begingroup$ Perhaps there is some confusion between "variable" and "indeterminate"? We construct (for example) a ring of polynomials $R[X]$ where $X$ is an indeterminate, and we may define "evaluation homomorphisms" $f_a: R[X] \to R$ which assign a value $X := a$. In this sense $X$ is a "variable" which can be assign varying values, but a priori it has no value, it is merely a symbol. $\endgroup$ – hardmath Oct 11 '15 at 9:48
  • $\begingroup$ @BigbearZzz If a variable is a mathematical symbol that denotes a mathematical object, then I can't say it denoted object A a while ago, but now is mutated to denote another object B. This is what being "immutable" means. $\endgroup$ – xji Oct 12 '15 at 18:04
  • $\begingroup$ If by "immutable variable" you mean something like $\pi$ or $\sqrt 2$, then you're mistaken: It is in fact not conventional to call those "variables". ${}\qquad{}$ $\endgroup$ – Michael Hardy Dec 22 '15 at 2:28

For a good (and extremely accessible) overview of the various roles of "variables" in mathematics, see Conceptions of School Algebra and Uses of Variables by Zalman Usiskin. The introduction lays out the terrain quite well:

Consider these equations, all of which have the same form —- the product of two numbers equals a third:

  1. $A=LW$
  2. $40=5x$
  3. $\sin x=\cos x \cdot \tan x$
  4. $1=n \cdot (1/n)$
  5. $y=kx$

Each of these has a different feel. We usually call (1) a formula, (2) an equation (or open sentence) to solve, (3) an identity, (4) a property, and (5) an equation of a function of direct variation (not to be solved). These different names reflect different uses to which the idea of variable is put. In (1), $A$, $L$, and $W$ stand for the quantities area, length, and width and have the feel of knowns. In (2), we tend to think of $x$ as unknown. In (3), $x$ is an argument of a function. Equation (4), unlike the others, generalizes an arithmetic pattern, and $n$ identifies an instance of the pattern. In (5), $x$ is again an argument of a function, $y$ the value, and $k$ a constant (or parameter, depending on how it is used). Only with (5) is there the feel of “variability,” from which the term variable arose. Even so, no such feel is present if we think of that equation as representing the line with slope $k$ containing the origin.

Conceptions of variable change over time. In a text of the 1950s (Hart 1951a), the word variable is not mentioned until the discussion of systems (p. 168), and then it is described as “a changing number.” The introduction of what we today call variables comes much earlier (p. 11), through formulas, with these cryptic statements: “In each formula, the letters represent numbers. Use of letters to represent numbers is a principal characteristic of algebra” (Hart’s italics). In the second book in that series (Hart 1951b), there is a more formal definition of variable (p. 91): “A variable is a literal number that may have two or more values during a particular discussion.”

Modern texts in the late part of that decade had a different conception, represented by this quote from May and Van Engen (1959) as part of a careful analysis of this term:

Roughly speaking, a variable is a symbol for which one substitutes names for some objects, usually a number in algebra. A variable is always associated with a set of objects whose names can be substituted for it. These objects are called values of the variable. (p. 70)

Today the tendency is to avoid the “name object” distinction and to think of a variable simply as a symbol for which things (most accurately, things from a particular replacement set) can be substituted.

The “symbol for an element of a replacement set” conception of variable seems so natural today that it is seldom questioned. However, it is not the only view possible for variables. In the early part of this century, the formalist school of mathematics considered variables and all other mathematics symbols merely as marks on paper related to each other by assumed or derived properties that are also marks on paper (Kramer 1981).

I will resist the temptation to quote additional large chunks of the Usisikin's text, but the rest of the paper does an exemplary job of distinguishing among the different conceptions of "variable" in mathematics, and how those conceptions relate to different conceptions of what "algebra" is.

  • $\begingroup$ A programming variable is not the same thing as a mathematical variable. Which do you mean, Or are you complaining that they don't mean the same thing? $\endgroup$ – steven gregory Sep 9 '17 at 0:43

A variable in mathematics is a symbol, rather than something (e.g., a number) which is denoted or by such symbol. There are no "variable numbers".

From : Bertrand Russell, Introduction to Mathematical Philosophy (1919), page 155-56 :

We mean by a “proposition” primarily a form of words which expresses what is either true or false. [...] Thus “two and two are four” and “two and two are five” will be propositions, and so will “Socrates is a man” and “Socrates is not a man.”

The statement: “Whatever numbers $a$ and $b$ may be, $(a + b)^2 = a^2 + 2ab + b^2$” is a proposition; but the bare formula “$(a + b)^2 = a^2 + 2ab + b^2$” alone is not, since it asserts nothing definite unless we are further told, or led to suppose, that $a$ and $b$ are to have all possible values, or are to have such-and-such values. The former of these is tacitly assumed, as a rule, in the enunciation of mathematical formulæ, which thus become propositions; but if no such assumption were made, they would be “propositional functions.”

A “propositional function,” in fact, is an expression [emphasis added] containing one or more undetermined constituents [the variables], such that, when values are assigned to these constituents, the expression becomes a proposition. In other words, it is a function whose values are propositions. [...] Examples of propositional functions are easy to give: “$x$ is human” is a propositional function; so long as $x$ remains undetermined, it is neither true nor false, but when a value is assigned to $x$ it becomes a true or false proposition. Any mathematical equation is a propositional function. So long as the variables have no definite value, the equation is merely an expression awaiting determination in order to become a true or false proposition. If it is an equation containing one variable, it becomes true when the variable is made equal to a root of the equation, otherwise it becomes false; but if it is an “identity” it will be true when the variable is any number.

Expressions of traditional logic such as “all $A$ is $B$” are propositional functions: $A$ and $B$ have to be determined as definite classes before such expressions become true or false.

  • $\begingroup$ I know it's a symbol. My question is why then is it called "variable". So it seems that the point is that it can be assigned different values. Before being assigned, it doesn't represent any value, and it's "variable" in this sense; however, after it's assigned, the value it represents should be definite and it's not really "variable" anymore. Is this interpretation correct? $\endgroup$ – xji Oct 12 '15 at 18:03
  • 1
    $\begingroup$ @XiangJi - it is called "variable" basically for historical reason... It works like a pronoun in natural language; if I utter "It is red" pointing at my red pen on the table, it means something different if you utter "It is red" pointing at your black shirt. The variable has a denotation in a "context; in formal languages, the context is an interpretation of the formula with variables (see math log textbooks). $\endgroup$ – Mauro ALLEGRANZA Oct 13 '15 at 6:16

Consider an equation such as $y = 3x + 5$. You can put in various values for $x$ and get from the equation various values for $y$. These symbols are able to represent various values. The English word "variable" derives from the Latin words meaning "various" and "able".


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.