What is f(g(x)) ang g(f(x))

539 Views Asked by At

Let $f: \mathbb{N}^2 \to \mathbb{Z}$ via $f(n, m) = n-m$ and let $g: \mathbb{Z} \to \mathbb{R}$ via $g(x) = \sqrt{|x|}$

$g \circ f$ is defined since $g \circ f : \mathbb{N}^2 \to \mathbb{R}$

$$\implies g(f(n,m)) = g(n-m) = \sqrt{n-m}$$

I don't get why $ f \circ g$ is not defined?

2

There are 2 best solutions below

2
On BEST ANSWER

The codomain of $g$ is $\mathbb{R}$, while the domain of $f$ is $\mathbb{N}^2$, thus $g$ doesn't output the kinds of things that $f$ requires as input. Hence the composition is not defined.

Edited to Elaborate: When we say that $f : \mathbb{N}^2 \to \mathbb{Z}$, we are declaring that $f$ is a function that eats pairs of natural numbers, and spits out integers. If we try to feed $f$ with something that is not a pair of natural numbers, then $f$ chokes.

Next, note that $g : \mathbb{Z}\to \mathbb{R}$. This means that $g$ eats integers, and spits out real numbers. When we compose $g$ with $f$, i.e. when we try to define $g\circ f$, there is no problem. $f$ outputs integers, and $g$ eats them up. Groovy.

On the other hand, when we try to compose in the other way, i.e. to define $f\circ g$, $g$ outputs real numbers, and $f$, which is expecting pairs of natural numbers, chokes. It can't handle what $g$ spits out, so the composition is nonsense.

0
On

The functions can be composed one way as there is no break in the chain $\mathbb{N}^2\rightarrow \mathbb{Z}\rightarrow \mathbb{R}$ However $\mathbb{Z} \rightarrow \mathbb{R}\rightarrow\mathbb{N}^2$ requires a mapping that the functions can't perform.

More specifically as the integers are only a subset of the real numbers then it is possible that you wish to input a real number when only integers are permitted. This wouldn't be so much of a problem the other way around.