I try to make an algorithm that decomposes a polynomial, ie find $f(x)$ such that $h(x) = f(g(x))$ by knowing $h$ and $g$.
For example, having : $h(x) = 112x^6 + 1232x^5 + 2772x^4 - 3388x^3 + 847x^2 + 12$ and $g(x) = 4x^3 + 22x^2 - 11 x$ how to find $f$ ?
(for this example $f(x) = 7x^2+12$).
If
$$f(x) = \sum_{n} a_n x^n $$
then
$$ f(g(x)) = \sum_{n} a_n g(x)^n $$
so you just set the coefficients on $x$ equal in the equation
$$ h(x) = \sum_{n} a_n g(x)^n $$
and solve for the $a_n$. (hint: start with the highest degree terms)