Difference between functions and variables

In summary, the conversation discusses the distinction between a function and a variable, particularly in the context of physics. It is noted that there is often abuse of notation in which the variable is treated as a function, but it is more mathematically correct to have a function and evaluate it at a specific value. The conversation also touches on the importance of keeping track of which is which, and notes that the concept applies to both single and multi-variable functions.
  • #1
etotheipi
This is probably a silly question, though it's confused me a little so I thought I'd ask. It is my understanding that a function is loosely defined as a mapping between two sets, whilst a variable can represent an element of either of those sets. I'll take the example of velocity, since it's often stated that velocity is a function of time. To me it seems that velocity and time are two variables, and they are related by some arbitrary function ##f## so that ##v = f(t)## which maps between them. I'm then a little confused as to why we say ##v## is a function, since it appears ##f## is the function and ##v## is just the output. Also, derivatives are defined for functions, so why does it make sense to say ##\frac{dv}{dt}##?

I wonder whether it's the case that for a definition like ##v=f(t)##, that makes ##v## a function as well? Or whether it's a bit of an abuse of notation as to why we can treat ##v## as a function and ignore ##f##.

It's a bit like if we're drawing graphs and we get something like ##z = x + y##, and we might say ##z## is a function of ##x## and ##y##, but we could also move everything to the LHS and define ##F(x,y,z) = z-x-y##, and now ##F## is a function. The two usages appear to be quite different.

I wondered whether anyone could clear some of this up, thank you!
 
Mathematics news on Phys.org
  • #2
It's just abuse of notation all over the place. To be strictly correct, one should say ##f## is a function and ##f(x)## is the function ##f## evaluated in ##x##.

At many places, one writes something like "Let ##f(x)## be a function ..." which is abuse of notation. The variable has mathematically no meaning and can be replaced by anything. From a physics point of view, it makes more sense to include the variable.
 
  • Like
  • Informative
Likes HallsofIvy, Stephen Tashi and etotheipi
  • #3
Math_QED said:
It's just abuse of notation all over the place. To be strictly correct, one should say ##f## is a function and ##f(x)## is the function ##f## evaluated in ##x##.

At many places, one writes something like "Let ##f(x)## be a function ..." which is abuse of notation. The variable has mathematically no meaning and can be replaced by anything. From a physics point of view, it makes more sense to include the parameter.

Thanks, that's reassuring. I suppose then we should really first be saying ##v = f(t)## and then ##a = \frac{df}{dt} = f'(t)## instead of something like ##a=\frac{dv}{dt}##, though the first is much more difficult to interpret so we just use ##v## anyway.

I guess it's a useful simplification so long as you know what is actually implied!
 
  • #4
In mathematical terms, we have relations and functions, where a function is a relation where there is a unique output (the range) for every input (the domain).

In physics, things are generally related to each other and in many cases you can express one thing as a function of another.

In classical physics, time is a parameter in the sense that physically time is running as an uncontrollable parameter and you can organise things so that an electric field at a certain point is a function of time. And then everything is essentially a function of time.

In terms of notation it's sometimes useful to write ##v = f(t)##, rather than more simply ##v(t)##. The later is almost universal in physics texts.
 
  • Like
Likes Lnewqban and etotheipi
  • #5
PeroK said:
In terms of notation it's sometimes useful to write ##v = f(t)##, rather than more simply ##v(t)##. The latter is almost universal in physics texts.

Yeah, this is where most of the confusion is coming from. All of the books I'm referencing are littered with ##z(x,y)##'s and ##v(t)##'s and what not and it's difficult (for me at least...) to try and unblur the lines. It doesn't really cause any problems normally but I tried to get started with some of that vector calculus stuff and it's seems a little more important to keep track of which is which.

Luckily it appears to be quite an easy fix, just translate ##a(b) \rightarrow a = f(b)##.
 
  • #6
etotheipi said:
Yeah, this is where most of the confusion is coming from. All of the books I'm referencing are littered with ##z(x,y)##'s and ##v(t)##'s and what not and it's difficult (for me at least...) to try and unblur the lines. It doesn't really cause any problems normally but I tried to get started with some of that vector calculus stuff and it's seems a little more important to keep track of which is which.

Luckily it appears to be quite an easy fix, just translate ##a(b) \rightarrow a = f(b)##.
You might find my insight on the chain rule useful:

https://www.physicsforums.com/insights/demystifying-chain-rule-calculus/
 
  • Love
  • Like
Likes Lnewqban and etotheipi
  • #7
v is a function mapping a real value to a real value (ignoring units here) and v(t) is the velocity at a given time t. No need to introduce some f.
 
  • Informative
Likes etotheipi
  • #8
mfb said:
v is a function mapping a real value to a real value (ignoring units here) and v(t) is the velocity at a given time t. No need to introduce some f.

That would also make sense, but then it would be incorrect to say something like ##\vec{v} = 3\hat{x} + 2\hat{y} + 8\hat{z}## without adding the time at which the function is evaluated.

And if I wrote an equation like ##\vec{F} = m\vec{a}##, would it still make sense that ##\vec{a}## is a function?
 
  • #9
If ##\hat x##, ##\hat y##, ##\hat z## are constant then v is just constant: It has the same value for each t. If they are functions of time then this is just adding functions.
etotheipi said:
And if I wrote an equation like ##\vec{F} = m\vec{a}##, would it still make sense that ##\vec{a}## is a function?
Same concept, F and a can be functions of time. m can be, too.
 
  • Like
Likes etotheipi
  • #10
etotheipi said:
And if I wrote an equation like ##\vec{F} = m\vec{a}##, would it still make sense that ##\vec{a}## is a function?

Newton's second law must be ##\vec F(t) = m\vec a(t)##. It's not only valid for constant force.

You need to be careful about making the mass a function of time. There are occasional debates on here about this. In Newtonian physics, mass cannot be created or destroyed. The only way mass can change is if particles are entering or leaving the system. As long as you are careful to account for where the mass is going to or coming from you can't go wrong.

Especially important in this regard are the two forms of the second law. The one above and:
$$\vec F(t) = \frac{d\vec p(t)}{dt} = \frac{d}{dt}(m(t) \vec v(t)) = m(t) \vec a(t) + \dot m(t) \vec v(t)$$
And, we have a discrepancy between this and ##\vec F(t) = m(t) \vec a(t)##.

There is no problem if ##m## is constant. But, if you let ##m## be a function of time you must be very careful to think about how the mass is changing.
 
  • Informative
  • Like
Likes hutchphd and etotheipi
  • #11
PeroK said:
Especially important in this regard are the two forms of the second law. The one above and:
$$\vec F(t) = \frac{d\vec p(t)}{dt} = \frac{d}{dt}(m(t) \vec v(t)) = m(t) \vec a(t) + \dot m(t) \vec v(t)$$
And, we have a discrepancy between this and ##\vec F(t) = m(t) \vec a(t)##.

There is no problem if ##m## is constant. But, if you let ##m## be a function of time you must be very careful to think about how the mass is changing.

I remember reading about this a while back, and I seem to remember that Wikipedia says Newton II isn't valid for variable mass systems, i.e. ##F = m\frac{dv}{dt} + v\frac{dm}{dt}## isn't a useful construction. There is also the issue, if you use this construction, of what part of the system do you apply NII to, if bits are leaving?

As far as I can remember, if mass is entering or leaving the system you have to instead do a momentum balance for the whole system (i.e. the classic example of a rocket ejecting fuel), and you can derive a similar expression which is

##F + v_{rel}\frac{dm}{dt} = m\frac{dv}{dt}##

Which is of course identical if the mass is constant. Except now you've properly accounted for the external forces and variable mass of parts within the system.

One example was considering you have a minecart full of sand, with a hole punctured in the lower face so that the sand would fall out with the same horizontal velocity of the minecart. Since the external force on the minecart is zero, and ##\frac{dm}{dt} < 0##, you'd expect the minecart to accelerate (i.e. ##\frac{dv}{dt} > 0##) if you use the first construction, which must be wrong since the sand does no work on the cart! But if you use the second construction, ##v_{rel}## and ##F## are zero so you get no acceleration, as expected.

The first construction does I think work in some cases, though I'm hesitant to use it since it appears to be wrong for many variable mass systems.
 
  • Like
Likes PeroK
  • #12
etotheipi said:
Luckily it appears to be quite an easy fix, just translate ##a(b) \rightarrow a = f(b)##.

It won't be that easy! In physics one tends to think of symbols like "v" as representing physical phenomena. A particular physical phenomenon such as velocity may be a function of different things in different contexts. For example, the velocity of a falling object might be a function of time, but if its position depends on time, then the velocity can also be a function of distance. The function represented by a variable that stands for a physical phenomenon is often ambiguous.

For eample if ## w = f(s,y) = s + y ## and ## s = x^2 + y##, what function is ##w## and what function does ##\frac{\partial f}{\partial x}## denote?

Does the name ##w## denote the function ##A(p,q) = p + q## or does it denote the function ##B(p,q) = ( p^2 + q) + q##? And is ##\frac{\partial w}{\partial x}## a notation for ##\frac{\partial A}{\partial p}## or is it a name for ##\frac{\partial B}{\partial p}##?

Often in physics books, I find that ##\frac{\partial w}{\partial x}## refers to the function ##\frac{\partial A}{\partial p}## even though the variable ##x## is not used as a place holder in defining ##w## as the function ##f##.
 
Last edited:
  • Like
Likes etotheipi
  • #13
Stephen Tashi said:
For eample if ## w = f(s,y) = s + y ## and ## s = x^2 + y##, what function is ##w## and what function does ##\frac{\partial f}{\partial x}## denote?

Does the name ##w## denote the function ##A(p,q) = p + q## or does it denote the function ##B(p,q) = ( p^2 + q) + q##? And is ##\frac{\partial w}{\partial x}## a notation for ##\frac{\partial A}{\partial p}## or is it a name for ##\frac{\partial B}{\partial p}##?

Often in physics books, I find that ##\frac{\partial w}{\partial x}## refers to the function ##\frac{\partial A}{\partial p}## even though the variable ##x## is not used as a place holder in defining ##w## as the function ##f##.

I had to read that a few times over, though why wouldn't ##\frac{\partial w}{\partial x}## refer to ##\frac{\partial B}{\partial p}##, that seems the best option? Is it because of how we initially defined the parameters of ##f##?
 
  • #14
etotheipi said:
I had to read that a few times over, though why wouldn't ##\frac{\partial w}{\partial x}## refer to ##\frac{\partial B}{\partial p}##, that seems the best option?

To me, ##\frac{\partial B}{\partial p}## would be the best option, but physics texts don't obey.

Expositions of the Calculus of Variations are another example. In the Wikipedia version https://en.wikipedia.org/wiki/Calculus_of_variations we have a function named ##L## defined as ##L(x,y(x),y'(x))## . Although we could think of ##L## as a function of ##x## alone, the text mentions ##L## being differentiable with respect to ##x##, ##y## and ##y'##. So apparently ##\frac{\partial L}{\partial y'}## considers ##L## as a function of 3 independent arguments and denotes the partial derivative of that function with respect to the third argument.
 
  • Like
Likes etotheipi

1. What is the difference between functions and variables?

Functions and variables are both important concepts in programming, but they serve different purposes. A variable is a placeholder that stores a value, while a function is a set of instructions that can be called upon to perform a specific task.

2. How are functions and variables declared?

Variables are declared by using the keyword "var" followed by the variable name and an assignment operator (=) to assign a value. Functions are declared using the keyword "function" followed by the function name and a set of parentheses containing any necessary parameters.

3. Can a variable be used as a function?

No, a variable cannot be used as a function. While a variable can store a function as its value, it cannot be called upon to perform a task like a function can.

4. What is the difference between local and global variables?

Local variables are declared within a function and can only be accessed within that function. Global variables, on the other hand, are declared outside of a function and can be accessed from anywhere in the code. It is generally considered good practice to limit the use of global variables in order to avoid potential conflicts.

5. How are functions and variables used in programming?

Functions and variables are essential building blocks in programming. Variables are used to store data and keep track of changing values, while functions are used to perform specific tasks and make the code more organized and efficient. By using functions and variables, programmers can create complex and dynamic programs.

Similar threads

Replies
17
Views
2K
  • General Math
Replies
2
Views
722
Replies
3
Views
704
Replies
6
Views
848
  • General Math
Replies
12
Views
1K
Replies
2
Views
746
Replies
1
Views
832
  • General Math
Replies
7
Views
770
Replies
4
Views
409
Replies
2
Views
247
Back
Top