The idea of “variable” is widely used in maths, but in most maths education never really explained. And it’s quite tricky. If you want to explore it more, look at:
The way I’ve explained it to year 8 and 9 students is that a variable is what’s inside a container covering a number (or other mathematical entity) chosen from a particular set, but you may not know which one. For example, a real variable is a container with some real number or other in it. I have coloured paper beakers placed on a desk (upside down, so no-one can see what’s inside) to display this idea, with the convention that two beakers the same colour are the same container appearing twice in the mathematical statement.
Since we want to be able to do maths with pencil and paper, without colours, we use letters instead of coloured beakers: “x” means “the number [or whatever] under the cover marked x”.
Sometimes (as in the picture above) you have enough info to find out what is inside the containers. Sometimes (as e.g. if you had only the first row in the picture above) you have info about what is in the containers, but not enough to pin it down exactly.
What we call a “constant” in maths is often a variable, only one which has the same value (same number or thing inside) over a range of statements. We may even know what the value is, but just find it shorter to refer to it as “the number in the lime-green container” (it may be easier to write N, when we’re doing physical chemistry, for Avogadro’s number, rather than 6.02214076×1023).
In s = ½gt2, usually “g” is just short for “9.81 in SI units”. We know what is in the container. If we consider the same equation across a range of planets, then g is a “variable” variable. But for calculations on any one planet, it is a “constant” variable.
If we consider F = ma for a range of forces F but the same mass m, then m is a “constant” (though we may not know exactly what it is). If we consider the same equation for the same F but a range of masses m, then F is the “constant” and m and a are the variables (you might even say, the variable “variables”).
We also have dummy variables, i.e. variables which do all their varying backstage from the statement they appear in.
In , “r” is a container for which we are told: put 1 in it, take a running total, then put 2 in it, recalculate the running total, put 3 in it, recalculate… put 10 in it, recalculate. Once you’ve finished the calculation, you’re done with using that “container”, and it didn’t matter whether it was yellow, turquoise, orange, whatever. The contents of the container vary all right, but only within the sum calculation.
In an equation like , r has already done all its varying within the sum calculation, so it’s backstage in the context of the actual equation, which is an equation giving you info about what’s in the container called “n”.
Likewise the dummy variable x in .
Notice you can change the name of the dummy variable and it makes no difference to the sum or integral or whatever. If you add the ages of the students in a class, and do it by adding one after another in alphabetical order of first name, it makes no difference whether you call the counter “first name”, “given name”, “prénom”, “Vorname”, or whatever.
, , , whatever, are all the same, all equal to 55. , , etc., are all the same, all equal to ½.
A random variable in statistics is really a function, not a variable in the sense above.