Sylvester matrix of two polynomials : sylvester

### 5.26.18 Sylvester matrix of two polynomials : sylvester

sylvester takes two polynomials as arguments.
sylvester returns the Sylvester matrix S of these polynomials.
If A(x)=∑i=0i=n aixi and B(x)=∑i=0i=mbixi are 2 polynomials, their Sylvester matrix S is a square matrix of size m+n where m=degree(B(x)) and n=degree(A(x)). The m first lines are made with the A(x) coefficients, so that :

⎛ ⎜ ⎜ ⎜ ⎝ |
s11=an | s12=an−1 | ⋯ | s1(n+1)=a0 | 0 | ⋯ | 0
s21=0 | s22=an | ⋯ | s2(n+1)=a1 | s2(n+2)=a0 | ⋯ | 0
⋮ | ⋮ | ⋮ | ⋱ | ⋮ | ⋱ | ⋮
sm1=0 | sm2=0 | ⋯ | sm(n+1)=am−1 | sm(n+2)=am−2 | ⋯ | a0
| ⎞ ⎟ ⎟ ⎟ ⎠

and the n further lines are made with the B(x) coefficients, so that :

⎛ ⎜ ⎜ ⎝ |
s(m+1)1=bm | s(m+1)2=bm−1 | ⋯ | s(m+1)(m+1)=b0 | 0 | ⋯ | 0
⋮ | ⋮ | ⋮ | ⋱ | ⋮ | ⋱ | ⋮
s(m+n)1=0 | s(m+n)2=0 | ⋯ | s(m+n)(m+1)=bn−1 | bn−2 | ⋯ | b0
| ⎞ ⎟ ⎟ ⎠

Input :

sylvester(x`^`3-p*x+q,3*x`^`2-p,x)

Output :

[[1,0,-p,q,0],[0,1,0,-p,q],[3,0,-p,0,0], [0,3,0,-p,0],[0,0,3,0,-p]]

Input :

det([[1,0,-p,q,0],[0,1,0,-p,q],[3,0,-p,0,0], [0,3,0,-p,0],[0,0,3,0,-p]])

Output :

-4*p`^`3--27*q`^`2