# MAT 101: Combining Functions

It’s quite interesting that functions can be treated like numbers, namely you can define $+$, $-$, $\times$, and $\div$ on a collection of functions. How do we do this? For instance given two functions $f$ and $g$, we can define a new function $f+g$ by
$$(f+g)(x)=f(x)+g(x)$$
for all $x$ in the domain (for sake of simplicity we assume that $f$ and $g$ both have the same domain. If not, one can take the intersection of the domains of $f$ and $g$, no big deal). In a similar manner, we can also define $f-g$, $fg$, and $\frac{f}{g}$ respectively as
\begin{align*}
(f-g)(x)&=f(x)-g(x)\\
(fg)(x)&=f(x)g(x)\\
\left(\frac{f}{g}\right)(x)&=\frac{f(x)}{g(x)}\ \mbox{provided}\ g(x)\ne 0
\end{align*}

Example. Let $f(x)=\frac{1}{x-2}$ and $g(x)=\sqrt{x}$.

(a) Find the functions $f+g$, $f-g$, $fg$ and $\frac{f}{g}$ and their domains.

(b) Find $(f+g)(4)$, $(f-g)(4)$, $(fg)(4)$, $\left(\frac{f}{g}\right)(4)$

Solution. (a) $\mathrm{Dom}(f)=\{x|x\ne 2\}$ and $\mathrm{Dom}(g)=\{x|x\geq 0\}$. So the intersection is $\{x|0\leq x<2\}\cup\{x|x>2\}=[0,2)\cup(2,\infty)$ and this is the domain of $f+g$, $f-g$ and $fg$. For $\frac{f}{g}$ since $g$ is not defined at $x=0$, its domain should be $(0,2)\cup(2,\infty)$.
\begin{align*}
(f+g)(x)&=\frac{1}{x-2}+\sqrt{x}\\
(f-g)(x)&=\frac{1}{x-2}-\sqrt{x}\\
(fg)(x)&=\frac{\sqrt{x}}{x-2}\\
\left(\frac{f}{g}\right)(x)&=\frac{1}{(x-2)\sqrt{x}}
\end{align*}

(b) I will do only $(f+g)(4)$. One way to evaluate $(f+g)(4)$ is to use $(f+g)(x)$ we obtained in part (a) i.e. $(f+g)(4)=\frac{1}{4-2}+\sqrt{4}=\frac{5}{2}$. Another way is evaluating $f(4)$ and $g(4)$ first which are $f(4)=\frac{1}{2}$ and $g(4)=2$. Then $(f+g)(4)=f(4)+g(4)=\frac{5}{2}$.

Composite Functions

Given two functions $f$ and $g$, if the range of $f$ is a subset of the domain of $g$, then we can combine the two functions to create a new function which we will denote by $g\circ f$.
$$x\stackrel{f}{\longmapsto} f(x)\stackrel{g}{\longmapsto} g(f(x))$$
The above diagram hints us that we can define a new function $g\circ f$ by
$$(g\circ f)(x)=g(f(x))$$
We call $g\circ f$ “$f$ followed by $g$.”

Example. Let $f(x)=x^2$ and $g(x)=x-3$.

(a) Find composite functions $f\circ g$ and $g\circ f$ and their domains.

(b) Find $(f\circ g)(5)$ and $(g\circ f)(5)$.

Solution. (a) By definition $(f\circ g)(x)=f(g(x))=f(x-3)=(x-3)^2$. Also by definition $(g\circ f)(x)=g(f(x))=g(x^2)=x^2-3$. From these we can clearly see both their domains are $(-\infty,\infty)$. In general $\mathrm{Dom}(f\circ g)=\mathrm{Dom}(g)$ and $\mathrm{Dom}(g\circ f)=\mathrm{Dom}(f)$.

(b) $(f\circ g)(5)$ can be evaluated using $(f\circ g)(x)$ we obtained in part (a).
$$(f\circ g)(5)=(5-3)^2=4$$
There is another way to do this. If you don’t have to find $(f\circ g)(x)$ but only need to calculate $(f\circ g)(5)$, this may be simpler. First note $(f\circ g)(5)=f(g(5))$. $g(5)=5-3=2$, so $f(g(5))=f(2)=2^2=4$. Similarly we find $(g\circ f)(5)=22$. In general $(f\circ g)(x)\ne (g\circ f)(x)$.

This site uses Akismet to reduce spam. Learn how your comment data is processed.