GeeksforGeeks App
Open App
Browser
Continue

# Composition of Functions

Composition of Function is the process or operation which combines two or more functions together into a single function. We define functions as the set of operations that operate on a set of values and give the desired output. Suppose f is a function say a function which draws the sketch of the fruits whose name we enter, here, the name given by us is the input value and the sketch of the fruit is the output value. Similarly, imagine any other function g which colors the given sketch.

Now a composition of function takes the two function and make it into one function, we define this function as the g[f(name of the fruit)]. Here, f(name of the fruit) is the first function, g(sketch of the fruit) is the second function, and g[f(name of the fruit)] is the composition of these two functions. Let’s learn about the Composition of Functions, their calculation, domain, and range in detail in this article.

## What is the Composition of Functions?

Composition of function is the building of the complex function using the simple function. Suppose we take two functions f(x) and g(x) which both take x as input values and give the specific output than the composition of function f(x) and g(x) when f(x) is first computed is, g(f(x)) of (g∘f)(x). We can understand this concept by the following example,

Example: If, f(x) = x2 and g(x) = x + 3. Then calculate the composition g(f(x)) and f(g(x)).

Solution:

g(f(x)) = g(x2) = x2 + 3

Similarly, we can easily calculate the f(g(x)) or (f∘g)(x) where g(x) is computed first.

f(g(x)) = f(x + 3) = (x + 3)2

Notice that g(f(x)) is not equal to f(g(x)) they can or can not be equal depending on the function f(x) and g(x). The composition of a function is also called the function of a function. Thus, we can say that,

• For f(g(x)), g(x) is the input of the function f(x).
• For g(f(x)), f(x) is the input of the function g(x).

We can understand this concept with the help of the image discussed below,

## Symbol of Composition of Functions

The composition of functions is represented using the symbol . We can also represent the composition of functions by simply using the parenthesis (). For any two given functions f(x) and g(x) we can find the composition of the function by using the formula,

(f∘g)(x) = f(g(x))

The above function is read as “f of g of x”. Here, first x is passed to g(x) which gives the answer in x and then the answer is passed to f(x) to find the desired composition of function.

(g∘f)(x) = g(f(x))

The above function is read as “g of f of x”. Here, first x is passed to f(x) which gives the answer in x and then the answer is passed to g(x) to find the desired composition of function.

## How to Solve Composite Functions?

Composite functions or the Composition of functions can easily be solved with the help of basic mathematics rules (BOADMAS). For any composite function, we first simplify the value inside the bracket and then the answer of the function is used as the input value for the second function. As we see here the order of the operation is very important and solving the question in the wrong order may result in the wrong answer.

For any two given functions f(x) and g(x), the composite function f(g(x)) and g(f(x)) is found using the following steps,

• For f(g(x)), we first find the g(x) and then substitute its value as input to f(x) and then find f(g(x))

Similarly, we can find the g(f(x)) as,

• For g(f(x)), we first find the f(x) and then substitute its value as input to g(x) and then find g(f(x))

This can be easily understood with the help of an example

Example: If f(x) = x + 2 and g(x) = (2x)2 find, f(g(x)) and g(f(x))

Solution:

For f(g(x))

Given, g(x) = (2x)2 = 4x2

Thus, f(g(x)) = f(4x2) = 4x2 + 2

Now for g(f(x))

Given, f(x) = x + 2

Thus, g(f(x)) = (2(x+2))2 = (2x + 4)2

⇒ g(f(x)) = 4x2 + 16 + 8x

## Finding Composite Function From Graph

If the functions are not given algebraically and only their graphical value is given then also they can be easily calculated using the graphs given.

To find the composite function of two functions f(x) and g(x) whose graphs are given, then (x, y) is a point on a function f(x) then f(x) = y. We can find f(g(a)) (i.e., f(g(x)) at x = a) using the above information.

Step 1: Firstly find g(a) i.e., the y-coordinate the on the graph of g(x) at x = a

Step 2: Now find f(g(a)) i.e., the y-coordinate on the graph of f(x) at x = g(a))

This can be understood using the image discussed below,

## Finding Composite Function From Table

Composite function or composition of function can also be easily calculated using the table in which the values of the function corresponding to a given input value are given. Let’s find the composite function using the table given below,

Example: From the following tables of f(x) and g(x), find g(f(1)).

For f(x) the table is,

For g(x) the table is,

Solution:

f(1) = 3 (from the first table)

g(f(1)) = g(3)

Now using the second table we can get the above value.

g(3) = 9

Thus, the required solution for g(f(1)) is 9

## Function Composition with Itself (Self Composition)

We can also compose a function with itself and it is called a self-composite function. For any given function f(x) the function composition with itself is f(f(x)) it is also defined as (f∘f)(x). Now,

(f∘f)(x) = f(f(x))

It can be better understood with the help of an example

Example: If f(x) = x3, then find (f∘f)(x).

Solution:

Given: f(x) = x3

(f∘f)(x) = f(f(x))
= f (x3)
= (x3)3

(f∘f)(x) = x6

## Domain and Range of Composition of Functions

It is not possible to compose any two functions, some functions cannot be composed together, for example, let’s say f(x) = ln(x) and g(x) = -x. If we try to compose f(g(x)), it is not possible for the positive value of x, as the logarithmic function cannot take negative input values, so f(g(x)) is not possible. So, there are certain things that should be kept in mind while deciding on composing the function.

So before composing any two functions first we have to find the domain and range of the function.

### Domain of Composite Functions

For any function f(x) and g(x) defined as g: X → Y and f: Y → Z then f(g(x)) is defined as f∘g: X → Z. i.e., the domain of f ∘ g is X and the range is Z.

If the functions are defined algebraically then also we can easily define their domain. To find the domain of the composite function use the following steps. If we have to find the domain of f(g(x))

Step 1: Firstly we will find the domain of the inner function g(x)

Step 2: Then we find the domain of the function obtained by finding f(g(x))

Step 3: Now the intersection of the domain of g(x) and the domain of f(g(x)) is the domain of f(g(x))

### Range of Composite Functions

The range of the composite function does not get affected by the inner function it only depends on the outer function and we can easily find the range of the composite function using normal methods.

We can easily understand these concepts with the help of the following example.

Example: Find the domain and range of f(g(x)) when f(x) = x+2 and g(x) = x2.

Solution:

For f(g(x)),

The inner function is g(x) and its domain is A = R

Now f(g(x)) = f(x2)

f(g(x)) = x2 + 2

The domain of x2 + 2 is R (say B)

Now the intersection of A and B is the domain of f(g(x))

Domain of f(g(x)) = A∩B = R

The range of f(g(x)) is the range of x2 + 2

Now the range is [2, ∞)

## Properties of Composition of Function

There are various properties of the composition of function, some of those properties are:

• Associativity Property: For functions f, g, and h, the composition of these functions is associative, if and only if

(f∘g)∘h = f∘(g∘h)

• Commutative Property:  Composition for any two functions f and g, is commutative if and only if

f∘g = g∘f

• Identity Property: For any function f, the identity function I(x) = x acts as the identity element for composition, meaning

f∘I = I∘f = f

• Inverse Property: If a function f has an inverse function f⁻¹, then

(f∘f⁻¹) = I = (f⁻¹∘f)

Some other properties of the Composition of Functions are:

• The composition of two or more one-one functions (Injective) is always one-one.
• The composition of onto functions(surjective) is always onto.
• Also, the composition of two or more bijections(one-one and onto) is always bijection.
• The inverse function of the composition of two invertible functions has the property that (f∘g)−1 = g−1∘f−1.

## Solved Examples on Composition of Function

Example 1: For the given functions f(x) = ex and g(x) = x2 + 1. Find out the values of f(g(x)) and g(f(x)).

Solution:

The domain of both the functions are real numbers, so there is no need to modify the domain for the first function in any case.

For f∘g(x),

f∘g(x) = f(g(x))

⇒ f∘g(x) = f(x2 + 1)

⇒ f∘g(x) =

For g∘ f(x)

g∘f(x) = g(f(x))

⇒ g∘f(x) = g(ex

⇒ g∘f(x) = (ex)2 + 1

⇒ g∘f(x) = e2x + 1

Example 2: For the given functions f(x) = 2x and g(x) = x2 + 1. Find out the values of f(g(x)) and g(f(x)) at x = 2.

Solution:

The domain of both the functions are real numbers, so there is no need to modify the domain for the first function in any case.

f∘g(x) = f(g(x))

⇒ f∘g(x) = f(x2 + 1)

⇒ f∘g(x) = 2(x2 + 1)

At x = 2,

⇒ f(g(2)) = 2(4 + 1)
⇒ f(g(2)) = 10

g∘ f(x) = g(f(x))

⇒ g∘f(x) = g(2x)

⇒ g∘f(x) = (2x)2 + 1

⇒ g∘f(x) = 4x4 + 1

At x = 2

g(f(2)) = 4(24) + 1
⇒ g(f(2)) = 4(16) + 1
⇒ g(f(2)) = 65

Example 3: For the given functions f(x) = sin(x) and g(x) = x2. Find out the domain and range for f∘g(x) and g∘f(x).

Solution:

f(x) = sin x has domain as all real numbers and range [-1,1].

While g(x) = x2 has domain all the real numbers and range R+

f∘ g(x) = f(g(x)) = f(x2) = sin(x2)

Domain is all real numbers, the range is [-1,1]

g∘ f(x) = g(f(x) = g(sinx) = sin2x

Domain is all real numbers, the range is between 0 and 1.

Example 4: For the given functions f(x) = log(x) and g(x) = x + 1. Find out the values of f(g(x)).

Solution:

Domain of f(x) is all positive numbers i.e R+ and range is all real numbers.

Domain and range for g(x) is all real numbers.

f(g(x)) = f(x+1) = log(x+1)

While doing this, the domain of f(x) must be kept in mind as it is logrethmic function it only takes positive values.

x + 1 > 0

x > -1

So,

• Domain is (-1, ∞)
• Range is all real numbers (R)

## FAQs on Composition of Functions

### Q1: What is a Composite Function?

When two functions f(x) and g(x) are combined to form a single function we called that a composite function. It is represented as f(g(x)) and g(f(x)).

### Q2: Define the composition of functions.

The composition of functions is a mathematical operation that combines two functions to create a new function.

### Q3: How do you find the Composition of Functions?

The composition of any function is found by solving the bracket in the order of BODMAS and then taking the output of the first function as the input of the second function.

### Q4: How to find the Domain of a Composite Function?

The domain of the composite function is the values we take as the input in the composite function it is the intersection of the domain of the inner function and the domain of the function formed after composing.