Update
This commit is contained in:
parent
4e7b5162c7
commit
6c4c9fc63c
6 changed files with 12 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
# Function
|
||||
|
||||
Function is a very basic term in [mathematics](math.md) and [programming](programming.md) with a slightly different meanings in each: mathematical function maps numbers to other numbers, a function in programming is a subprograms to which we divide a bigger program. Well, that's pretty simplified but those are the basic ideas. A more detailed explanation will follow.
|
||||
Function is a very basic term in [mathematics](math.md) and [programming](programming.md) with a slightly different meanings in each: mathematical function maps numbers to other numbers, a function in programming is a subprogram to which we divide a bigger program. Well, that's pretty simplified but those are the basic ideas. A more detailed explanation will follow.
|
||||
|
||||
## Mathematical Functions
|
||||
|
||||
|
@ -12,9 +12,9 @@ Here we call the function *f* and say it takes one [parameter](parameter.md) (th
|
|||
|
||||
{ I always imagined functions as kind of little boxes into which we throw a number and another number falls out. ~drummyfish }
|
||||
|
||||
Now consider a function *f2(x) = 1 - 1 / x*. Note that in this case the domain is the set of real number minus [zero](zero.md); the function can't take zero as an input because we can't divide by zero. The codomain is the set of real numbers minus one because we can't ever get one as a result.
|
||||
Now consider a function *f2(x) = 1 - 1 / x*. Note that in this case the domain is the set of real numbers minus [zero](zero.md); the function can't take zero as an input because we can't divide by zero. The codomain is the set of real numbers minus one because we can't ever get one as a result.
|
||||
|
||||
Another common example of a function is the [sine](sin.md) function that we write as *sin(x)*. It can be defined in several ways, commonly e.g. as follows: considering a [right triangle](right_triangle.md) with one of its angles equal to *x* [radians](radian.md), *sin(x)* is equal to the ratio of the side opposing this angle to the triangle [hypotenuse](hypotenuse.md). For example *sin(pi / 2) = sin(45 degrees) = 1 / sqrt(2) ~= 0.71*. The domain of sine function is again the set of real number but its codomain is only the set of real numbers between 0 and 1 because the ratio of said triangle sides can never be negative or greater than 1, i.e. sine function will never yield a number outside the interval <0,1>.
|
||||
Another common example of a function is the [sine](sin.md) function that we write as *sin(x)*. It can be defined in several ways, commonly e.g. as follows: considering a [right triangle](right_triangle.md) with one of its angles equal to *x* [radians](radian.md), *sin(x)* is equal to the ratio of the side opposing this angle to the triangle [hypotenuse](hypotenuse.md). For example *sin(pi / 4) = sin(45 degrees) = 1 / sqrt(2) ~= 0.71*. The domain of sine function is again the set of real number but its codomain is only the set of real numbers between -1 and 1 because the ratio of said triangle sides can never be negative or greater than 1, i.e. sine function will never yield a number outside the interval <-1,1>.
|
||||
|
||||
Note that these functions have to satisfy a few conditions to really be functions. Firstly each number from the domain must be assigned exactly one number (although this can be "cheated" by e.g. using a set of couples as a codomain), even though multiple input numbers can give the same result number. Also importantly **the function result must only depend on the function's parameter**, i.e. the function mustn't have any memory or inside state and it mustn't depend on any external factors (such as current time) or use any randomness (such as a dice roll) in its calculation. For a certain [argument](argument.md) (input number) a function must give the same result every time. For this reason not everything that transforms numbers to other numbers can be considered a function.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue