I'm interested in finding the generating function for the sequence defined by the recurrence relation $$a(n)=3a(n-1)+a(n-2)+a(n-3)$$ with initial values $a(0)=3$,$a(1)=9$ and $a(2)=31$
There doesn't seem to be any useful information in the OEIS,thanks in advance.
With those initial conditions and the assumption that $a(n)=0$ for $n<0$, the recurrence can be written
$$a(n)=3a(n-1)+a(n-2)+a(n-3)+3[n=0]+[n=2]\;,$$
where the last two terms contain Iverson brackets. Multiplying by $x^n$ and summing over $n\ge 0$, we have
$$\begin{align*} \sum_{n\ge 0}a(n)x^n&=3\sum_{n\ge 0}a(n-1)x^n+\sum_{n\ge 0}a(n-2)x^n+\sum_{n\ge 0}a(n-3)x^n+3+x^2\\ &=\left(3x+x^2+x^3\right)3x\sum_{n\ge 0}a(n)x^n+3+x^2\;, \end{align*}$$
so
$$\sum_{n\ge 0}a(n)x^n=\frac{3+x^2}{1-3x-x^2-x^3}\;.$$