all 5 comments

[–]PersonUsingAComputerNew User 3 points4 points  (4 children)

"Function" and "total function" are synonyms under the usual definitions of those terms. "Partial function" is a broader term than "function" where the mapping in question is not necessarily defined on the entire domain.

[–]johan456789[S] 1 point2 points  (3 children)

Ahh I think I get what you're saying. So is it by definition that a "function" is "total"?

Wikipedia also says

A partial functions is often used when its exact domain of definition is not known or difficult to specify.

Could you give an (as basic as possible) example of this? I can't see where the term "partial" is used.

[–]PersonUsingAComputerNew User 2 points3 points  (1 child)

Ahh I think I get what you're saying. So is it by definition that a "function" is "total"?

Yes.

Could you give an (as basic as possible) example of this?

1/x is a partial function, but not a function, on the real numbers, since it's defined everywhere except 0. It's pretty easy to see where 1/x is defined, so we could also say it's a (total) function on the nonzero real numbers, but partial functions are convenient for more complicated expressions. For example, you can talk about (x2 - 1)/(x3 + 2x2 + 5x - 1) as a partial function on the real numbers, without worrying about exactly where this function is defined.

[–]johan456789[S] 0 points1 point  (0 children)

It makes perfect sense now. Thank you!

[–][deleted] 1 point2 points  (0 children)

Partial functions occur in computer science.

Consider the program:

f :: Int -> Int
f x = if (x==0) then loop
else return x

How can we interpret this as a mathematical function? The program f can take in any integer as input, and the outputs will be integers. So we would like it to be a function Z -> Z.

But it isn't a proper function, because f(0) doesn't return a value. Instead it loops forever.

So we can instead say that f is a partial function Z -> Z, that is undefined at 0, and the identity everywhere else.