Composition of functions and invertible functions

NCERT Class 12 Mathematics Chapter 1 Section 1.4

Quick answer

The composition gof of f : A → B and g : B → C is the function from A to C with gof(x) = g(f(x)): f acts first and then g, and in general gof and fog are different. A function f : X → Y is invertible if some g : Y → X undoes it, so that gof is the identity on X and fog the identity on Y; this g is the inverse f. A function is invertible exactly when it is one-one and onto.

With your textbook

NCERT Mathematics Part I (Class 12), Chapter 1 “Relations and Functions”, Section 1.4 “Composition of Functions and Invertible Function”, pages 12–13.

Open the official NCERT chapter (PDF, 1.4 MB, ncert.nic.in) (opens in a new tab)

Checked against the 2026-27 reprint on .

What is the composition of two functions?

Composition of functions

Let f : A → B and g : B → C be two functions. Then the composition of f and g, denoted by gof, is defined as the function gof : A → C given by gof(x) = g(f(x)), ∀ x ∈ A.

NCERT Mathematics Part I (Class 12), Section 1.4, page 12

  • Read gof as “g of f”. Many books write it g ∘ f.
  • In gof the function written last, f, acts first.

In plain words: to find gof(x), feed x to f, then feed the answer f(x) to g. This needs every output of f to be an input that g accepts, which is why the codomain B of f is the domain of g. gof goes straight from A to C, skipping B. More generally it is enough that the range of f lies inside the domain of g; the two named sets need not be identical.

Arrow diagrams of NCERT Example 15: f takes 2, 3, 4, 5 to 3, 4, 5, 5 and g takes 3, 4, 5, 9 to 7, 7, 11, 11; below, gof takes 2 and 3 to 7, and 4 and 5 to 11.
Top: f and then g for the sets of NCERT Example 15. Bottom: the composite gof joins each start to its end in one step; 15 in C is not reached. After NCERT Fig 1.5 (page 12), drawn with the numbers of Example 15.

Domains of real composites (JEE). Beyond the NCERT text, for real functions given by formulas gof(x) is defined only where f(x) is defined and f(x) lies in the domain of g. For f(x) = x − 4 and g(x) = √x, gof(x) = √(x − 4) needs x ≥ 4, while fog(x) = √x − 4 needs only x ≥ 0.

gof and fog are usually different

NCERT Example 16 (page 12): f(x) = cos x and g(x) = 3x2 on R.

  • gof(x) = g(cos x) = 3 cos2 x;
  • fog(x) = f(3x2) = cos 3x2.

At x = 0 the first is 3 and the second is cos 0 = 1, so gof ≠ fog. One value is enough to show that two functions differ.

Sometimes only one order makes sense. In NCERT Example 15, g ends in {7, 11, 15}, and none of these is in the domain {2, 3, 4, 5} of f, so fog is not defined at all.

Beyond the NCERT text, three facts reasoned from the definitions:

  • composition is associative: ho(gof) and (hog)of both send x to h(g(f(x)));
  • if f and g are both one-one, so is gof; if both are onto, so is gof;
  • the converses hold only halfway: if gof is one-one then f is one-one, and if gof is onto then g is onto, but g need not be one-one nor f onto (f : {1} → {1, 2}, f(1) = 1, and g : {1, 2} → {1} give a bijection gof).

Invertible functions

NCERT Definition 9 (page 12): a function f : X → Y is invertible if there is a function g : Y → X such that gof = IX and fog = IY, where IX(x) = x is the identity function of X. This g is the inverse of f, written f−1. So f−1 undoes f, and f undoes f−1:

Inverse of a function

f(f(x)) = x, for every x ∈ X

f(f(y)) = y, for every y ∈ Y

Thus, if f is invertible, then f must be one-one and onto and conversely, if f is one-one and onto, then f must be invertible.

NCERT Mathematics Part I (Class 12), Section 1.4, page 12

NCERT states this without proof. The reason, reasoned from Definition 9:

  • Invertible ⇒ one-one and onto. If f(x) = f(x), apply g to both sides: x = g(f(x)) = g(f(x)) = x. And any y ∈ Y equals f(g(y)), so it is an image.
  • One-one and onto ⇒ invertible. Onto gives each y at least one x with f(x) = y, and one-one makes that x unique. Let g(y) be this x. Then f(g(y)) = y by the choice of g(y), and g(f(x)) = x because x is the only element with image f(x). So gof = IX and fog = IY.

So the one-one and onto tests decide invertibility, often without finding the inverse, as NCERT notes on page 12.

Finding the inverse. Check that f is one-one and onto, write y = f(x), solve for x, and name the result f−1(y). Then check that f−1(f(x)) = x and f(f−1(y)) = y.

The graph of the inverse. (a, b) is on the graph of f exactly when (b, a) is on the graph of f−1, so the two graphs are mirror images in the line y = x (NCERT states this in Chapter 2, pages 19–20).

The line y = 3x − 5 and its inverse y = (x + 5)/3, mirror images in the dashed line y = x; the point (3, 4) on the first matches the point (4, 3) on the second.
The graph of f(x) = 3x − 5 and of its inverse, from Example 4 below, reflected in the line y = x: f(3) = 4, so f−1(4) = 3.

Two more facts (JEE). Beyond the NCERT text, and following from the definition: (f−1)−1 = f, and if f and g are invertible, then (gof)−1 = f−1og−1: to undo “f, then g”, undo g first.

Solved examples

Example 1: A composite on finite sets (NCERT Example 15, page 12)

f : {2, 3, 4, 5} → {3, 4, 5, 9} and g : {3, 4, 5, 9} → {7, 11, 15} are given by f(2) = 3, f(3) = 4, f(4) = f(5) = 5, g(3) = g(4) = 7 and g(5) = g(9) = 11. Find gof.

Apply f, then g: gof(2) = g(3) = 7, gof(3) = g(4) = 7, gof(4) = g(5) = 11 and gof(5) = g(5) = 11.

Answer: gof = {(2, 7), (3, 7), (4, 11), (5, 11)}.

Example 2: gof against fog (NCERT Example 16, page 12)

f(x) = cos x and g(x) = 3x2 on R. Find gof and fog, and show that gof ≠ fog.

gof(x) = g(f(x)) = 3(cos x)2, and fog(x) = f(g(x)) = cos(3x2). At x = 0: 3 cos2 0 = 3 but cos 0 = 1.

Answer: gof(x) = 3 cos2 x and fog(x) = cos 3x2; they differ at x = 0.

Example 3: An inverse with a restricted codomain (NCERT Example 17, pages 12–13)

f : N → Y, f(x) = 4x + 3, where Y = {y ∈ N : y = 4x + 3 for some x ∈ N}. Show that f is invertible and find its inverse.

Every y in Y is 4x + 3 for some x ∈ N, so x = (y − 3)/4. Define g : Y → N by g(y) = (y − 3)/4. Then

gof(x) = (4x + 3 − 3)/4 = x,

fog(y) = 4(y − 3)/4 + 3 = y.

So gof = IN and fog = IY.

Answer: f is invertible and f−1(y) = (y − 3)/4. Y = {7, 11, 15, …} is the range of f; as a function into all of N, f would not be onto (1 is never 4x + 3), and so not invertible.

Example 4: Inverse of a linear function

Show that f : R → R, f(x) = 3x − 5, is invertible, find f−1 and evaluate f−1(4).

3x − 5 = 3x − 5 gives x = x, so f is one-one. From y = 3x − 5, x = (y + 5)/3, a real number for every real y, so f is onto. Check: f((y + 5)/3) = (y + 5) − 5 = y.

Answer: f−1(y) = (y + 5)/3, and f−1(4) = 9/3 = 3, since f(3) = 4.

Example 5: Inverse of a rational function

f : R − {3} → R − {2}, f(x) = (2x + 1)/(x − 3). Find f−1.

Put y = (2x + 1)/(x − 3). Then y(x − 3) = 2x + 1, so xy − 2x = 3y + 1 and

x = (3y + 1)/(y − 2).

This is defined for every y ≠ 2, and it is never 3, because (3y + 1)/(y − 2) = 3 would need 1 = −6. So f is onto R − {2}, and since each y gives only one x, it is one-one.

Answer: f−1(y) = (3y + 1)/(y − 2), for y ≠ 2. Check: f(4) = 9/1 = 9 and f−1(9) = 28/7 = 4.

Common mistakes to avoid

Common mistake

Applying the functions in the wrong order

gof means f first, then g. With f(x) = 2x + 3 and g(x) = x2, gof(1) = g(5) = 25, while fog(1) = f(1) = 5.

Common mistake

Reading f(x) as 1/f(x)

For f(x) = 3x − 5, f−1(4) = 3, but 1/f(4) = 1/7. The −1 means “inverse function”, not “reciprocal”.

Common mistake

Inverting a function that is not one-one

f(x) = x2 on R has no inverse: f(2) = f(−2) = 4, so “f−1(4)” would need two values. On [0, ∞) to [0, ∞) it is one-one and onto, and f−1(y) = √y.

Common mistake

Forgetting the codomain

f(x) = 4x + 3 from N to N is not invertible, because it is not onto. It becomes invertible only when the codomain is cut down to its range Y, as in NCERT Example 17.

Quick revision summary

  • Composition: gof(x) = g(f(x)), defined when the outputs of f are inputs of g; f acts first.
  • Order matters: in general gof ≠ fog, and one of them may not even be defined.
  • f : X → Y is invertible when some g : Y → X has gof = IX and fog = IY; that g is f−1.
  • f is invertible exactly when it is one-one and onto. To find f−1, solve y = f(x) for x.

Formula sheet

  • gof(x) = g(f(x)), for x ∈ A
  • gof ≠ fog in general
  • f invertible: some g : Y → X has gof = IX and fog = IY; g = f−1
  • f invertible ⇔ f one-one and onto
  • f−1(f(x)) = x and f(f−1(y)) = y
  • (gof)−1 = f−1og−1

Questions students ask

Can gof and fog ever be equal?

Yes, gof and fog are equal for some pairs of functions f, g : X → X, even though they differ in general. Two translations always commute, as f(x) = x + 4 and g(x) = x − 6 give x − 2 in both orders, and so do a bijection f : X → X and its inverse, since f−1of and fof−1 are both IX. For linear functions the condition can be solved: with f(x) = 3x + 1 and g(x) = 7x + k, fog(x) = 21x + 3k + 1 and gof(x) = 21x + 7 + k, which agree for every x only when k = 3. Commuting does not make f and g inverses: x + 4 and x − 6 commute, yet neither undoes the other.

Is the inverse of a function the same as its inverse relation?

Every function f : X → Y has an inverse relation, its pairs reversed as for any relation, but that relation is the inverse function f−1 only when f is one-one and onto. Reversing f = {(1, 10), (2, 10), (3, 20)} from {1, 2, 3} to {10, 20, 30} gives {(10, 1), (10, 2), (20, 3)}, which is not a function from {10, 20, 30} to {1, 2, 3}: 10 has two images because f is not one-one, and 30 has none because f is not onto. When f is one-one and onto, each y in Y is paired with exactly one x, and the reversed relation is f−1, with f−1(y) = x exactly when f(x) = y.

How do you find the inverse of a quadratic function?

A quadratic function is never one-one on all of R, as its graph is symmetric about the vertical line through its vertex, so a usual way to make it invertible is to restrict its domain to an interval on one side of the vertex and its codomain to the resulting range. More generally, any restriction that keeps at most one input for each output is one-one. For f(x) = x2 − 6x + 10 = (x − 3)2 + 1, take f : [3, ∞) → [1, ∞); solving y = (x − 3)2 + 1 with x ≥ 3 gives f−1(y) = 3 + √(y − 1), so f−1(2) = 4. For f : (−∞, 3] → [1, ∞) the inverse is 3 − √(y − 1). Inverse trigonometric functions are made the same way, by restricting the domain.

What is the difference between an invertible function and an inverse function?

“Invertible” is a property of a function f : X → Y, that some g : Y → X has gof = IX and fog = IY, while “the inverse” is that function g itself, written f−1; only an invertible function has an inverse. For f(x) = 7 − 2x on R, f is invertible because it is one-one and onto, and its inverse is f−1(y) = (7 − y)/2, so f(5) = −3 and f−1(−3) = 5. The inverse is invertible too, with inverse f, and it is unique: if g and h both have this property, then g = go(foh) = (gof)oh = IXoh = h.

Are composition of functions and inverse functions in the JEE Main 2027 syllabus?

Yes, composition of functions and inverse functions are both in the JEE Main 2027 syllabus: Unit 1, Sets, Relations and Functions, ends with “one-one, into and onto functions, the composition of functions”, and Unit 7, Limit, Continuity and Differentiability, lists “inverse functions” among its real-valued functions. Unit 7 also covers the differentiation of “composite and implicit functions” and of inverse trigonometric functions, which build on gof and f−1. Both ideas are taught in NCERT Mathematics Part I (Class 12), Chapter 1, Section 1.4 (pages 12–13).

Practice questions

Try each question first, then open the answer to check your working.

  1. Q1. f(x) = x + 2 and g(x) = 3x on R. Find gof(x), fog(x) and gof(1).

    Show answerHide answer

    gof(x) = 3(x + 2) = 3x + 6 and fog(x) = 3x + 2. gof(1) = 9, while fog(1) = 5.

  2. Q2. f : {1, 2, 3} → {5, 6, 7} has f(1) = 6, f(2) = 7, f(3) = 5, and g : {5, 6, 7} → {0, 1} has g(5) = 0, g(6) = 1, g(7) = 1. Find gof. Is fog defined?

    Show answerHide answer

    gof(1) = g(6) = 1, gof(2) = g(7) = 1 and gof(3) = g(5) = 0, so gof = {(1, 1), (2, 1), (3, 0)}. fog is not defined on the whole domain {5, 6, 7} of g: g(5) = 0 is not in the domain of f. A restricted composite on {6, 7} is possible, with both values equal to f(1) = 6.

  3. Q3. Show that f : R → R, f(x) = 5x + 2, is invertible and find f−1.

    Show answerHide answer

    5x + 2 = 5x + 2 gives x = x; and y = 5x + 2 gives x = (y − 2)/5 for every real y. So f is one-one and onto, and f−1(y) = (y − 2)/5. Check: f((y − 2)/5) = y − 2 + 2 = y.

  4. Q4. Is f : N → N, f(x) = x + 1, invertible? What if the codomain is {2, 3, 4, …}?

    Show answerHide answer

    Into N it is one-one but not onto (1 is never x + 1), so it is not invertible. Into {2, 3, 4, …} it is also onto, and f−1(y) = y − 1.

More practice questions

Sources and review

Written by
TopicLamp Editorial Team.
Checked by
TopicLamp Review Team.
NCERT source
NCERT, Mathematics Part I (Class 12), reprint 2026-27. Chapter 1 “Relations and Functions”, Section 1.4 “Composition of Functions and Invertible Function”, pages 12–13. Checked on . Official chapter PDF on ncert.nic.in (opens in a new tab) (1.4 MB).
Dates
First published Checked and updated
Corrections
  • : OpenAI Codex content review: checked proofs, counterexamples, domains and counts; corrected model assumptions, empty-set counting and inverse/composition scope.

Report a mistake on this page How pages are written, reviewed and corrected

Topics in Relations and Functions (Class 12)

  1. Types of relations

    NCERT Sections 1.1–1.2 21 min read

  2. Types of functions

    NCERT Section 1.3 19 min read

  3. Composition of functions and invertible functions

    NCERT Section 1.4 You are reading this topic