07-12-2018, 11:15 PM

I am interested in coding general cases of the Vieta's formulas (check the Wikipedia article to see these formulas in a high-level language like VBA, Python, Matlab, and C++. The target is to have a function that sums up the squares of the LHS - RHS of each Vieta formula:

F(X,a) = (LHS1 - RHS1)^2 + (LHS2 - RHS2)^2 + ... + (LHSn - RHSn)^2

Where:

LHS1 = sum(X(i)) for i = 1 to n

RHS1 = - a(n-1)/a(n))

LHS2 = ((X(1)*X(2) + X(1)*X(3) + ... + X(1)*X(n)) +

((X(2)*X(3) + X(2)*X(4) + ... + X(2)*X(n)) +

... +

X(n-1)*X(n)

RHS2 = a(n-2)/a(n))

....

LHSn = product(X(i)) for i = 1 to n

RHSn = (-1)^n * a(0)/a(n)

The parameters are the array X() which represents the guesses for the roots, and array a() that represents the polynomial coefficients. The Wikipedia article designates a(n) as the coefficient for x^n and a(0) as the constant term.

Good luck to us all!!

Namir

F(X,a) = (LHS1 - RHS1)^2 + (LHS2 - RHS2)^2 + ... + (LHSn - RHSn)^2

Where:

LHS1 = sum(X(i)) for i = 1 to n

RHS1 = - a(n-1)/a(n))

LHS2 = ((X(1)*X(2) + X(1)*X(3) + ... + X(1)*X(n)) +

((X(2)*X(3) + X(2)*X(4) + ... + X(2)*X(n)) +

... +

X(n-1)*X(n)

RHS2 = a(n-2)/a(n))

....

LHSn = product(X(i)) for i = 1 to n

RHSn = (-1)^n * a(0)/a(n)

The parameters are the array X() which represents the guesses for the roots, and array a() that represents the polynomial coefficients. The Wikipedia article designates a(n) as the coefficient for x^n and a(0) as the constant term.

Good luck to us all!!

Namir