Bridging the gap of understanding function terminology in math for a programmer.

191 Views Asked by At

I'm a computer programmer by profession with no formal CS education. When I read in mathematics the terminology used around a function, I get confused. For example, I was reading up on some calc and read this: As a function of time. Or the following statement: "In science, engineering, technology, finance, and other areas, graphs are tools used for many purposes. In the simplest case one variable is plotted as a function of another, typically using rectangular axes"

What does this example As a function of time actually mean for a programmer? Is t the parameter of a method? What would be the return value? Any simple examples to bridge this gap of confusion.

2

There are 2 best solutions below

0
On

If you go in your car and move at a speed of $60$ mph then you can express the distance you travel "as a function of time". Written in mathematical terms $f(t)=60 \cdot t.$ So, $f(0)=0,$ which means in $0$ hours you move $0$ miles; $f(2)=120,$ which means in $2$ hours you move $120$ miles.

1
On

For a programmer, a "function of time" would be a method where the parameter is time and every time the method is run with a specific value of time the same value is returned every single time. There will usually be no other parameters if the function is only a function of time. For example:

 double Velocity(double time){
      return 10*time;
 }

Would be considered a function of time. This can be thought of a function that represents the velocity of an object where the object is at rest when time = 0 and then accelerates.

In mathematics, time is generally represented with a t and the function is usually f or other letter. For example, we could write:

 double f(double t){
      return t*t+2*t-10;
 }

This would represent a function of time such that $f(t) = t^2 + 2t - 10$.

For an example of something that is not a function of t:

 double notAFunction(double time){
      return t*rand();
 }

This is not a mathematical function of time because if you wrote the expression notAFunction(1) == notAFunction(1) it would almost always be false. This contradicts the criteria in my first sentence.

Another odd example of a (valid) function of time would be

 int returnTen(double time){
      return 10;
 }

This satisfies every one of the criteria even though no matter what value you use you have that returnTen(t) == 10. This would represent a constant function $f(t) = 10$.