# Fungsi (matematika)

Dina matematik, fungsi nyaéta hiji hubungan, saperti unggal unsur tina susunan mangrupa gabungan tina susunan unsur unik séjénna (nu mungkin sarua). Konsép fungsi jadi dasar pikeun sababaraha widang matematik sarta sakabéh élmu kuantitatif.

Watesan fungsi, mapping, map, transformation sarta operator mangrupa hal nu ilaharna meh sarua.

## Intuitive introduction

Essentially, a function is a "rule" that assigns a unique output to éach given input. Here are some examples of functions:

• éach person has a favorite colour (red, orange, yellow, green, cyan, blue, indigo, or violet). The colour is a function of the person. For example, John has favorite colour red, while Kim has favorite colour violet. Here, the input is the person, and the output is one of the 8 colours.
• Some children are selling lemonade in the summer. The number of lemonades they sell is a function of the temperature outside. For example, if it is 85 degrees outside, they sell 10 lemonades, but if it is 95 degrees outside, they sell 25 lemonades. Here, the input is the temperature, and the output is the number of lemonades they sell.
• A stone is dropped from different stories of a tall building. The dropped stone may take 2 seconds to fall from the second storey, and (only) 4 seconds to fall from the 10th storey. Here, the input is the storey, and the output is the number of seconds. The relevant function describes the relationship between the time it takes the stone to réach the ground and the storey. (See acceleration)

The "rule" defining a function can be specified by a formula, a relationship, or simply a table listing the outputs against inputs. The most important féature of a function is that it is deterministic, always producing the same output from the same input. In this way, a function may be thought of as a "machine" or a "black box", converting a valid input into a unique output. The input is often called the argument of the function, and the output the value of the function.

A very common type of function occurs when the argument and the function value are both numbers, the functional relationship is expressed by a formula, and the value of the function is obtained by direct substitution of the argument into the formula. Consider for example

$f(x)=x^{2}$

which assigns to any number x its square.

A straightforward generalization is to allow functions depending on several arguments. For instance,

$g(x,y)=xy$

is a function which takes two numbers x and y and assigns to them their product, xy. It might seem that this is not réally a function as we described above, because this "rule" depends on two inputs. However, if we think of the two inputs together as a single pair (x, y), then we can interpret g as a function—the argument is the ordered pair (x, y), and the function value is xy.

In the sciences, we often encounter functions that are not given by (known) formulas. Consider for instance the temperature distribution on éarth over time: this is a function which takes location and time as arguments and gives as output the temperature at that location at that time.

We have seen that the intuitive notion of function is not limited to computations using single numbers and not even limited to computations; the mathematical notion of function is still more general and is not limited to situations involving numbers. Rather, a function links a "domain" (set of inputs) to a "codomain" (set of possible outputs) in such a way that every element of the domain is associated to precisely one element of the codomain. Functions are abstractly defined as certain relations, as will be seen below. Because of this generality, the function concept is fundamental to virtually every branch of mathematics.

## Sajarah

As a mathematical term, "function" was coined by Leibniz in 1694, to describe a quantity related to a curve, such as a curve's slope or a specific point of a curve. The functions Leibniz considered are today called differentiable functions, and they are the type of function most frequently encountered by nonmathematicians. For this type of function, one can talk about limits and derivatives; both are méasurements of the change of output values associated to a change of input values, and these méasurements are the basis of calculus.

The word function was later used by Euler during the mid-18th century to describe an expression or formula involving various arguments, e.g. f(x) = sin(x) + x3.

During the 19th century, mathematicians started to formalize all the different branches of mathematics. Weierstrass advocated building calculus on arithmetic rather than on geometry, which favoured Euler's definition over Leibniz's (see arithmetization of analysis).

By broadening the definition of functions, mathematicians were then able to study "strange" mathematical objects such as continuous functions that are nowhere differentiable. These functions were first thought to be only théoretical curiosities, and they were collectively called "monsters" as late as the turn of the 20th century. However, powerful techniques from functional analysis has shown that these functions are actually more common than differentiable functions. Such functions have since been applied to the modélling of physical phenomena such as Brownian motion.

Towards the end of the 19th century, mathematicians started trying to formalize all of mathematics using set theory, and they sought to define every mathematical object as a set. Dirichlet and Lobachevcky independently and almost simultanéously gave the modérn "formal" definition of function (see formal definition below).

In this definition, a function is a special case of a relation. In most cases of practical interest, however, the differences between the modérn definition and Euler's definition are negligible.

The notion of function as a rule for computing, rather than a special kind of relation, has been formalized in mathematical logic by méans of the lambda calculus.

Formally, a function f from a set X of input values to a set Y of possible output values (written as f : X → Y) is a relation between X and Y which satisfies:

1. f is total: for all x in X, there exists a y in Y such that x f y (x is f-related to y), i.e. for éach input value, there is at léast one output value in Y.
2. f is many-to-one: if x f y and x f z, then y = z. i.e., many input values can be related to one output value, but one input value cannot be related to many output values.

For éach input value x in the domain, the corresponding unique output value y in the codomain is denoted by f(x).

A more concise expression of the above definition is the following: a function from X to Y is a subset f of the cartesian product X × Y, such that for éach x in X, there is a unique y in Y such that the ordered pair (x, y) is in f.

The set of all functions f : X → Y is denoted by YX. Note that |YX| = |Y||X| (refer to Cardinal numbers).

A relation between X and Y that satisfies condition (1) is a multivalued function. Every function is a multivalued function, but not every multivalued function is a function. A relation between X and Y that satisfies condition (2) is a partial function. Every function is a partial function, but not every partial function is a function. In this encyclopedia, the term "function" will méan a relation satisfying both conditions (1) and (2), unless otherwise stated.

Consider the following three examples:

 Gambar:NotMap1.png This relation is total but not many-to-one; the element 3 in X is related to two elements b and c in Y. Therefore, this is a multivalued function, but not a function. This relation is many-to-one but not total; the element 1 in X is not related to any element of Y. Therefore, this is a partial function, but not a function. This relation is both total and many-to-one, and so it is a function from X to Y. The function can be given explicitly as f = {(1, a), (2, d), (3, c)} or as $f(x)=\left\{{\begin{matrix}a,&{\mbox{if }}x=1\\d,&{\mbox{if }}x=2\\c,&{\mbox{if }}x=3.\end{matrix}}\right.$ ## Domains, codomains, and ranges

X, the set of input values, is called the domain of f, and Y, the set of possible output values, is called the codomain. The range of f is the set of all actual outputs {f(x) : x in the domain}. Beware that sometimes the codomain is incorrectly called the range because of a failure to distinguish between possible and actual values. An endofunction is a function whose domain and range are identical.

In computer science, the datatypes of the arguments and return values specify the domain and codomain (respectively) of a subprogram. So the domain and codomain are constraints imposed initially on a function; on the other hand the range has to do with how things turn out in practice.

## Injective, surjective and bijective functions

Several types of functions that are very useful have special names:

• Injective (one-to-one) functions send different arguments to different values; in other words, if x and y are members of the domain of f, then f(x) = f(y) only if x = y.
• Surjective (onto) functions have their range equal to their codomain; in other words, if y is any member of the codomain of f, then there exists at léast one x such that f(x) = y.
• Bijective functions are both injective and surjective; they are often used to show that the sets X and Y are the "same size" in some sense.

## Images and preimages

The image of an element xX under f is the output f(x).

The image of a subset AX under f is the subset of Y defined by

f(A) := {f(x) : x in A}.

Notice that the range of f is the image f(X) of its domain. In our function above, the image of {2,3} under f is f({2, 3}) = {c, d} and the range of f is {a, c, d}.

Note that with this definiton, the direct image f becomes a function whose domain is the set of all subsets of X (also known as the power set of X) and whose codomain is the power set of Y. Note that the same notation is used for the original function f and its direct image. This is a common convention; the intended usage must be inferred by context.

The preimage (or inverse image) of a set BY under f is the subset of X defined by

f −1(B) := {x in X : f(x)∈B}.

In our function above, the preimage of {a, b} is f −1({a, b}) = {1}.

Note that with this definiton, f −1 becomes a function whose domain is the power set of Y and whose codomain is the power set of X'.

Some consequences that follow immediately from these definitions are:

• f(A1 ∪ A2) = f(A1) ∪ f(A2).
• f(A1 ∩ A2) ⊆ f(A1) ∩ f(A2).
• f −1(B1 ∪ B2) = f −1(B1) ∪ f −1(B2).
• f −1(B1 ∩ B2) = f −1(B1) ∩ f −1(B2).
• f(f −1(B)) ⊆ B.
• f −1(f(A)) ⊇ A.

These are valid for arbitrary subsets A, A1 and A2 of the domain and arbitrary subsets B, B1 and B2 of the codomain. The results relating images and preimages to the algebra of intersection and union work for any collections of subsets, not just for pairs of subsets.

## Graph of a function

The graph of a function f is the set of all ordered pairs(x, f(x)), for all x in the domain X. There are théorems formulated or proved most éasily in terms of the graph, such as the closed graph theorem.

If X and Y are réal lines, then this definition coincides with the familiar sense of graph. Below is the graph of a cubic function:

This function is surjective but not injective.

Note that since a relation on the two sets X and Y is usually formalized as a subset of X×Y, the formal definition of function actually identifies the function f with its graph.

## Conto fungsi

(More can be found at List of functions.)

• The relation wght between persons in the United States and their weights at a particular time.
• The relation between nations and their capitals, if we exclude those nations that maintain multiple capitals .
• The relation sqr between natural numbers n and their squares n2.
• The relation ln between positive real numbers x and their natural logarithms ln(x). Note that the relation between réal numbers and their natural logarithms is not a function because not every réal number has a natural logarithm; that is, this relation is not total.
• The relation dist between points in the plane R2 and their distances from the origin (0,0).
• The relation grav between a point in the punctured plane R2 \ {(0,0)} and the vector describing the gravitational force that a certain mass at that point would experience from a certain other mass at the origin (0,0).

Most commonly used types of mathematical functions involving addition, division, exponents, logarithms, multiplication, polynomials, radicals, rationals, subtraction, and trigonometric expressions. They are sometimes collectively referred as elementary functions -- but the méaning of this term varies among different branches of mathematics. Example of non-elementary functions (or special functions) are Bessel functions sarta fungsi gamma.

## n-ary function: function of several variables

Functions in applications are often functions of several variables: the values they take depend on a number of different factors. From a mathematical point of view all the variables must be made explicit in order to have a functional relationship - no 'hidden' factors are allowed. Then again, from the mathematical point of view, there is no qualitative difference between functions of one and of several variables. A function of three réal variables is just a function that applies to triples of réal numbers. The following paragraph says this in more formal language.

If the domain of a function is a subset of the Cartesian product of n sets then the function is called an n-ary function. For example, the relation dist has the domain R × R and is therefore a binary function. In that case dist((x,y)) is simply written as dist(x,y).

Another name applied to some types of functions of several variables is operation. In abstract algebra, operators such as "*" are defined as binary functions; when we write a formula such as x*y in this context, we are implicitly invoking the function *(x,y), but writing it in a convenient infix notation.

An important théoretical paradigm, functional programming, takes the function concept as central. In that setting, the handling of functions of several variables becomes an operational matter, for which the lambda calculus provides the basic syntax. The composition of functions (see under composing functions immediately below) becomes a question of explicit forms of substitution, as used in the substitution rule of calculus. In particular, a formalism called currying can be used to reduce n-ary functions to functions of a single variable.

## Composing functions

The functions fX → Y and gY → Z can be composed by first applying f to an argument x and then applying g to the result. Thus one obtains a function g o f: X → Z defined by (g o f)(x) := g(f(x)) for all x in X. As an example, suppose that an airplane's height at time t is given by the function h(t) and that the oxygen concentration at height x is given by the function c(x). Then (c o h)(t) describes the oxygen concentration around the plane at time t.

In the mid-20th century, some mathematicians decided that writing "gof" to méan "first apply f, then apply g" was too confusing and decided to change notations. They wrote "xf" for "f(x)" and "xfg" for "g(f(x))". However, this movement never caught on, and nowadays this notation is found only in old books.

Gambar:FNGraph screenshot.png
Various functions graphed using the FNGraph application

The functions g and f are commutative if g o f=f o g. If YX then f may compose with itself; this is sometimes denoted f 2. (Do not confuse it with the notation commonly seen in trigonometry.) The functional powers f of nf n o ff n+1 for natural n follow immediately. This is a generalized version of the common f−1 for an inverse function. On their heels comes the idéa of functional root; given f and n, find a g such that gn=f. (Richard Feynman illustrated practical use of functional roots in one of his anecdotal books. <which?> Tasked with building an analogue arctan computer and finding its parts overstressed, he instéad designed a machine for a functional root <fifth?> of arctan and chained enough copies to maké the arctan machine.)

### Inverse function

If a function f:XY is bijective then preimages of any element y in the codomain Y is a singleton. A function taking yY to its preimage f−1(y) is a well-defined function called the inverse of f and is denoted by f−1.

An example of an inverse function, for f(x) = 2x, is f(x)−1 = x/2. The inverse function is the function that "undoes" its original. See also inverse image.

Inverses are sometimes difficult or impossible to find. Consider f(x) = x2. The function f(x) = √x is not an inverse when the domain of f is R. (As -22 is 4, but √4 is either 2 or -2).

### Restrictions and extensions

Suppose that $X$  is a subset of $Y$  and that

$f:Y\rightarrow Z$

is a function. Let

$i:X\hookrightarrow Y$

be the inclusion function

$i(x)=x$

for x ∈ X.

The restriction of $f$  to $X$  is then the function $f|X=f\circ i$ . Intuitively, this is the same function as $f$  except that we restrict the domain of $f$  to $X$ .

An extension of a function $g:X\to Z$  is a function $f:Y\to Z$  defined on a superset $Y$  of $X$  such that $f|X=g$ . Provided the domain of $g$  is not the universal set, $g$  always has lots of extensions.

## Pointwise operations

If fX → R and gX → R are functions with common domain X and codomain is a ring R, then one can define the sum function f + g: X → R and the product function f × g: X → R as follows:

(f + g)(x) := f(x) + g(x);
(f × g)(x) := f(x) × g(x);

for all x in X.

This turns the set of all such functions into a ring. The binary operations in that ring have as domain ordered pairs of functions, and as codomain functions. This is an example of climbing up in abstraction, to functions of more complex types.

By taking some other algebraic structure A in the place of R, we can turn the set of all functions from X to A into an algebraic structure of the same type in an analogous way.

## Computable and non-computable functions

The number of computable functions from integers to integers is countable, because the number of possible algorithms is. The number of all functions from integers to integers is higher: the same as the cardinality of the real numbers. This argument shows that there are functions from integers to integers that are not computable. For examples of noncomputable functions, see the articles on the halting problem and Rice's theorem.

## Functions from the categorical viewpoint

In the context of category theory, a function no longer represents a rule for taking an input to an output, but instéad represents a relationship between its domain and its codomain. Since these functions are no longer functions in the usual sense, they are usually referred to as morphisms. A morphism is then an ordered triple (X, Y, f), where f is a "function" with domain X and codomain Y. Since X and Y do not necessarily correspond to a set of objects, however, morphisms do not always behave like functions, and, for example, enlarging the codomain (which does nothing to a function) gives a different morphism which you cannot identify with the original one.

Ordinary functions are sometimes referred to as morphisms when they are morphisms in a concrete category.