Problem 44259. Product of two multivariate polynomials
MATLAB has a few functions for creating and manipulating single-variable polynomials, but outside of the Symbolic Math Toolbox there is nothing for multivariate polynomials such as y-x^2 or x^2+y^2+z^2-1. Generalizing the approach for one variable, we can define an array of coefficients with one dimension for each variable. We will index them in decreasing order, for example if p(x) = A + B x^3, then the coefficients are
c = [B 0 0 A].
Note this is same order as used by the builtin functions. A couple more examples: if p(x,y) = x - y^2, then
c = [0 -1; 0 0; 1 0].
If p(x,y,z) = z-2, then c has dimensions [1 1 2] with c(:,:,1) = 1 and c(:,:,2) = -2.
The challenge is to create a function polyMult that takes two arrays of coefficients for polynomials p1 and p2 and returns the coefficients for p1*p2. See the tests for examples.
Solution Stats
Problem Comments
-
1 Comment
Can you explain why is the same matrix c = [0 -1; 0 0 ; 1 0] used to represent two different polynomials p(x,y) = x-y^2 (as in problem definition above) and p(x,y) = y - x^2 as in test example 3 on the solution page?
Solution Comments
Show commentsProblem Recent Solvers18
Suggested Problems
-
10021 Solvers
-
623 Solvers
-
Operate on matrices of unequal, yet similar, size
194 Solvers
-
129 Solvers
-
46 Solvers
More from this Author9
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!