# Question about domain of composition of functions?

I am tutoring a student in precalculus and there was a question that I couldn't quite answer.

I know that the domain of $$f \circ g$$ is the domain of $$g$$, minus the points $$z$$ where $$g(z)$$ is not in the domain of $$f$$.

Now, in precalculus we often have functions such as $$f(x) = \dfrac {1}{x+2}$$ and $$g(x) = 1/x$$. According to what I said above, the domain for $$f \circ g$$ is $$\mathbb{R} - \{0, -\frac 12 \}$$. But if we just compute the formula for $$f\circ g$$ directly, we get $$\dfrac {x}{2x+1}$$. Now, this function also gives us the restriction $$x \not = -\frac 12$$.

So it seems that, we still have to start with the domain of $$g$$, but then instead of finding the points $$z$$ where $$g(z)$$ is not in the domain of $$f$$, it seems like we can directly compute $$f \circ g$$ and compute the domain directly from there (after simplification). In fact, my tutee's professor even told the students to write this "fact" down.

Is this really true, or can it fail? I really think it should fail in some cases, because I really don't see how you would ever prove it; "finding the domain of $$f \circ g$$ after simplification" is just a very ambiguous concept, so I can't even see where you would start to prove such a thing.

• This is a weird issue to begin with. Why would anyone start with formula and try to find domain for it? How is that useful? Plus what is a domain of $f(x)=x$? Reals? Complex numbers? Matrices? Something entirely different? In reality its the other way around: you start with domain and apply a valid formula to it. With this approach the problem is nonexistent. Jan 16, 2020 at 16:16
• @freakish I agree. However, professors often try to make things as easy as possible for the students, and I guess finding the domain of the composition formula is slightly easier that the other route. I think this seems to be a pretty common flaw in precalculus classes; I believe my teacher taught me the same way. Jan 16, 2020 at 16:54
• Yes, I do remember being taught the same way. But as you said: it's a flawed way. Jan 16, 2020 at 17:29

It is false that you can find the domain of $$f\circ g$$ after simplifying the expression. Here is an example: take $$g(x)=\sqrt{x}$$ and $$f(x)=x^2$$. The domain of $$f\circ g$$ is $$x\ge 0$$ but after simplification you get $$f\circ g(x)=x$$ and it might seem that the domain is $$\mathbb{R}$$ which is false. The whole point is that an expression is not a function. In order to specify a function you need a domain. The domain of the composition is by definition the set of points in the domain of $$g$$ such that $$g(x)$$ is in the domain of $$f$$ to be able to apply both functions sequentially.

Actually, the formula for $$f\circ g(x)$$ is not what you give. The formula is $$f\circ g(x) = f\Bigl(g(x)\Bigr) = f\left(\frac{1}{x}\right) = \frac{1}{\frac{1}{x}+2}.$$ For this formula to make sense, you need $$x\neq 0$$ and you need $$\frac{1}{x}\neq -2$$ (or $$x\neq -\frac{1}{2}$$); which gives the correct answer.

Why is that the formula? Because “$$f\circ g$$” means “do $$g$$ to $$x$$ first, then do $$f$$ to the result of that.” In this case, “do $$g$$ to $$x$$” means “take the reciprocal of $$x$$”. And “do $$f$$ to $$u$$” means “add two to $$u$$, then take the reciprocal.” so $$f\circ g(x)$$ means:

1. First take the reciprocal of $$x$$; then
2. Add two to that; and then
3. Take the reciprocal of that result.

And this corresponds to $$\frac{1}{\frac{1}{x}+2}$$ and not to $$\frac{x}{2x+1}$$.

This all comes from our convention that if we give a function by a formula, but do not specify its domain, then we mean the domain to be the “natural domain”: the set of all numbers for which the formula makes sense. When you “simplify” the formula, you may be removing restrictions and thus changing the domain. So you would need to do something like this: \begin{align*} f\circ g(x) &= \frac{1}{\frac{1}{x}+2}\\ &= \frac{1}{\quad\frac{1+2x}{x}\quad} &\text{(1)}\\ &= \frac{x}{1+2x}, \quad x\neq 0 &\text{(2)} \end{align*}

Notes:

1. This is fine, because the natural domain of both expressions are the same.

2. Here you need to include the restriction $$x\neq 0$$ in order to keep the domains the same.

Note that $$\frac{1}{\frac{1}{x}+2}$$ is not the same function as $$\frac{x}{1+2x}$$, precisely because they have different domains. Similarly, the function $$\frac{1}{\quad\frac{1}{x}\quad}$$ and the function $$x$$ are different, because they have different domains.

• Invalid simplifications like this are used in many math puzzles, like "proofs" that 1 == 0 Jan 16, 2020 at 16:49