I am considering the reverse process of the Taylor expansion of a rational function.
Question: suppose that I have$$f(x) = a_{0}+a_{1}x+a_{2}x^{2}+\cdots,$$and I know that $f(x)$ is a rational function (i.e. $f(x)=\frac{h(x)}{g(x)}$ is quotient of two polynomials) and I know the formula for $a_{n}$. How can I explicitly find $h(x)$ and $g(x)$?
More specifically, the formula of $a_{n}$ is the following: there is a square matrix $A$, and $a_{n}$ is the $(1,1)$-entry of $A^{n}$, i.e.$$a_{n} = (A^{n})_{1,1}$$In this case, how can we write $f(x)$ as a rational function?
Example: Let$$A=\left(\begin{matrix}1 & 0 & 1 \\0 & 2 & 0 \\1 & 0 & 1\end{matrix}\right)$$Then, $a_{n}=2^{n-1}=(1,2,4,8,\cdots)$, and $f(x) =x+2x^{2}+4x^{3}+8x^{4}+\cdots= \frac{x}{1-2x}$. However, I got the expression of $f(x)= \frac{x}{1-2x}$ by guessing. Is there a concrete way of finding such $f(x)$?
Thanks very much for your help!