Advertisement
Guest User

Sylvester matrix function

a guest
Feb 10th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. SylvesterMatrix[poly1_, poly2_, var_] := With[{coeffs1 = Reverse[CoefficientList[poly1, var]], coeffs2 = Reverse[CoefficientList[poly2, var]], l1, l2},
  2. l1 = Length[coeffs1]; l2 = Length[coeffs2];
  3. Join[If[l2 - 2 > 0, NestList[RotateRight, PadRight[coeffs1, l1 + l2 - 2], l2 - 2], {}],
  4. If[l1 - 2 > 0, NestList[RotateRight, PadRight[coeffs2, l1 + l2 - 2], l1 - 2], {}]]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement