# polymake¶

## Purpose¶

Computes the coefficients of a polynomial given the roots.

## Format¶

c = polymake(r)
Parameters: r (Nx1 vector) – roots of the desired polynomial c ((N+1)x1 vector) – contains the coefficients of the Nth order polynomial with roots r: $p(z)=c*z^n + c*z^{(n-1)} + ... c[n]*z + c[n+1]$

## Examples¶

// Assign values for the roots of the polynomial
r = { 2, 1, 3 };

// Calculate the coefficients
c = polymake(r);

// Print 3 spaces for each number and 1 digit after the
// decimal place
format /rd 3,1;

// Iterate through each root in 'r'
for i(1, 3, 1);
rtmp = r[i];
// Calculate the polynomial
rout = c*rtmp^3 + c*rtmp^2 + c*rtmp + c;
print "rtmp = " rtmp "rout = " rout;
endfor;


Since the values of r are roots for this polynomial, rout should equal 0.

Thus the code above gives the following output:

rtmp = 2.0 rout = 0.0
rtmp = 1.0 rout = 0.0
rtmp = 3.0 rout = 0.0


This example assigns c to be equal to:

     1.0
c = -6.0
11.0
-6.0


This represents the polynomial:

$x^3 - 6x^2 + 11^x - 6$

## Remarks¶

The coefficient of $$z^n$$ is set to unity ($$c=1$$).

poly.src