I was trying to compute intersection of two vector spaces. I did find this link Intersection of two vector spaces with a nifty function being made for this given two lists of basis vectors.
I am having trouble finding an efficient way of putting basis vectors into a list that start as polynomials. For example, I have the vector spaces spanned by {z1, z2, z3}
and {z4, z5, z6}
z1 = (1/6 p ((x1 + 2 y1)^2 + (2 x1 + y1)^2) + ((p - 1)/p) (x2 + y2)) (x1 + 2 y1);
z2 = (x1 + 2 y1)^3;
z3 = (x1 + 2 y1) (x2 + 2 y2);
And another given by
z4 = (1/6 p ((x1 + 2 y1)^2 + (2 x1 + y1)^2) + ((p - 1)/p) (x2 + y2)) (2 x1 + y1);
z5 = (2 x1 + y1)^3;
z6 = (2 x1 + y1) (2 x2 + y2);
I am interested in the intersection of these vector spaces. When I try to find an efficient way to put them into list, I was thinking something like
w1 = Flatten[CoefficientList[z1, {x1, y1, x2, y2}];
would work, but I don't get vectors of the same size, as illustrated below
Flatten[CoefficientList[z1, {x1, y1, x2, y2}]]
{0, 0, 0, 0, 0, (2 (-1 + p))/p, (2 (-1 + p))/p, 0, 0, 0, 0, 0, (5 p)/3, 0, 0, 0, 0, (-1 + p)/p, (-1 + p)/p, 0, 0, 0, 0, 0, (7 p)/2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3 p, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (5 p)/6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
Flatten[CoefficientList[z2, {x1, y1, x2, y2}]]
{0, 0, 0, 8, 0, 0, 12, 0, 0, 6, 0, 0, 1, 0, 0, 0}
Any suggestions?
{}
button above the edit window. The edit window help button?
is also useful for learning how to format your questions and answers. You may also find this meta Q&A helpful $\endgroup$CoefficientList
, just use the optional third argument, with settings based on highest exponents appearing for a given variable. $\endgroup$