# Composition of functions proofs

I would like some help with proving or disproving the next statements:

• If $f(x)$ and $g(x)$ are defined on the same domain $D$ than $f\circ g$ and $g\circ f$ are also defined on D.

I think this is not true but only if I can look on part of the domain. for example if $D$ is {$x\in \mathbb R| x\ne0$} and $f(x)=\frac{1}{x}$ $g(x)=\sin x$ than $f\circ g$ is not defined for every $n\pi$ for every natural n. but can it be false if you look at two functions with exactly the same domain?

• If $f(x)$ and $g(x)$ are defined for every $\mathbb R$ than $f\circ g$ and $g\circ f$ are also defined for every $\mathbb R$

I think this is true since for every $x$ I will input $f(x)$ is defined and for every $x$ I will input in $g(x)$ it will also be defined so also $f\circ g$ will be defined.

• If $f\circ g =g\circ f$ than $f(x) = g(x)$

I think this is false. for example: $f(x) = -x$ and $g(x)=x^3$

• If $f\circ f=g\circ g$ than $f(x)=g(x)$

I think this is false. for example $f(x)=\frac{1}{x}$ and $g(x)=\frac{2}{x}$

My main problem is I'm not sure how to approach proving the true statements.

Any help will be highly appreciated.

• "If $f(x)$ and $g(x)$ are defined on the same domain $D$ then $f\circ g$ and $g\circ f$ are also defined on $D$" What is important to functions is not only the domain but also the codomain. Take for example $f$ the function from words to natural numbers counting the number of letters in the word and $g$ the function from words to natural numbers counting the number of $a$'s in the word. E.g. $f(\text{apple})=5$ and $g(\text{apple})=1$. Now... what is $(f\circ g)(\text{apple})$? Similar problems can occur with $\Bbb R$ as the domain where the codomain is not a subset of $\Bbb R$. – JMoravitz Jul 6 '17 at 20:47
• Note that all four statements are false. (JMoravits and AJ Stas have both implied it but they haven't explicitly said it.) – Tanner Swett Jul 6 '17 at 21:47
• @TannerSwett why is the second one false? of g(x) gives any real value than $f\circ g$ gets a real value therefore it's true – segevp Jul 6 '17 at 22:22
• can you give a counter-example? – segevp Jul 6 '17 at 22:22
• Counter example: $g(x) = x^2 + 7$. $f(x) =$"babar, the elephant". $f(1) =$ "babar, the elephant". $f(\pi)=$"babar, the elephant". $g(f(x) ) = g($"babar the elephant"$)$ is undefined. For a less silly example. Let $f:\mathbb R \rightarrow \mathbb R\times \mathbb R$ via $f(x) = (-x, x^2)$ let $g(x) = x^2 + 7$. Then $f(2) = (-2, 4)$ and $g(f(2)) = g((-2,4))$ which isn't defined. g is defined to have only a real number input; not an ordered pair. – fleablood Jul 6 '17 at 23:29

If $f,g:\Bbb R\to\Bbb R$, then since $f(x),g(x)\in\Bbb R$ for all $x\in\Bbb R$, we have that $f(g(x))$ and $g(f(x))$ are defined for all $x\in\Bbb R$.
This is, in general, not true if $f$ and $g$ do not have the same codomain.
• Wait, why would that not be true if the have different codomains. The codomains are still subsets of R and thus subsets of the domains of the other. For any $x \in \mathbb R$ then $f(x) \in \mathbb R$ is defined. And as for every $y \in \mathbb R$ then $g(y) \in \mathbb R$ is defined. So $g(f(x))$ is defined. Surely the statement is true? – fleablood Jul 6 '17 at 22:59