# The notion of equality when considering composition of functions

When going through some (very introductory) calculus homework I was given the function $f(x) = \frac{x}{1+x}$ and asked to find the composition $(f\circ f)(x)$ and then find its domain. Substituting, we find that $$(f\circ f)(x)= \frac{\frac{x}{1+x}}{1+\frac{x}{1+x}}$$ The domain is then found by solving $\frac{x}{1+x} = -1$ and to find that the composition is undefined at $-\frac{1}{2}$. It is also, of course, undefined at $-1$. Thus our domain is $\{x \in \mathbb{R} \mid x \neq -\frac{1}{2}$ and $x \neq -1$}. My question comes from noticing that if we take the algebra further we find that $$(f\circ f)(x)= \frac{\frac{x}{1+x}}{1+\frac{x}{1+x}} = \frac{x}{2x+1}$$ The domain is still surely unchanged. However, suppose I never did this problem and for some reason I simply desired to write down the function $\frac{x}{2x+1}$ on a sheet of paper and find its domain. I would find that it is defined for all reals except $-\frac{1}{2}$. (Wolfram alpha also verifies this). This would then imply that $$(f\circ f)(x)= \frac{\frac{x}{1+x}}{1+\frac{x}{1+x}} \neq \frac{x}{2x+1}$$ since the domain of the two functions is unequal. Couldn't we also work backwards from $\frac{x}{2x+1}$ in the following manner? $$\frac{x}{2x+1} = \frac{\frac{x}{1+x}}{\frac{1+2x}{1+x}} = \frac{\frac{x}{1+x}}{\frac{1+x}{1+x} + \frac{x}{1+x}} = \frac{\frac{x}{1+x}}{1 + \frac{x}{1+x}}$$ This is the function we orignally found the domain for. Did I some how just remove a point from the domain by just doing algebraic manipulations?

My guess is perhaps there are two (or more?) notions of equality going on here. One notion would perhaps be the idea of two functions $f$ and $g$ being "formally" equivalent if $f$ can be algebraically manipulated to $g$ and vice versa. The other notion would be the more intuitive one where two functions are equal if they have the same domain and map the elements of the domain to the same points in the codomain.

Thanks.

• Yeah, $x/x$ isn't the same thing as $1$. – Serge Seredenko Jan 19 '17 at 20:16
• – Wildcard Jan 19 '17 at 23:59
• Your function $f \circ f$ has a removable singularity at $-1$. – Ilmari Karonen Jan 20 '17 at 6:56

## 3 Answers

Note that the notation $(f\circ f)(x)$ gives some intuitive notion that we are going to do $2$ different operations. The first will be to "feed" $x$ to $f$, and then "feed" $f(x)$ to $f$. Indeed we have $(f\circ f)(x) = f(f(x))$. We know that $f$ is not defined for $x = -1$ and therefore the inner $f$ in $f(f(x))$ cannot be "fed" $-1$. However, the outer $f$ is fed values from $f(x)$ and it just so happens that $f(x) = -1 \iff x = -\frac12$.

We can then proceed to write the algebraic manipulations you wrote assuming that $1+x \not= 0, \frac{x}{1+x} \not= -1$ given that otherwise you would be dividing by $0$.

On the other hand, starting from $\frac{1}{2x+1}$ one cannot write $$\frac{\frac{x}{1+x}}{\frac{1+2x}{1+x}}$$ if we don't explicitly state that $1+x\not=0$, otherwise you would be dividing by $0$. Therefore one can always do the algebraic manipulations, given that one carries the excluded points along.

Therefore, one finds $f(f(x))$ to be defined for $x\not\in \{-\frac12, -1\}$ and for the points where it is defined we have $f(f(x)) = \frac{1}{2x+1}$. Similarly, working backwards like you did, we get

$$\frac{\frac{x}{1+x}}{\frac{1+2x}{1+x}} = \frac{\frac{x}{1+x}}{1 + \frac{x}{1+x}}$$

except for the points $x = -\frac12, -1$ because we had to exclude them.

What is more, you are right when you say that two functions are equal if they have the same domain/codomain and if they map the same objects to the same images. Having that in mind, the functions $f(f(x))$ and $\frac1{2x+1}$ are not the same function, unless you restrict the second one to the points where we know $f(f(x))$ is well-defined.

• Well worded, clear and concise. Deserves my +1 – Simply Beautiful Art Jan 19 '17 at 18:50
• "Therefore one can always do the algebraic manipulations, given that one carries the excluded points along." Nicely phrased. – Wildcard Jan 20 '17 at 0:19

Essentially, the only time you may multiply the fraction by $\frac{x+1}{x+1}$ is if $x\ne-1$, or else you'd be multiplying by $\frac00$, which doesn't make sense in this context.

It is, however, an applicable standard technique in calculus to evaluate the limit as $x\to1:$

$$\underbrace{\lim_{x\to-1}\frac{\frac x{1+x}}{1+\frac x{1+x}}=\lim_{x\to-1}\frac x{2x+1}}_{\text{the expressions under the limit are equal for any x\in \mathbb{R} \smallsetminus \{-1,-\frac12\}}}=1$$

To put this into words, $(f\circ f)(x)$ approaches $1$ as $x$ approaches $-1$. The approach is to algebraically remove any $1/(x+1)$ by multiplying everything through by $(x+1)$, which is what you did.

• Minor typo: in your first sentence you mean to have -1 rather than 1. Likewise the second sentence, describing the limit. – Chris Hayes Jan 19 '17 at 20:46
• @ChrisHayes thanks for the catch! – Simply Beautiful Art Jan 19 '17 at 21:31

Have you studied set theory? One defines there a composition of two functions $f \colon A \to B$ and $g \colon B \to C$ as a function $g \circ f \colon A \to C$. In your case, the domain of $x / (1 + x)$ is $\mathbb R \setminus \{-1 \}$, but the codomain is $\mathbb R \setminus \{1\}$, so you can't compose $f$ with itself.

What have you done unconsciously here is a restriction of both domain and codomain. You should restrict them at least to $\mathbb R \setminus \{1, -1\}$, in order to be able to compose the functions.

Additionaly you must remove $-1/2$ from your domain, otherwise you will divide by zero when calculating $f(f(-1/2))$.

• The codomain of $f$ is $\Bbb R$. It is the image of $f$ that is $\Bbb R \setminus \{1\}$. Please don't mix these concepts up. It was mixing them up that has led to range being no longer a useful terminology. And there is no reason to remove $1$ from the domain. $f\circ f(1) = \frac 13$. – Paul Sinclair Jan 19 '17 at 20:40