Best way for manipulating multivariate polynomials

11 views (last 30 days)
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
]
  2 Comments
Luc
Luc on 10 Jul 2014
See on this page for one solution: https://stackoverflow.com/questions/24432904/best-way-for-manipulating-multivariate-polynomials-matlab
John D'Errico
John D'Errico on 10 Jul 2014
I'm confused at your question. However, you might find my sympoly toolbox to be useful.
Anyway, in your example, note that H fails to evaluate due to a typo.
More importantly, you say that your goal is to evaluate H*D'. Of course, H*D' will not succeed because the arrays do not conform for multiplication.
Did you really mean H'*D? Be clear, or how can we answer anything? I refuse to try to guess your real question, since anytime I do that, I am ALWAYS wrong.
Are you computing these extra arrays C, E, MX, MY for some purpose, or is it just because they make it "easy" for you to do other computations like differentiate WRT X and Y? That part is trivial though, so it would seem you need a better reason, else you are just making work for the sake of doing so.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!