How to solve 3D vector equations symbolically?

245 Views Asked by At

I'm trying to solve the following system of equations for $\vec{X}$: $$ \vec{A} \cdot \vec{X}=d_1 $$ $$ \vec{B} \cdot \vec{X}=d_2 $$ $$ (\vec{A} \times \vec{B}) \cdot \vec{X}=(\vec{A} \times \vec{B}) \cdot \vec{C} $$ Where $\cdot$ is the dot product, $\times$ is the cross product, $\vec{A}$, $\vec{B}$, $\vec{C}$, $\vec{X}$, are 3D vectors and $d_1$ and $d_2$ are scalars. ($\vec{A}$ and $\vec{B}$ have unit length if that's any help)

I tried to do the following in Maxima:

load("vect");

declare([A,B,C,X],nonscalar);

solve([A.X=d1, B.X=d2, (A~B).X=(A~B).C], X);

But the answer I got was []. Then I tried this:

solve([express(A.X=d1), express(B.X=d2), express((A~B).X=(A~B).C)], express(X));

Getting the following answer:

$$ X_x=(A_y(A_x(B_yB_zC_z-C_yB_z^2-d_2B_y)-d_1B_xB_y)+A_z(A_x((B_yC_y-d_2)B_z-B_y^2C_z)+A_y(B_xB_yC_z+(B_xC_y-2C_xB_y)B_z)-d_1B_xB_z)+A_y^2(-B_xB_zC_z+C_xB_z^2+d_2B_x)+d_1A_x(B_z^2+B_y^2)+(-B_xB_yC_y+C_xB_y^2+d_2B_x)A_z^2)/(A_x^2(B_z^2+B_y^2)+A_y^2(B_z^2+B_x^2)+A_z(-2A_yB_yB_z-2A_xB_xB_z)+(B_y^2+B_x^2)A_z^2-2A_xB_xA_yB_y), $$ $$ X_y=- (A_y(A_x(-B_xB_zC_z+C_xB_z^2+d_2B_x)+d_1(-B_z^2-B_x^2))+A_z(A_x((2B_xC_y-C_xB_y)B_z-B_xB_yC_z)+A_y(B_x^2C_z+(d_2-B_xC_x)B_z)+d_1B_yB_z)+A_x^2(B_yB_zC_z-C_yB_z^2-d_2B_y)+((B_xC_x-d_2)B_y-B_x^2C_y)A_z^2+d_1A_xB_xB_y)/(A_x^2(B_z^2+B_y^2)+A_y^2(B_z^2+B_x^2)+A_z(-2A_yB_yB_z-2A_xB_xB_z)+(B_y^2+B_x^2)A_z^2-2A_xB_xA_yB_y), $$ $$ X_z= (A_y(A_x((B_xC_y+C_xB_y)B_z-2B_xB_yC_z)-d_1B_yB_z)+A_x^2(B_y^2C_z+(d_2-B_yC_y)B_z)+A_y^2(B_x^2C_z+(d_2-B_xC_x)B_z)-d_1A_xB_xB_z+(A_x(B_xB_yC_y-C_xB_y^2-d_2B_x)+A_y((B_xC_x-d_2)B_y-B_x^2C_y)+d_1(B_y^2+B_x^2))A_z)/(A_x^2(B_z^2+B_y^2)+A_y^2(B_z^2+B_x^2)+A_z(-2A_yB_yB_z-2A_xB_xB_z)+(B_y^2+B_x^2)A_z^2-2A_xB_xA_yB_y) $$

Which I would like in vector form, so expressed as a cross/dot product of vectors. Is there a way for Maxima to give me the vector form, or to convert the solution to vector form? Alternatively, is there other software out there that can do that?

Edit: I worked out the solution from the above formula by hand: $$ \vec{X}=\dfrac{ d_1 ((\vec{A} \cdot \vec{B}) \vec{B}-(\vec{B} \cdot \vec{B}) \vec{A})+d_2 ((\vec{A} \cdot \vec{B}) \vec{A}-(\vec{A} \cdot \vec{A}) \vec{B})-(\vec{C} \cdot (\vec{A} \times \vec{B})) (\vec{A} \times \vec{B})}{(\vec{A} \times \vec{B}) \cdot(\vec{A} \times \vec{B})} $$ It would still be useful to know the general method for solving these kinds of equations.