I ran this same question by my girlfriend who teaches undergraduate
physics classes.  She isn't an experienced programmer, so concepts of
operator overloading and object oriented vs functional programming
styles are not on here mind, but she has taught a lot of the core
required physics classes to both majors and non-majors at UC Davis, so
she has a lot of experience interacting with undergraduates on this
kind of thing.  Surprisingly, she thought the operator interface
seemed the clearest because once you learn the meanings of the &, ^,
|, it is about as close to what you would write on a black board or on
paper as you could hope for.

That said, there are issues with &, ^, and |, namely it is unlikely to
know what they mean unless you read the docstrings of Vector or read
the Sphinx documentation that Gilbert has written.  Additionally, as
Matthew brings up using '^' for the cross product may visually
conflict with the wedge operator.  Then again, it doesn't seem to hurt
to have overlapping syntax's, as long as they are both well
documented.

I vote for keeping the operators and the functions, and if any are
removed, to remove the methods.

If people have thoughts on any negative implications of implementing
multiple ways to perform the same thing, especially related to long
term maintenance of the code, it would be great to hear them.

~Luke

On Thu, Aug 11, 2011 at 12:14 PM, Gilbert Gede <gilbertg...@gmail.com> wrote:
> My Summer of Code project is writing a submodule of SymPy for creation of
> symbolic equations of motion for multibody systems. As part of this, I've
> implemented classes to represent vectors and dyadics. I have currently
> implemented three ways to do mathematical operations on vectors: an
> operator, a function, and a method interface.
> I think three interfaces for these operations is too many, and am looking
> for some input on which ones people prefer. The implemented interfaces look
> like:
> Cross product:
>>>> (vec1 ^ vec2)
>>>> cross(vec1, vec2)
>>>> vec1.cross(vec2)
> Dot product:
>>>> (vec1 & vec2)
>>>> dot(vec1, vec2)
>>>> vec1.dot(vec2)
> Outer product:
>>>> (vec1 | vec2)
>>>> outer(vec1, vec2)
>>>> vec1.outer(vec2)
> Here is one example where vector and dyadic quantities are used in the code.
> I is a dyadic, and omega and alpha are vectors.
>>>> -(I & alpha) - (omega ^ (I & omega))
>>>> -dot(I, alpha) - cross(omega, dot(I, omega))
>>>> -I.dot(alpha) - omega.cross(I.dot(omega))
>
> I'd appreciate people's opinions on:
> 1) Which is clearest?
> 2) Which would be easiest to teach?
> 3) Which is least error prone?
> I personally prefer the operator interface (&, ^, |), as I think once you
> learn what the three operators represent, it is clearer to read and write.
> I would especially value the input of anyone who would be interested in
> using this as part of teaching students.
> I've also made a poll here: http://www.surveymonkey.com/s/CK8HDMD
> Thanks,
> Gilbert
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to sympy@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
>



-- 
"Those who would give up essential liberty to purchase a little
temporary safety deserve neither liberty nor safety."

-- Benjamin Franklin, Historical Review of Pennsylvania, 1759

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to