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 CommentsShow comments
Problem Recent Solvers18