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?