# Nakafa Learning Content

> For AI agents: use [llms.txt](https://nakafa.com/llms.txt) for the site index. Markdown versions are available by appending `.md` to content URLs or sending `Accept: text/markdown`.

URL: https://nakafa.com/en/subjects/mathematics/function-composition-inverse-function/domain-codomain-range
Source: https://raw.githubusercontent.com/nakafaai/nakafa.com/refs/heads/main/packages/contents/material/lesson/mathematics/function-composition-inverse-function/domain-codomain-range/en.mdx

Learn function domain, codomain, and range concepts with practical examples. Understand input restrictions and output sets in mathematical functions.

---

## Domain

The Domain is like the VIP guest list for our function machine. It is the **collection of all input values that are allowed** into the function. If a value is not on the list (domain), it cannot enter the function machine.

### Finding the Domain Example

Suppose we have a function like this:

```math
f(x) = \frac{1}{x}
```

This machine works by dividing $$1$$ by the number you input. Can we input all numbers? Try inputting the number $$0$$.

Visible text: This machine works by dividing by the number you input. Can we input all numbers? Try inputting the number .

```math
f(0) = \frac{1}{0}
```

Oops, we cannot divide by zero! That's not allowed in mathematics. So, the number $$0$$ is not included in the guest list (domain) for this function. All other numbers are allowed.

Visible text: Oops, we cannot divide by zero! That's not allowed in mathematics. So, the number is not included in the guest list (domain) for this function. All other numbers are allowed.

So, the domain of the function $$f(x) = \frac{1}{x}$$ is all real numbers except $$0$$.

Visible text: So, the domain of the function is all real numbers except .

Another example:

```math
g(x) = \sqrt{x}
```

This machine finds the square root of the input. Can we input negative numbers, for example $$-4$$?

Visible text: This machine finds the square root of the input. Can we input negative numbers, for example ?

```math
g(-4) = \sqrt{-4}
```

For real numbers, we cannot take the square root of a negative number. So, all negative numbers are not allowed. Only $$0$$ and positive numbers are allowed.

Visible text: For real numbers, we cannot take the square root of a negative number. So, all negative numbers are not allowed. Only and positive numbers are allowed.

So, the domain of the function $$g(x) = \sqrt{x}$$ is all real numbers greater than or equal to $$0$$ ($$x \ge 0$$).

Visible text: So, the domain of the function is all real numbers greater than or equal to ().

## Codomain

The Codomain is like a **catalog of all possible outputs** that the function machine can produce. It is the set of values where we _expect_ the output to be. We determine this catalog when defining the function.

For example, let's define a function $$f(x) = 2x$$.
We specify the **Domain** (input) as the set of natural numbers:

Visible text: For example, let's define a function .
We specify the **Domain** (input) as the set of natural numbers:

```math
\{1, 2, 3, ...\}
```

Then, we specify the **Codomain** (possible output) as the set of integers:

```math
\{..., -2, -1, 0, 1, 2, ...\}
```

By defining the codomain as integers, we are stating that we _expect_ the result of the function $$f(x)=2x$$ to be an integer. Although we know that if the input is a natural number, the output will definitely be a positive even number (which is the Range):

Visible text: By defining the codomain as integers, we are stating that we _expect_ the result of the function to be an integer. Although we know that if the input is a natural number, the output will definitely be a positive even number (which is the Range):

```math
\{2, 4, 6, ...\}
```

The codomain we defined (integers) is still valid because all the actual results
(range) are included in the codomain.

The codomain tells us what 'type' of value might come out, even if not all values in the codomain actually appear as results.

## Range

The Range is the **collection of all output values that are _actually_ produced** by the function when we input all members of the domain. The Range is part of (or sometimes exactly the same as) the Codomain.

**Example:**
Let's use the function $$f(x) = x^2$$ again.

Visible text: **Example:**
Let's use the function again.

Suppose the Domain is the set of integers:

```math
\{..., -2, -1, 0, 1, 2, ...\}
```

and the Codomain is also the set of integers.

When we input values from the domain:

- $$f(-2) = 4$$
- $$f(-1) = 1$$
- $$f(0) = 0$$
- $$f(1) = 1$$
- $$f(2) = 4$$
- and so on...

Visible text: - 
- 
- 
- 
- 
- and so on...

The values that _actually_ come out as output are $$0, 1, 4, 9, 16$$, and so on (non-negative square numbers).
So, the **Range** of this function (with this domain) is the set:

Visible text: The values that _actually_ come out as output are , and so on (non-negative square numbers).
So, the **Range** of this function (with this domain) is the set:

```math
\{0, 1, 4, 9, 16, ...\}
```

Notice that this range ($$\{0, 1, 4, 9, ...\}$$) is a part (subset) of the codomain we defined (integers):

Visible text: Notice that this range () is a part (subset) of the codomain we defined (integers):

```math
\{..., -1, 0, 1, 2, ...\}
```

Not all members of the codomain are part of the range.

## Why Is This Important?

Understanding domain, codomain, and range is very important because it helps us define functions correctly and understand their limitations. Without a clear domain, we might try to input values that "break" the function (like dividing by zero). Without codomain and range, we don't know exactly what kind of output to expect.

## Mathematical Relationship

Mathematically, a function $$f$$ maps every element from the set Domain ($$D$$) to one element in the set Codomain ($$K$$). This is often written as:

Visible text: Mathematically, a function maps every element from the set Domain () to one element in the set Codomain (). This is often written as:

```math
f: D \to K
```

The Range ($$R$$) is the set of all actual results $$f(x)$$ for every $$x$$ in the Domain. In other words:

Visible text: The Range () is the set of all actual results for every in the Domain. In other words:

```math
R = \{ f(x) \mid x \in D \}
```

The important relationship between the three is that the Range is always a subset of the Codomain:

```math
R \subseteq K
```

This means all values that actually come out of the function (Range) must be included
in the set of values that *might* come out (Codomain), but not all values in the
Codomain must be results.