Let $f(x)=x^6-2x^3-8$ and $g(x)=x^2+2x+4$. Let $a_1$ through $a_6$ be its roots. Find the value of $\prod_{n=1}^{6} (g(a_n))$ Question:

Let $f(x)=x^6-2x^3-8$ and $g(x)=x^2+2x+4$. Let $a_1$ through $a_6$ be its roots. Find the value of $\displaystyle \prod_{n=1}^{6} (g(a_n))$

My process:
I first thought of setting $z=a_i^2+2a_i+4$ and then putting the value back into $f(z)$ and then from there finding the product using Vieta's. But the process turned incredibly long and tedious and I found it to be impossible to do by hand.
So I just went to to the brute force method, expanding the whole expression out. Writing all the terms would be really tedious so I would like to abbreviate it. Let $P= a_1 \cdot a_2 \cdots \cdot a_6$ and let $e_n$ denote the sum of roots taken $n$ at a time.
Here is the expression I got:
$$\prod_{i=1}^{6} (a_i^2+2i+4)=P^2+2e_5P+2^2e_4P+2^3e_3P+2^4e_2P+2^5e_1P+2^6P+2^5*4*e_5+2^4*4^2*e^4+2^3*4^3*e_3+2^2*4^4*e_2+2*4^5*e_1+4_6+4(\sum_{cyc}(a_1a_2a_3a_4a_5)^2))^+4^2(\sum_{cyc}(a_1a_2a_3a_4)^2)+4^3\sum_{cyc}(a_1a_2a_3)^2+4^4\sum_{cyc}(a_1a_2)^2+4^5\sum_{cyc}(a_1)^2$$
Which is a monster in its own right. However, I was extremely interested in the patterns that kept popping up. Like the $2e_5P+2^2e_4P+2^3e_3P+2^4e_2P+2^5e_1P+2^6P$ where the power of 2 and the index of $e$ keeps increasing and decreasing with each other. Therefore I wondered if there could be any general formula for any $f(x)$ and $g(x)$.
And that is my question, is there any way to find the answer efficiently without all this unnecessary calculation; and also can this process be generalised to any polynomials $f(x)$ and $g(x)$. And if it cannot be generalised, then is there any sort of algorithm or methodical way that one can take while solving this type of problem?
 A: Note that $(x^2+2x+4)(x-2)=x^3-8$. So the product of the $g(a_i)$ is $P/Q$, where
$$P=\prod(a_i^3-8)$$
$$Q=\prod(a_i-2)$$
As @mathcounterexamples.net notes, the roots of $f$ are the cube roots of $4$ and $-2$; so $a_i^3-8$ takes the values $-4,-4,-4,-10,-10,-10$. Hence $P=64000$.
And the product of $a_i-2$ taken over all roots of $f(x)$ is the product of $a_i$ taken over all roots of
$$f(x+2)=(x+2)^6-2(x+2)^3-8$$
which is simply the constant term $2^6-2.2^3-8=40$.
So we get $P/Q=1600$.
A: $g(x)=(x-a)(x-b)$ where $a=-1+\sqrt 3 i, b=-1-\sqrt 3 i$ are cubic roots of 8.
For $n=1, 2, \ldots, 6, a_n-a$ are the roots of $h_1 (x) = f(x+a)$, $a_n-b$ are the roots of $h_2(x)=f(x+b)$.
Recall that $a^3=b^3=8$, then the desired product is the product of $h_1(x)$ and $h_2(x)$'s constant terms
$$
h_1(0) \cdot h_2(0) = (a^6-2a^3-8)\cdot (b^6-2b^3-8) = (8^2-2 \cdot 8 - 8)^2 = 40^2=1600.
$$
A: The leading coefficient of $f$ is equal to one, so $\prod_{n=1}^{6} (g(a_n))$ is the resultant of $f$ and $g$, and that can be computed as a determinant whose entries are the coefficients of the polynomials:
$$
\prod_{n=1}^{6} (g(a_n)) = \operatorname{res}(f, g) = 
\begin{vmatrix}
-8 &   & 4 \\
0 & -8 & 2 & 4 \\
0 & 0 & 1 & 2 & 4 \\
-2 & 0 &  & 1 & 2 & 4 \\
0  & -2 &   &  & 1 & 2 & 4 \\
0 & 0 & & & & 1 & 2 & 4 \\
1 & 0 & & & & & 1 & 2  \\
 & 1 & & & & & & 1
\end{vmatrix}
= 1600
$$
where the  empty entries are zero.
A: Hint
that can reduce significantly the computation effort... But still some will be required!
Notice that the roots of $f$ are the cubic roots of $4$ and $-2$.
In less that 1 second:
from sympy import resultant
from sympy.abc import x

R = resultant(x ** 6 - 2 * x ** 3 - 8, x ** 2 + 2 * x + 4)
print(R)

$R = 1600$
