6

The roots $x_{1}$ and $x_{2}$ of

$$ax^{2}+bx+c=0 $$

satisfy

$$ x_{1}+x_{2}=\frac{-b}{a} $$ and $$x_{1}x_{2}=\frac{c}{a}$$

I need Mathematica to give me $x_{1} ^ n + x_{2}^ n$ for any $n$; that is:

$${x_{1}}^{2}+{x_{2}}^{2}=(x_{1}+x_{2})^{2} -2x_{1}x_{2} = \frac{b^2-2ac}{a^2}$$

$${x_{1}}^{3}+{x_{2}}^{3}=(x_{1}+x_{2})\left ( (x_{1}+x_{2})^{2}-3x_{1}x_{2} \right )=\frac{3abc-b^3}{a^3}$$

$$\dots$$

edit: $$ {x_{1}}^{2}+{x_{2}}^{2}=\underset{\text{I also need this in all cases}}{{(x_{1}+x_{2})^{2} -2x_{1}x_{2}}} = \frac{b^2-2ac}{a^2} $$

I need $x_{1} ^ n + x_{2}^ n$ for any $n$ In terms of (Or as a function of) $$ x_{1}+x_{2} $$ and $$x_{1}x_{2}$$

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
zeros
  • 2,263
  • 1
  • 14
  • 18
  • 1
    {x1, x2} = x /. Solve[a x^2 + b x + c == 0, x]; f[n_] := Together@FullSimplify[x1^n + x2^n]; f[15] – corey979 Jan 24 '17 at 00:13
  • Thanks,I need the final structure in terms of x1 and x2 also for each case, not just the final result – zeros Jan 24 '17 at 00:28

4 Answers4

9

SymmetricReduction is a good tool for this:

First @ SymmetricReduction[x1^2+x2^2,{x1,x2}, {-b/a, c/a}]
First @ SymmetricReduction[x1^3+x2^3,{x1,x2}, {-b/a, c/a}]
First @ SymmetricReduction[x1^4+x2^4,{x1,x2}, {-b/a, c/a}]
b^2/a^2-(2 c)/a
-(b^3/a^3)+(3 b c)/a^2
b^4/a^4-(4 b^2 c)/a^3+(2 c^2)/a^2
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Carl Woll
  • 130,679
  • 6
  • 243
  • 355
6

Recalling the relationship between sums of powers and linear recurrence relations, here is how one can use LinearRecurrence[] to generate the required expressions:

LinearRecurrence[{-b/a, -c/a}, {2, -b/a}, 5] // Simplify
   {2, -b/a, (b^2 - 2 a c)/a^2, -(b^3 - 3 a b c)/a^3, (b^4 - 4 a b^2 c + 2 a^2 c^2)/a^4}

Using Inactivate[] on the symmetric polynomials involved yields the expressions for the power sums in terms of symmetric polynomials of the roots:

LinearRecurrence[{Inactivate[x1 + x2], -Inactivate[x1 x2]},
                 {2, Inactivate[x1 + x2]}, 5] // Simplify // Activate

   {2, x1 + x2, -2 x1 x2 + (x1 + x2)^2, -3 x1 x2 (x1 + x2) + (x1 + x2)^3,
    2 x1^2 x2^2 - 4 x1 x2 (x1 + x2)^2 + (x1 + x2)^4}

Carl has already mentioned SymmetricReduction[] and its convenient third argument, if you're looking to explicitly display the Newton-Girard formulae. If you'll look at that last link, you'll see that a nice linear equation is satisfied between power sums and symmetric polynomials; you might want to try formulating this in terms of LinearSolve[].

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
3

One can obtan this as the solution to a certain recurrence equation. Call the nth term f[n], and the roots x1 and x2. Then

f[n] = (x1+x2)^n =
(x1+x2)*(x1^(n-1)+x2^(n-1)) - (x1*x2^(n-1)+x2*x1^(n-1)) =
(x1+x2)*(x1^(n-1)+x2^(n-1)) - x1*x2*(x1^(n-2)+x2^(n-2)) =
f[1]*f[n-1] - x1*x2*f[n-2]

Now suppose we make the quadratic monic, so it is x^2-b*x+c (the negative for the linear term coefficient is from expanding (x-x1)*(x-x2) and getting x^2-(x+x2)*x+x1*x2). With this convention, we have f[1]==b and we also require that f[0]==2 (which is the sum of the roots to the zeroth power).

rtpowersums = 
 RSolveValue[{f[n] == b*f[n - 1] - c*f[n - 2], f[1] == b, f[0] == 2}, 
  f[n], n]

(* Out[213]= 2^-n ((b - Sqrt[b^2 - 4 c])^n + (b + Sqrt[b^2 - 4 c])^n) *)

Quick test for case where roots are 2 and 3:

tt = Table[Expand[rtpowersums], {n, 1, 5}]
tt /. {b -> 5, c -> 6}

(* Out[214]= {b, b^2 - 2 c, b^3 - 3 b c, b^4 - 4 b^2 c + 2 c^2, 
 b^5 - 5 b^3 c + 5 b c^2}

Out[215]= {5, 13, 35, 97, 275} *)

Table[2^n + 3^n, {n, 5}]

(* Out[216]= {5, 13, 35, 97, 275} *)
Daniel Lichtblau
  • 58,970
  • 2
  • 101
  • 199
2

It's seem the RootSum is your after,of course,it just show the result.

RootSum[a #^2 + b # + c &, #^1 &] // FullSimplify
RootSum[a #^2 + b # + c &, #^2 &] // FullSimplify
RootSum[a #^2 + b # + c &, #^3 &] // FullSimplify
RootSum[a #^2 + b # + c &, #^4 &] // FullSimplify

Mathematica graphics

yode
  • 26,686
  • 4
  • 62
  • 167