1. ## Functions of functions

its easy to plug a function into a function, we did that in algebra.
f(x)=x^2 g(x) = (x+2) fog(x)= x^2+4x+4

but how about going the other way
if fog(x)= 3x^2+2x+8 and g(x) = (x^2+4x), what is f(x)?

I never learned this in precalc or algebra, which branch or course deals with this topic? What is the process for solving these kind of problems?

2. Try expressing $\displaystyle f\circ g(x)$ in terms of $\displaystyle g(x)$.

$\displaystyle g(x)=x^2+4x\implies g(x)=(x+2)^2-4\implies x=-2+\sqrt{g(x)+4}$ or $\displaystyle x=-2-\sqrt{g(x)+4}$

$\displaystyle \therefore f(g(x))=3(-2+\sqrt{g(x)+4})^2+2(-2+\sqrt{g(x)+4})+8$ or $\displaystyle 3(-2-\sqrt{g(x)+4})^2+2(-2-\sqrt{g(x)+4})+8$

$\displaystyle \therefore f(x)=3(-2+\sqrt{x+4})^2+2(-2+\sqrt{x+4})+8$ or $\displaystyle 3(-2-\sqrt{x+4})^2+2(-2-\sqrt{x+4})+8$

3. Be careful here! You get two different functions $\displaystyle f(x)$ depending on what domain you choose for $\displaystyle g(x)$.

$\displaystyle g(x)+4=(x+2)^2$ $\displaystyle \Rightarrow$ $\displaystyle \sqrt{g(x)+4}=\begin{cases}x+2 & x\ge-2\\ -x-2 & x\le-2\end{cases}\ \Rightarrow\ x=\begin{cases}-2+\sqrt{g(x)+4} & x\ge-2\\ -2-\sqrt{g(x)+4} & x\le-2\end{cases}$

If you choose $\displaystyle [-2,\infty)$ as your domain for $\displaystyle g(x)$, then $\displaystyle f((g(x))=3\left(-2+\sqrt{g(x)+4}\right)^2+2\left(-2+\sqrt{g(x)+4}\right)+8$ and so $\displaystyle f(x)=3\left(-2+\sqrt{x+4}\right)^2+2\left(-2+\sqrt{x+4}\right)+8$.

If you choose $\displaystyle (-\infty,-2]$ as your domain for $\displaystyle g(x)$, then $\displaystyle f((g(x))=3\left(-2-\sqrt{g(x)+4}\right)^2+2\left(-2-\sqrt{g(x)+4}\right)+8$ $\displaystyle \Rightarrow$ $\displaystyle f(x)=3\left(-2-\sqrt{x+4}\right)^2+2\left(-2-\sqrt{x+4}\right)+8$.

(In both cases, the domain of $\displaystyle f(x)$ is $\displaystyle [-4,\infty)$.)

However, if you choose $\displaystyle \mathbb{R}$ as your domain for $\displaystyle g(x)$, then, unfortunately, it will be impossible to determine $\displaystyle f(x)$ as a function. ($\displaystyle f(x)$ would be a one-to-many relation and therefore not a function.)