Table of contents
1.
Introduction
2.
Example
3.
Properties of inverse functions
4.
How to find the inverse of a function?
5.
FAQs
6.
Key Takeaways
Last Updated: Mar 27, 2024
Easy

Inverse functions

Author Shreya Deep
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

A function in layman's English language denotes an activity. While in programming, it is a chunk of code that we write which performs some operations. You must have studied it in your high school that a function f(x) is said to be the inverse of another function g(x) when the input of g(x) is the output of f(x) with g(x) as it’s input. Mathematically, if g(x) = y, then f(y) = x. 

Example

Let, f(x) = 5x+2 and g(y) = (y-2)/5. Then, we can clearly see that, if x = 2, then f(x) = 12. Now, if we calculate g(12), we can see that, g(12) = (12-2)/5 = 2, which was the input of f(x). 

Properties of inverse functions

The properties of inverse functions are:

  • Inverse functions are one to one. The functions in which no two different inputs produce the same output value are called one-to-one functions. Thus, for inverse functions, f(x), f(x1) is never equal to f(x2). 
     
  • The domain of a function is a set of values that the function can accept as input, and the co-domain of a function is a set of values in which all the output values of the function lie. In a pair of inverse functions, f(x) and g(x), the domain of f(x) is the co-domain of g(x). This is obvious as we know that, the input of f(x) is the output of g(x). 
     
  • The graph of f(x) and g(x) are mirror images of each other.
    For example: if we have function f(x) = x2, then it’s inverse will be g(x) = square root(x). The graphs of these functions are:
     

               source

As you can see, these graphs are mirror images of each other.

Note: There is one very common misconception about inverse functions that inverse of f(x) = 1/f(x). Remember that this is not true. 

How to find the inverse of a function?

Given a function f(x), the steps to find its inverse are:

  • Let f(x) = y and therefore, replace f(x) with y. 
     
  • Replace all x with y and all y with x.
     
  • Solve the equation for y.
     
  • Now, the equation for y is the inverse of f(x).
     

Let’s understand the above steps through an example.

Suppose we have f(x) = 5x+2. 

  • Step1: Let f(x) = y, and replace f(x) with y. Thus, y = 5x+2.
     
  • Step2: Replace all x with y. Thus, 5y+2 = x.
     
  • Step3: Solve the equation formed, for y. 5y+2 = x => y = (x-2)/5.
     
  • Step4: Thus, inverse of f(x) = (x-2)/5.

FAQs

  1. What is a function?
    A function is a set of all statements put together to perform a selected task. It could be statements doing some repeated duties or statements doing a little specialty task like printing etc.
     
  2. When is a function g(x) called the inverse of another function f(x)?
    If g(f(x)) = x, then, g(x) is called the inverse function of the function f(x).
     
  3. What is a one-to-one function?
    A function in which no two different inputs produce the same output is called a one-to-one function.
     
  4. What is the domain of a function?
    The domain of a function is a set of values that the function can accept as input.
     
  5. What is the co-domain of a function?
    The co-domain of a function is a set of values in which all the output values of the function lie.

Key Takeaways

In this article, we discussed the inverse functions along with their properties. We hope that you gained a better understanding of what these are and how to find the inverse function. If you would like to learn more, check out our articles on Library. Do upvote our blog to help other ninjas grow. 

Recommended Readings:

Are you planning to ace the interviews of reputed product-based companies like Amazon, Google, Microsoft, and more? 

Attempt our Online Mock Test Series on Coding Ninjas Studio now!

Happy coding!

Live masterclass