# How to implement Newton's Identities

I need to produce identities related to Newton's Identities of arbitrary order. More specifically, I need the identities in the following image for an arbitrary n: What I can't quite wrap my head around is how to work with expressions in Mathematica where I don't know how many variables are involved. Is there a way to programatically create subscripted variables on the fly? So, basically, looking for help getting started.

Format[p[x_] := Subscript[p, x]];
Format[e[x_] := Subscript[e, x]];
Table[p[k] == (-1)^(k - 1) e[k] k +
Sum[(-1)^(k - 1 + i) e[k - i] p[i], {i, 1, k - 1}], {k, 1,
10}] // Column


$$\begin{array}{l} p_1=e_1 \\ p_2=e_1 p_1-2 e_2 \\ p_3=-e_2 p_1+e_1 p_2+3 e_3 \\ p_4=e_3 p_1-e_2 p_2+e_1 p_3-4 e_4 \\ p_5=-e_4 p_1+e_3 p_2-e_2 p_3+e_1 p_4+5 e_5 \\ p_6=e_5 p_1-e_4 p_2+e_3 p_3-e_2 p_4+e_1 p_5-6 e_6 \\ p_7=-e_6 p_1+e_5 p_2-e_4 p_3+e_3 p_4-e_2 p_5+e_1 p_6+7 e_7 \\ p_8=e_7 p_1-e_6 p_2+e_5 p_3-e_4 p_4+e_3 p_5-e_2 p_6+e_1 p_7-8 e_8 \\ p_9=-e_8 p_1+e_7 p_2-e_6 p_3+e_5 p_4-e_4 p_5+e_3 p_6-e_2 p_7+e_1 p_8+9 e_9 \\ p_{10}=e_9 p_1-e_8 p_2+e_7 p_3-e_6 p_4+e_5 p_5-e_4 p_6+e_3 p_7-e_2 p_8+e_1 p_9-10 e_{10} \\ \end{array}$$

It's not clear whether you need just a display or formal expression or an actual recursive function. I'll assume the latter.

p = e;
p[n_] :=
Simplify[
Sum[e[i]*p[n - i]*(-1)^(1 + i), {i, 1, n - 1}] +
n*e[n]*(-1)^(1 + n)]


This was just a matter of coming up with an expression for p[n] that matched the pattern provided. I didn't try to simplify it any. The Simplify just forces the terms to be combined. You should test to verify it actually matches your expectation--it looks correct to me for a small set of terms.

Now, you mentioned subscripts. Subscripts are just notation, so a formal expression like e can be interpreted as equivalent to a subscripted e. However, if you really want to see subscripts you can use this:

Format[e[n_]] := Subscript[e, n]


Execute the above before evaluating any specific p, and then you should see the nicely subscripted format when you do evaluate a specific p. Understand that this will just affect the display. The actual expressions will still use things like e.

Since you provided the fully expanded expression on the far right hand side (the ones with just e and no p), then I'm assuming that you don't need to keep the intermediate form with p. If you do need that form, then we'd need to come up with something slightly different.