Why codomain is more than the range in an Inverse function

While solving inverse function problems, I got confused in a part, like for any Inverse function to be defined, it must be one-one and onto, then in many questions why the codomain is given more than the Range as if we know that the codomain must needs to be equivalent to the Range for the Inverse function to be valid or defined, then why does they gave us the codomain different from the range?

Kindly help me solving this doubt.

• The codomain defines the set of possible values a function may take while the range of a function defines the actual values a function takes. The range of a function is too restrictive. For example, we often want to speak of "domain shaped" objects within a space represented by a codomain of a function. This gives us greater insights into the structure of the codomain by viewing its components which may be equivalent to simpler structures. Commented Jul 9, 2023 at 21:17

It is a matter of definition only. In some books invertible functions have to be one to one and onto, so if $$f\colon A\to B$$, then $$f^{-1}\colon B\to A$$. But in some references the function only has to be one to one. and the inverse function is defined on the range of the original function.