3 ms·
As a slight additional aside I realised it might be interesting for some to understand some parallels between functions in programming and functions in maths.
by seanhunter 2y ago
As a slight additional aside I realised it might be interesting for some to understand some parallels between functions in programming and functions in maths.
For programmers, you can think of the rule of the function as being like the function body when you write a function in a computer program. The codomain is like the return type of the function (except in maths you're really talking about a set and in maths a set and a type are somewhat different things).
The domain is like the type of the function inputs (although it's also a set not a type). So if you have a function where the rule is f(x) = x^2 you can hopefully see that if the domain is the real numbers that's a different function from if the domain is the complex numbers.
I mentioned the image set of the function in my previous post, so just to finish off the explanation, say we have f where the domain and codomain are the reals and the rule of f is f(x) = x^2. The image set of f is actually going to be all the real numbers greater than or equal to zero (even though the codomain is all real numbers). The reason for this is if you (hypothetically) went through every value in the domain and applied the rule you would always get a value from zero to positive infinity. None of the real numbers when mapped by the function (squared) will return a negative number.
The domain is the type of all the inputs, so if you have a function which takes multiple inputs, the domain will be a set of tuples (think of them like coordinates) and likewise for functions which have multiple outputs, the co-domain and image set will contain tuples.