Why is variable called "variable" in mathematics if in fact it's immutable? 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?
 A: 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:
  
  
*
  
*$A=LW$
  
*$40=5x$
  
*$\sin x=\cos x \cdot \tan x$
  
*$1=n \cdot (1/n)$
  
*$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.
A: 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.

A: 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".
