*This problem is from a math olympiad.
It is known that $$ x + \frac{1}{x} = 3$$ What is the value of $$ x^{3} + \frac{1}{x^{3}} ?$$
I know that we can solve for $x$ from $ x + 1/x = 3$ first, by $$ x^{2}-3x+1 = 0$$
Which gives
$$ x = \frac{3 \pm \sqrt{5} }{2} $$
Then we can relatively tedious find the values of
$$ x^{3} + \frac{1}{x^{3}} $$
Are there better ways? Can we generalize a way for $$ x^{n} + \frac{1}{x^{n}} ? $$
Thanks.
We know that $$x+\frac{1}{x}=a\implies x^2-ax+1=0\implies x=\frac{1}{2} \left(a\pm\sqrt{a^2-4}\right),$$
so that $$x^n+\frac{1}{x^n}=\frac{\left(a\pm\sqrt{a^2-4}\right)^n}{2^n}+\frac{2^n}{\left(a\pm\sqrt{a^2-4}\right)^n}.$$
In your original case, you had $a=3$ and $n=3$, which gives
$$x+\frac{1}{x}=3\implies x^3+\frac{1}{x^3}=\frac{8}{(\sqrt{5}+3)^3}+\frac{(\sqrt{5}+3)^3}{8}=18,$$ which is correct.
Let's try a bigger one, with $a=7$ and $n=9$,
$$x+\frac{1}{x}=7\implies x^9+\frac{1}{x^9}=\frac{512}{(7+3\sqrt{5})^9}+\frac{(7+3\sqrt{5})^9}{512}=33385282.$$
Old approach
My original solutions complicated things by using the Binomial Theorem...
$$\left(x+\frac{1}{x}\right)^n=\sum_{k=0}^n{n\choose k}x^{n-k}\frac{1}{x^k}=\sum_{k=0}^n{n\choose k}x^{n-2k}=x^n+\frac{1}{x^n}+\sum_{k=1}^{n-1}{n\choose k}x^{n-2k}.$$
So if we know that $$x+\frac{1}{x}=a,$$ then we have that $$x^n+\frac{1}{x^n}=a^n-\sum_{k=1}^{n-1}{n\choose k}x^{n-2k}.$$
Since $x^2-ax+1=0$ then $x=\frac{a}{2}\pm \frac{1}{2}\sqrt{a^2-4}$, so that $$x+\frac{1}{x}=a\implies x^n+\frac{1}{x^n}=a^n-\sum_{k=1}^{n-1}{n\choose k}\left(\frac{a}{2}\pm \frac{1}{2}\sqrt{a^2-4}\right)^{n-2k}.$$
Evaluating the finite sum gives,
$$x+\frac{1}{x}=a\implies x^n+\frac{1}{x^n}=\frac{2^n}{\left(\sqrt{a^2-4}\pm a\right)^n}+\frac{\left(\sqrt{a^2-4}\pm a\right)^n}{2^n}.$$