# Sum of a to the n formulas

This page gathers some formulas related to sums of squares, cubes, and other symmetric polynomials.

Let

\begin{align} P &= a+b+c \\ Q &= ab+bc+ca \\ R &= abc \\ \end{align} Then $$a^2+b^2+c^2 = P^2-2Q$$ Then \begin{align} PQ &= (a+b+c)(ab+bc+ca) \\ &= a^2(b+c)+b^2(a+c)+c^2(a+b)+3R \\ \end{align} and $$P^3=a^3+b^3+c^3+3(a^2(b+c)+b^2(a+c)+c^2(a+b))+6R$$ allows us to derive $$a^3+b^3+c^3 = P^3-3PQ+3R$$ Continuing we get $$a^4+b^4+c^4 = P^4-4P^2Q+4PR+2Q^2$$

Here is a numeric demonstration:

package main

import "fmt"

func check(a, b, c float64) {
p := a + b + c
q := a*b + b*c + a*c
r := a * b * c
sum2 := a*a + b*b + c*c
sum3 := a*a*a + b*b*b + c*c*c
sum4 := a*a*a*a + b*b*b*b + c*c*c*c
f2 := p*p - 2*q
f3 := p*p*p - 3*p*q + 3*r
f4 := p*p*p*p - 4*p*p*q + 4*p*r + 2*q*q
if f2 != sum2 {
fmt.Printf("f2/sum2 %.2f != %.2f\n", f2, sum2)
}
if f3 != sum3 {
fmt.Printf("f3/sum3 %.2f != %.2f\n", f3, sum3)
}
if f4 != sum4 {
fmt.Printf("f4/sum4 %.2f != %.2f\n", f4, sum4)
}
}

func main() {
check(1, 1, 1)
check(1, 2, 3)
check(3, 2, 1)
}