I have a simple quadratic (with $x^2$) equation, x can Be complex too:
$$x^2+x+1=0$$
But it could be any equation, the equation above is just an example. I need to compute $x_1^{10}+x_2^{10}$, but it could have another exponents (ex: $x_1^{50}+x_2^{50}$).
I need to know, on a general case, how to find $x_1^n+x_2^n,\ n\in\mathbb{N}\ ax^2+bx+c=0,\ a\ is\ not\ 0$?
I ask this because I have to create a software which computes this (user writes the equation and the number n = exponent) and I can't find the roots always, because sometimes are complex. I think I should make use of Viete, but I don't know how to compute $x_1^n+x_2^n$.
Thank you very much!!
One approach is to represent the roots in polar form, and take advantage of their symmetry. For the sake of ease of exposition, let the quadratic be monic; that is, $a = 1$. If it's not already in that form, it's trivial to convert it to a monic form.
If the roots are real—if $b^2-4c \geq 0$—I assume you know how to handle that. So we'll just consider the case where they're not real. In that case, $b^2-4c < 0$, and the roots are given by
$$ x_{1, 2} = \frac{-b \pm \sqrt{b^2-4c}}{2} = \frac{-b}{2} \pm \frac{\sqrt{4c-b^2}}{2}i $$
Note that $c > 0$ necessarily if the roots are not real. We can see, using the Pythagorean theorem, that $|x_1| = |x_2| = \sqrt{c}$. Now, find $\theta, 0 \leq \theta \leq \pi$ such that
$$ \cos\theta = -\frac{b}{2\sqrt{c}} $$ $$ \sin\theta = \sqrt{1-\frac{b^2}{4c}} $$
This can be done using the atan2 function in many programming languages. Then $x_{1, 2}$ can be represented as $\sqrt{c} \text{ cis } (\pm\theta) \equiv \sqrt{c} \left[\cos(\pm\theta)+i\sin(\pm\theta)\right]$. Then
$$ x_1^n = \sqrt{c^n} \text{ cis }(n \theta) $$ $$ x_2^n = \sqrt{c^n} \text{ cis } (-n\theta) $$
Since $x_1^n$ and $x_2^n$ form a conjugate pair (just as $x_1$ and $x_2$ do), we therefore have
$$ x_1^n+x_2^n = 2\sqrt{c^n}\cos (n\theta) $$