Possible bug in the cross product and vector simplfication ?



You are probably looking for this:

(%i1) load("vect")$
(%i2) declare([PR0, PR1, PR2, PR3], nonscalar)$
(%i3) declare([ax0, ay0, ax1, ay1, ax2, ay2, ax3, ay3], scalar)$
(%i4) declare([XN, YN, ZN, X, Y, Z], nonscalar)$
(%i5) PRN0 : PR0 + ax0*X + ay0*Y$
(%i6) PRN3 : PR3 + ax3*X + ay3*Y$
(%i7) vectorsimp(PRN0 ~ PRN3), expandall=true, expand;
(%o7) ax0*ay3*X~Y-ax3*ay0*X~Y-ay0*PR3~Y-ax0*PR3~X+ay3*PR0~Y+ax3*PR0~X
+PR0~PR3

(There is and additional expand evflag for %i7)

Andrej

On pon, 2005-05-30 at 21:28 +0200, Sergey Ten wrote:
> I'm trying to use cross product
> and getting wrong result:
> DECLARE([PR0, PR1, PR2, PR3], NONSCALAR);
> (%o1)                      DONE
> (%i2) load("vect");
> (%o2)   C:/PROGRA~1/MAXIMA~1.1/share/maxima/5.9.1/share/vector/vect.mac
> (%i3) DECLARE([ax0, ay0, ax1, ay1, ax2, ay2, ax3, ay3], SCALAR);
> (%o3)                      DONE
> (%i4) DECLARE([PRN0, PRN1, PRN2, PRN3], NONSCALAR);
> (%o4)                      DONE
> (%i5) DECLARE([XN, YN, ZN, X, Y, Z], NONSCALAR);
> (%o5)                      DONE
> (%i6)  PRN0 : PR0 + ax0*X + ay0*Y;
> (%o6)                   ay0 Y + ax0 X + PR0
> (%i7) PRN3 : PR3 + ax3*X + ay3*Y;
> (%o7)                   ay3 Y + ax3 X + PR3
> (%i8) EXPANDCROSSCROSS :TRUE;
> (%o8)                      TRUE
> (%i9) EXPANDCROSSPLUS :TRUE;
> (%o9)                      TRUE
> (%i10) VECTORSIMP(PRN0 ~ PRN3);
> 
> WARNING: DECLARE VECTOR INDETERMINANTS
> 
> NONSCALAR TO AVOID ERRORS & TO GET FULL SIMPLIFICATION
> (%o10)        ay3 PR0 ~ Y + ax3 PR0 ~ X + PR0 ~ PR3 + ay0 ~ (- PR3 ~ Y)
> 
> that is very strange result
> 
> the problem seems in the
> EXPANDCROSSCROSS :TRUE;
> which is
> "EXPANDCROSSCROSS refers to replacing p~(q~r) with (p.r)*q-(p.q)*r"
> if I do
> 
> (%i11) EXPANDCROSSCROSS :FALSE;
> 
> I'm getting
> (%o9)                      TRUE
> (%i10) VECTORSIMP(PRN0 ~ PRN3);
> 
> WARNING: DECLARE VECTOR INDETERMINANTS
> 
> NONSCALAR TO AVOID ERRORS & TO GET FULL SIMPLIFICATION
> (%o10)        ay3 PR0 ~ Y + ax3 PR0 ~ X + PR0 ~ PR3 + ay0 ~ (- PR3 ~ Y)
> (%i11) EXPANDCROSSCROSS :FALSE;
> (%o11)                      FALSE
> (%i12) VECTORSIMP(PRN0 ~ PRN3);
> WARNING: DECLARE VECTOR INDETERMINANTS
> 
> NONSCALAR TO AVOID ERRORS & TO GET FULL SIMPLIFICATION
> (%o12) ay3 PR0 ~ Y + ax3 PR0 ~ X + PR0 ~ PR3 + 1 ~ X ~ Y ax0 ay3
> 
>              + ay0 ~ (- PR3 ~ Y) - 1 ~ X ~ Y ax3 ay0 - 1 ~ PR3 ~ X ax0
> 
> - it is better, but still - why scalars cross producted to vector ? It 
> seems scalar treated as vector, - instead of ax0  it's treated as 
> ax0*Vector_1
> Any advice how I should work with cross product to get correct results ?
> 
>