Why do you need that extra minus? I believe my original function was
correct - perhaps you are thinking of the expansion in 2x2 minors? Or
am I missing something?
-Marshall
On Mar 30, 12:00 pm, "David Joyner" <[EMAIL PROTECTED]> wrote:
> On 3/30/07, Marshall Hampton <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Here's a function definition to avoid using maxima:
>
> > def cross_product(vec1,vec2):
> > r'''
> > This returns the cross product of 2 three-dimensional vectors.
>
> > INPUT:
> > vec1 - the first 3D vector in the cross product
> > vec2 - the second 3D vector in the cross product
>
> > OUTPUT:
> > A 3D vector
>
> > EXAMPLES:
> > basic usage:
> > sage: cross([1,2,3],[2,3,4])
>
> sage: cross_product([1,2,3],[2,3,4])
>
> > [-1, 2, -1]
>
> > NOTES:
> > This is a crude first attempt.
> > '''
> > x,y,z = QQ['x,y,z'].gens()
> > mat = matrix([[x,y,z],vec1,vec2])
> > d = det(mat)
> > return [d(1,0,0),d(0,1,0),d(0,0,1)]
>
> return [d(1,0,0),-d(0,1,0),d(0,0,1)]
>
>
>
> > On Mar 30, 11:33 am, "Marshall Hampton" <[EMAIL PROTECTED]> wrote:
> > > Hi,
>
> > > I am not an expert on SAGE but I was curious about your question and
> > > tried to find an answer. I am curious about better ways to do this.
>
> > > Anyway, the first thing I found that works is to use maxima's vect
> > > package. For some reason it uses '~' as the cross-product operator.
> > > As an example:
>
> > > sage: maxima.load('vect')
> > > ?\/Users\/mh\/sage\ - 2\.1\.0\.1\/local\/share\/maxima\/5\.11\.0\/share
> > > \/vector\/vect\.mac
> > > sage: maxima('express([1,2,3]~[2,3,4])')
> > > [ - 1,2, - 1]
>
> > > At some point it would be nice to have a native SAGE way to do this
> > > and other differential form computations; given the developer's
> > > interest in modular forms this probably wouldn't be extremely
> > > difficult.
>
> > > -M.Hampton
>
> > > On Mar 30, 4:58 am, "microdev" <[EMAIL PROTECTED]> wrote:
>
> > > > hello,
>
> > > > I have tried the dot product :
>
> > > > v = (1,2,3)
> > > > v1 = (2,4,6)
> > > > v.dot_product(v1) -> ok
>
> > > > and for the cross product?
>
> > > > thank you for help..
>
> > > > Felix
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---