Đặt \(x^2+3x+1=a\)
Ta có: \(\left(x^2+3x+1\right)\left(x^2+3x+2\right)=6\)
\(\Leftrightarrow a\left(a+1\right)=6\)
\(\Leftrightarrow a^2+a-6=0\)
\(\Leftrightarrow a^2+3a-2a-6=0\)
\(\Leftrightarrow a\left(a+3\right)-2\left(a+3\right)=0\)
\(\Leftrightarrow\left(a+3\right)\left(a-2\right)=0\)
\(\Leftrightarrow\left(x^2+3x+1+3\right)\left(x^2+3x+1-2\right)=0\)
\(\Leftrightarrow\left(x^2+3x+4\right)\left(x^2+3x-1\right)=0\)
mà \(x^2+3x+4=x^2+2\cdot x\cdot\frac{3}{2}+\frac{9}{4}+\frac{7}{4}=\left(x+\frac{3}{2}\right)^2+\frac{7}{4}>0\forall x\)
nên \(x^2+3x-1=0\)
\(\Leftrightarrow x^2+2\cdot x\cdot\frac{3}{2}+\frac{9}{4}-\frac{5}{4}=0\)
\(\Leftrightarrow\left(x+\frac{3}{2}\right)^2=\frac{5}{4}\)
\(\Leftrightarrow\left[{}\begin{matrix}x+\frac{3}{2}=\frac{\sqrt{5}}{2}\\x+\frac{3}{2}=-\frac{\sqrt{5}}{2}\end{matrix}\right.\Leftrightarrow\left[{}\begin{matrix}x=\frac{\sqrt{5}-3}{2}\\x=\frac{-\sqrt{5}-3}{2}\end{matrix}\right.\)
Vậy: \(S=\left\{\frac{\sqrt{5}-3}{2};\frac{-\sqrt{5}-3}{2}\right\}\)