How to get the coefficients of the minimal polynomial ?

8 views (last 30 days)
Dear All,
I have to find the coefficients of the minimal polynomial of all the matrices stored in a 3-D array. I have tried through the MuPAD but through that I am getting the whole polynomial, If anyone knows the way how to extract only the coefficients from it(i.e. from the polynomial in MuPAD) and then to store them in a vector in matlab, or if any function in Matlab only which can give the coefficients of the minimal polynomial.
Here is the code for the mupad :
nb=mupad;
A:=Dom::Matrix(Dom::Rational)([[1,-1,-1],[1,-2,1],[0,1,-3]]);
delete x: linalg::minpoly(A,x)
This gives the minimal polynomial for the given matrix in 'x'. (I have to do it for the 3-D array of matrices).
If anyone knows some other way too that would be very helpful.
URGENT help needed !!
Thank you, Palash.

Accepted Answer

Kai Gehrs
Kai Gehrs on 22 Jun 2011
Hi Palash,
I think the following MATLAB function could do the job for your problem:
function p = minpoly(A)
p = evalin(symengine, ['map(poly2list(linalg::minpoly(' char(sym(A)) ',x)),c->c[1])']);
end
If you add it in MATLAB to your path, then you can call it via:
>> A = [1 -1 -1; 1 -2 1; 0 1 -3]; % minimal polynomial is x^3 + 4*x^2 + x - 1
>> minpoly(A)
ans =
[ 1, 4, 1, -1]
Hope this helps. Inside of MuPAD the function 'poly2list' converts polynomials to a nested list representation containing the information on the coefficients of polynomials.
Best regards,
-- Kai

More Answers (3)

Walter Roberson
Walter Roberson on 20 Jun 2011
Use sym2poly()

Palash
Palash on 22 Jun 2011
Hi Walter,
If I am not wrong then this is the function by which we can get the coefficients for a given polynomial, but not the "minimal polynomial".
I would like to put my questn again : I have to find the coefficients of the minimal polynomial in the Mtalb, or to store the coefficients in a vector in Matlab.
Thanks,
Palash Goyal.
  1 Comment
Walter Roberson
Walter Roberson on 22 Jun 2011
evalin(symengine) the linalg::minpoly operation, which will return the symbolic result to MATLAB. sym2poly() that result at the MATLAB level.
There is no MATLAB function that does this computation directly.

Sign in to comment.


Pantelis Sopasakis
Pantelis Sopasakis on 9 Nov 2011
Just my two cents... The code posted by Kai Gehrs will not work if the returned polynomial has some zero coefficients. Try for example the matrix:
A=ones(3,3);
The output will be
[1 -3]
instead of
[1 -3 0]
An m-function that takes care of such a case can be found at https://github.com/alphaville/eat/blob/master/zz_minPolSymb.m

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!