3 ms·
Yeah, I noticed a thing students in math class would get confused is the difference between local and global variables. So I'd ask people if we're discussing fu
by bikenaga 3y ago
Yeah, I noticed a thing students in math class would get confused is the difference between local and global variables. So I'd ask people if we're discussing functions from the reals to the reals, are these the same function?
f(x) = x^2 vs. f(t) = t^2
They are, because they produce the same set of ordered pairs (input, output).
Some of the confusion is the fault of math profs, because we get lazy. We could say "the function f: R -> R defined by f(x) = x^2", but we wind up saying "the function f(x)" (wrong - f is the function, f(x) is the value when x is plugged in) or worse "the function x^2" (really wrong). But if you always say the absolutely correct thing "the function f: R -> R defined by f(x) = x^2" you sound really pedantic, and the extra words make it hard for students to comprehend. Oh well.
What was more confusing to people was if you had f(t) = t^2 and people thought "t" had some sort of independent existence outside the definition of f. Some guy was asking me about it and I was trying various explanations and he wasn't getting it. Then I remembered he was a CS major and I said "t is an argument to f and it's local to the function block" and he got it and nodded his head.
So I wonder if these kinds of distinctions are easier for programmers than for typical math students - in the sense that programmers would know there's no difference between these:
int f(int x)
{
return x * x;
}
int f(int t)
{
return t * t;
}
- BruceEel 3y agoBrilliant. Love the programming analogy. I like that the above works particularly well in C as: int f(int x); int f(int t); will compile with no errors, while changing t to, f.i., "float" obviously won't. I wonder whether this could be pushed farther to come up with programmer-friendly descriptions of things like the chain rule starting from something like: int h(int x) { return f(g(x)); } etc.