vector times vector; vector^-1?



Am 15 Nov 2008 um 16:36 hat Harald Geyer geschrieben:

> 
> Just in case I'm wrong and you are not doing the above: What would your
> vector code do different to the current implementations via matrices/lists?

The difference is an independence of matrices and lists. It gets rid of listarith : true/false. 
The second important point is a better structured readability of vector expressions in 
chosable 1d or 2d.

(%i3) v: vector(1,2);
                                     [ 1 ]
(%o3)                                [   ]
                                     [ 2 ]
(%i4) [vectorp(v), matrixp(v), listp(v)];
(%o4)                        [true, false, false]
(%i5) vector_display2d:false$
(%i6) w: apply(vector, [3,4]);
(%o6)                               [3, 4]
(%i7) [vectorp(w), matrixp(w), listp(w)];
(%o7)                        [true, false, false]

It looks like a matrix or list, depending on what you prefer, but isn't. 

( This output doesn't work with wxMaxima at the moment. wxMaxima seems to need 
matrixp(v)=true to be able to show it as a one-column-matrix resp. listp(v)=true for list-like 
output. Perhaps someone can help. I am sure the result will look fine then. )


I will now give a working example on what I mean by "structured readability":
I will use display2d:false in this e-mail and I hope that you can imagine how it will look like 
with display2d:true. For better readability in this display2d:false-presentation I use an alias 
for vector.

(%i2) alias(vc, vector)$
(%i3) display2d:false$

(%i4) plane1: vc(x,y,z) = vc(1,2,3)+p*vc(4,5,6)+q*vc(7,8,9);
(%o4) vc(x,y,z) = q*vc(7,8,9)+p*vc(4,5,6)+vc(1,2,3)
(%i5) plane2: vc(x,y,z) = vc(3,2,1)+r*vc(6,5,4)+s*vc(9,8,7)$

These equations represent two planes in parameter form. Basically there is no 
simplification. 
I will now compute the common points. veq is a vector equation:

(%i6) veq: rhs(plane1) = rhs(plane2);
(%o6) q*vc(7,8,9)+p*vc(4,5,6)+vc(1,2,3) = s*vc(9,8,7)+r*vc(6,5,4)+vc(3,2,1)

To solve this equation I have to extract the three coordinate-equations:

(%i7) map(disp, sys: extract_equations(veq))$
7*q+4*p+1 = 9*s+6*r+3

8*q+5*p+2 = 8*s+5*r+2

9*q+6*p+3 = 7*s+4*r+1

Solving the system:

(%i8) params: algsys(sys,[p,q,r,s]);
(%o8) [[p = %r1,q = %r2,r = -1/3*(16*%r2+13*%r1+16),s = 1/3*(13*%r2+10*%r1+10)]]
(%i9) params: params, %r1=u, %r2=v$

Knowing the params which solve sys I can compute the common points:

(%i10) plane1, params;
(%o10) vc(x,y,z) = v*vc(7,8,9)+u*vc(4,5,6)+vc(1,2,3)

( The two planes turn out to be the same. )
In this case there is no restructuring of the expression necessary. Using plane2 is different:

(%i11) plane2, params;
(%o11) vc(x,y,z) = 1/3*(13*v+10*u+10)*vc(9,8,7)-1/3*(16*v+13*u+16)*vc(6,5,4)+vc(3,2,1)

Simplifying would look as ugly as the old listarith:true-form:

(%i12) %, vector_simp;
(%o12) vc(x,y,z) = vc(-2*(16*v+13*u+16)+3*(13*v+10*u+10)+3,
                      -5/3*(16*v+13*u+16)+8/3*(13*v+10*u+10)+2,
                      -4/3*(16*v+13*u+16)+7/3*(13*v+10*u+10)+1)

OK, you could expand, but this wouldn't really help. Alternatively I offer a function that 
allows to restructure this expression by explicitely indication of the parameters to factor out:

(%i13) vector_rebuild(%,[v,u]);
(%o13) vc(x,y,z) = v*vc(7,8,9)+u*vc(4,5,6)+vc(1,2,3)


That'all I have coded so far. I am at the very beginning.

Volker