Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Polynomial expansion
Posted:
Nov 5, 2007 8:37 PM


Hi, I'm currently hard coding this but I was wondering if somebody could help me with writing a function for the polynomial expansion of a vector. For example if I have a vector [x1 x2] and I want a 2nd order polynomial expansion then my expanded vector z= [1 x1 x2 x1^2 x1x2 x2^2] which is all the possible cross terms and powers of x1 and x2. As another example, if I wanted a second order expansion of [x1 x2 x3] then z=[1 x1 x2 x3 x1x2 x2x3 x1x3 x1^2 x2^2 x3^2]. Finally, if I needed a third order expansion of [x1 x2], then z=[1 x1 x2 x1^2 x1x2 x2^2 x1^2x2 x1x2^2 x1^3 x2^3]
Can some one help me formulate this in the form of a function?



