Tac-Tics
- 816
- 7
AUMathTutor said:In mathematics, ..., I don't think there's much of a difference between the idea of "variable" and "constant".
Variables in mathematics never vary.
Terminology is loose in both fields, but in both mathematics and computer science, there is a pretty simple definition if you're working with a wide number of variable-having systems. The rules come from lambda calculus, but easily generalize to propositional logic, algebra, and set theory.
First, variables cannot exist in a vacuum. They must always be created by a special thing called a binding form (whose name I stole from Lisp). A binding form provides three things for the variable: its name, its scope, and its purpose.
Names of variables can be pretty much anything: x, y, z, the greek letters, or full identifiers like "sin" or "cosh". They are names and nothing more.
The scope of a variable is the expression in which the variable even exists. For example, in the expression 50n + \Sigma_k^5 k^2, the variable k is created by the binding form \Sigma. It only exists inside the expression k^2. To say something like k + \Sigma_k^5 k^2 is nonsense, because k simply doesn't exist outside of the sigma which creates it.
The purpose of a variable depends on the type of binding form. I list a bunch of these in another post I link to below. But they include definition, function abstraction (the lambda of lambda calculus), universal and existential quantification, summations and integrals (the "dummy" variables of both), and a few others.
Consider the expression "x^2 + 1". What is x? We don't know. We can't actually see the binding form of x in the expression we are considering, we say that it is unbounded (relative to that expression).
It might be a simple number like 2. It might be a function parameter, such as in "f(x) = x^2 + 1". It might be a dummy parameter in an integral, such as \int x^2 + 1 dx. If we can see the binding form in the expression, we say that x is bounded (relative to the expression in question).
The boundedness of variables isn't so important in mathematics, but it is absolutely critical to know for doing functional programming in computer science. The interesting thing is that there is a direct correspondence between constants in mathematics and unbounded variables in computer science. An unbounded variable IS a constant.
One implication of this is that "constantness" of a variable depends on which expression you're looking at. "Pi" by itself isn't a constant. It's not 3.14 inherently in the fabric of space and time. You have to wait until the author says "let pi be the ratio of a circumference of a circle to its diameter" and only then does pi take on a meaning. And author could just as easily say "let pi be the function which maps ordered pairs to their first coordinate" or "let pi be the function which maps integers to the count of lesser primes".
Another application is a function of two parameters, such as in multivariable calculus, which undergoes "partial" application. That is, you have a function f(x, y), and a real number c. You can create a new function g_c(x) which is equal to f(x, c). In a sense, this is a way to turn parameters into constants. Not literally, of course, but you do substitute y, which is bounded by the definition of f with another variable c, which is bounded "farther out" by "let c be a real number".
See another post explaining this in a little more detail here:
at https://www.physicsforums.com/showthread.php?t=258803
Of course, when talking about infinities, you have to keep in mind that infinity is a name we give to many things. A few of them aren't even mathematical objects. Aleph null and the cardinality of the continuum would be constant values. The infinity in "lim x->infinity" isn't really...