Can the vectors and multivectors in the GA module work with arbitrary
sympy expressions?  i.e, if v is a GA vector, and s is a sympy
expression, does it make sense to do: s*v?  Is the result of type Mul
or of something else?

~Luke

On Mon, May 9, 2011 at 5:42 PM, Alan Bromborsky <[email protected]> wrote:
> On 05/09/2011 08:30 PM, Luke wrote:
>>
>> Here is a more explicit example of what Gilbert is talking about:
>> In [1]: from sympy import *
>> In [2]: from pydy import *
>> In [3]: x = symbols('x')
>> In [4]: N = ReferenceFrame('N')
>> In [5]: type(N[1])
>> Out[5]: pydy.pydy.UnitVector
>> In [9]: test = x*N[1] + x*x*N[2]
>> In [10]: type(test)
>> Out[10]: sympy.core.add.Add
>> In [11]: test2 = Vector(test)
>> In [12]: test2
>> Out[12]: x*n1>  + x**2*n2>
>> In [13]: type(test2)
>> Out[13]: pydy.pydy.Vector
>> In [14]: test3 = x*test2
>> In [15]: test3
>> Out[15]: x*x*n1>  + x**2*n2>
>> In [16]: type(test3)
>> Out[16]: sympy.core.mul.Mul
>>
>> As you can see, in Out[15], the multiplication of x and test2 is being
>> printed in a way that doesn't make sense, and in Out[16] we can see
>> that this multiplication isn't resulting in another Vector object,
>> instead it is of type Mul.
>>
>> Currently, to create a Vector object, you need to explicitly call
>> Vector on a sympy expression that is composed from terms that have
>> UnitVectors in them, or pass a dictionary with UnitVectors as the keys
>> and sympy expressions as the values.
>>
>> Once you have that Vector object, you might want to multiply it by a
>> scalar (sympy expression) and have it return another Vector object.
>> This could be done using a somewhat user unfriendly approach:
>>
>> In [22]: Vector(dict([(k, x*v) for k, v in test2.dict.items()]))
>> Out[22]: x**2*n1>  + x**3*n2>
>>
>> This gets the job done, but it isn't very convenient.
>>
>> So basically, the question is whether
>> 1)  Is it easy enough in Sympy to make something like x*aVectorObject
>> evaluate to another Vector object?  Where the x is a "scalar part"
>> (probably a sympy Expression) and aVectorObject is of type Vector
>> (which currently subclasses from Basic)?
>> 2)  Or is it ok to have to be more explicit about creating Vector
>> objects by using the notation Vector(x**2*N[1] + x**3*N[2]) or
>> Vector({N[1]: x**2, N[2]:x**3})?
>>
>> Additionally, there are other types of products that make sense for
>> Vector and UnitVector objects, namely dot, cross, and outer products.
>> So the stuff above would only be for multiplying a Vector by a scalar.
>>  I think all the other types of products have to make use of explicit
>> method calls since there would be no way to know which type of product
>> would be implied.
>>
>> ~Luke
>>
>> On Mon, May 9, 2011 at 4:23 PM, Gilbert Gede<[email protected]>
>>  wrote:
>>>
>>> In PyDy (which we plan to merge into SymPy.physics.classical this summer)
>>> Vector is one of the classes already implemented (along with UnitVector).
>>>  Vectors extend Basic, and UnitVector extend Expr.
>>> The way it works now, you can't use Vector as part of a SymPy expression:
>>> In [57]: test
>>> Out[57]: x*n1>  + x*a1>
>>> In [58]: x*test*x
>>> Out[58]: x**2*x*n1>  + x*a1>
>>> Do people want to be able to use Vector (which comes with dot, cross,
>>> outer
>>> products, and derivative (between reference frames) functions
>>> implemented)
>>> in SymPy expressions?  Or is it the type of thing no one really wants?
>>> I'm looking forward to getting to work on PyDy&  SymPy this summer.
>>> -Gilbert
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "sympy" group.
>>> 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/sympy?hl=en.
>>>
>>
>>
> GA module has vectors and multivectors.  See documentation
> http://docs.sympy.org/dev/modules/galgebra/GA/GAsympy.html
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> 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/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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to