The mathematical connection of functions in programming
A tiny excerpt I have written during my time as mathematics major in undergrad while I was taking a Programming Languages class.
In programming, functions can be defined as “self-contained” sequences of code that are program to execute a specific task; it is a way to combine multiple actions into one single process (Germain). Functions in programming work in a similar way to functions in mathematics; as they both have inputs and outputs. However in programming, these inputs take in data types and process it order to return a result (Myers, 2010). I have created an example below to illustrate the similarities of how functions in mathematics are parallel with functions in programming.
This is how a function is traditionally defined in mathematics:
A function from X to Y assigns each element of X to each element of Y.
However the notation of a function can also be written as:
I have written the second notation because it can be easier to visualize how a function also works within a program, which would then better illustrate the parallels of how functions work in both mathematics and in programming.
Think of X as your initial input, which is typically articulated through arguments…