I am looking for a good way to manipulate multivariate polynomials in Matlab. The purpose of this question is very global. Currently, I am manipulating some matrices of polynomials in MATLAB (with currently 2 variables). To simplify this manipulation I split each matrix into four new matrices:
- One for defining the coefficient:
C
- One for defining an exponent:
E
(see below) - One for defining the power of the first variable
X
:MX
- One for defining the poser of the second variable
Y
:MY
Thus you can evaluate polynomial matrix by this way C./h^E.*X.^MX.*Y.^MY
. For some reason, sometimes each component of the polynomial matrix can be a sum of some monomials. In this case, I use some nD-arrays (and sum(.,3)
).
For my work, I need also to defined the derivatives of the polynomial matrices with respect to X
or Y
. Using the previous formulation, the derivatives can be easily obtained by subtracting 1 to the associated matrix MX
or MY
and by multiplying C
by the right matrix MX
or MY
.
Currently this approach works fine for lower degrees but I need also to multiplying some polynomial matrices and this is the big problem of this approach. To deal with this problem I write manually the full matrix product (compute using Mathematica).
I want to extend my code for higher degrees and to manipulate more easily the polynomial matrices. So if you have any idea to do this.
I can use any toolbox in Matlab but at the end I need to have the matrices MX
, MY
, E
and C
(I need this separated matrices for doing some specific computations). I tried to use the Symbolic Toolbox
but it seems to be very difficult to extract these four matrices when the polynomial matrix is complicated.
Example:
H=[
1 0 Y/h 10*Y^2/h^2 5X*Y/h^2 0
0 1 -X/h X/h 50*X^2/h^2 60*X*Y/h^2
]
C=[
1 0 1 10 5 0
0 1 -1 1 50 60
]
E=[
0 0 1 2 2 0
0 1 1 1 2 2
]
MX=[
0 0 0 0 1 0
0 0 1 1 2 1
]
MY=[
0 0 1 2 1 0
0 0 0 0 0 1
]
Problem: Compute H*D'
and extract C
, E
, MX
and MY
(with H
define above) and
D=[
Y/h Y^2/h^2 X/h
X/h Y/h X*Y/h
]