<s>[INST] 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?
 [/INST] $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.
$$
</s>