Comment by OpenPlex on 26/06/2024 at 19:12 UTC

2 upvotes, 4 direct replies (showing 4)

View submission: Ask Anything Wednesday - Engineering, Mathematics, Computer Science

What is a function?

My mind immediately visualizes a function as any mathematical expression, for example 1 + 1 or 2 × 2, but then the explanations on Wikipedia seem far more complicated and like you need to first learn many prerequisites before you could hope to understand what a function is.

Does an intuitive explanation exist?

Replies

Comment by functor7 at 27/06/2024 at 18:12 UTC

4 upvotes, 1 direct replies

A function is something that pops stuff out based off of what you put in it. Importantly, if you put the same thing in twice then it will pop out the same result. This is rigorously defined on wikipedia, but that's the main idea. A machine that reliably produces outputs based on inputs.

So, for example, there is "Add One" function. If you feed it any number, the output number will be one plus the input number. So if you input 5 it will output 6. If you input -0.5 it will output 0.5. That's a function.

There is a difference between a function and an expression. An expression is like a sentence fragment in English, but for math: It is a collection of mathematical symbols that are arranged according to the syntactic rules of math. So, for instance, we could have the expression 1+1 or 2+2 or x+1. These don't say anything, they just are. It's like saying "The red dog" or "Bananas" - theses are expressions that fit the rules of English but have no meaning because they are incomplete. So "1+1" is a correctly arranged collection of math symbols, but it doesn't have anything to say. Importantly, these are not rules or anything, just correct arrangements of math symbols. These are not functions.

An *equation* is like a full mathematical sentence. Importantly, it has a verb: The equals sign. The equals sign is one of the few verbs that math has and it is the verb "is". It is NOT the symbol for "this is the answer" and, in fact, many college students do not do well in college math specifically because they don't understand that "=" means "is" and they think it means "answer" because that's what it means on their calculators. Just as I can say "The red dog is big", I can create a complete mathematical sentence with math's verb: "1+1 = 2". That is a sentence that says something. It says that 1+1 *is* 2. I can make other sentences as well "1+1 =3" and "1+1= 6-4", one of these is a *false* sentence and the other is true. A sentence being false does not mean it is not a sentence, and an equation being false does not mean it is not an equation. And finally, I can make the sentence "x+1 = 7". This sentence can be true or false, depending on what x is. If I assert that "x+1=7" is true, then it must be that "x=6" is true. But if x=3 then "x+1=7" is just false. The graph of something like "x^(2)+y^(2)=1" is just the set of all (x,y) that make this sentence true. These are also not functions.

Back to functions. We usually give functions names - typically one letter like "f" but we can be creative with it like "cos". If a function is named "f" and we feed into it the input "x", then we give the name "f(x)" to the output. That is "f(x)" is the output you get from "f" when you input "x". If "AddOne" is our function from before, then AddOne(1) is just another way to write 2. Using equations, we can then say "AddOne(1)=2". In fact, AddOne(4)=5 and AddOne(6)=7. If x is a yet-to-be-determined number then maybe I can find a simple *expression* that helps me know what AddOne(x) is. In fact, there is, and I can say that "AddOne(x) = x+1". This is an *equation* which finds an *expression* that the *function* equals when fed an arbitrary vale. The *function* is "AddOne", and "x+1" is merely an *expression* that we can use. These are all different things, which can be confusing, and their differences are not articulated well in math classes.

An important thing is that simple expressions for functions like "f(x)=x^(2)" or "F(x)=x-1" are a matter of convenience and are NOT defining features of functions. In fact *most* functions do not have simple expressions for their rules, it is an exception when they can be expressed simply. For instance, there is no simple expression that I can say equals sin(x). And so sin(x) is defined by what it does rather than some mathematical expression that is simple for computation. sin(x) is the y-coordinate of the point on the unit circle that makes an angle "x" with the positive horizontal axis. That's what it "is", it provides a rule to output a number given an input, but there is no expression for it. Most functions of interest are like this: The path air takes over a plane's wing, the price of a stock, the temperature at a given location over time, the number of primes less than the input number etc. These are functions that people are *actually* interested in and actually study. They are merely defined by what they do and not by an expression they equal. Most of math deals with trying to find ways to *use* our simple tools in order to approximate or predict these actually interesting functions.

Comment by [deleted] at 26/06/2024 at 19:33 UTC*

3 upvotes, 1 direct replies

[removed]

Comment by [deleted] at 26/06/2024 at 19:47 UTC

3 upvotes, 1 direct replies

[removed]

Comment by mfukar at 27/06/2024 at 07:05 UTC

2 upvotes, 0 direct replies

The definition you've read (a correspondence/assignment/relationship between sets) is accurate. The informal definition is flexible enough to learn about functions' properties in a clear way, and the formal definition is not what we'd call inaccessible. There is no way to tell what feels intuitive to you and what is not, so it is best to ask the question in a different way.

Importantly, every previous comment reply to you is incorrect in some - minor or not - way, the most important one is that functions in computer science are very different in most contexts. They have been removed.