Issue 16: objects with indices (tensors)
http://code.google.com/p/sympy/issues/detail?id=16

Comment #9 by [EMAIL PROTECTED]:
Hi, I've been aware of Sympy for about a year and have kept an eye on it  
since then.
I need to do some (and eventually lots) of calculations involving indices.  
Playing
around a bit with some of the ideas on this page, I have written some  
prototype code
that lets Sympy manipulate indices.

I've attached a patch, and I hope I got the format etc right.

I've used the notation ([i], [j,k]) for example to denote an indexed object  
with one
lower index i and two upper indices, j and k.

Example usage:
>>> from sympy.indexed import *
>>> from sympy import *
>>> i, j, k, l = symbols('i', 'j', 'k', 'l')
>>> theta, phi = symbols(r"\theta", r"\phi")
>>> g = Indexed('g', [i,j], components = ((1,0), (0, sin(theta)**2)))
>>> g([2,2])
sin(\theta)**2
>>> g([i,j])
g([i, j])
>>> einstein_sum(g([i,i]))
1 + sin(\theta)**2
>>> einstein_sum(g([i,j]) * g([], [j,k])) # Second list of indices are  
superscript
g([i, 1])*g([], [1, k]) + g([i, 2])*g([], [2, k])

There is a fair amount of framework there but not much usability yet. I'm  
having
trouble figuring out how to handle differentiation since \delta_1(g_{ij})  
really
means the derivative of g^{ij} in the first coordinate direction, but  
substituting
the indices in when calculating the einstein sum would give diff(g([i,j]),  
1) which
doesn't work as needed.

Is there a neat way I can intercept diff(g([i,j]), 1) to replace 1 with the  
required
coordinate? I think anything else is going to be ugly.

The other next step is to allow an expression like einstein_sum(g([i,j]) *  
g([],
[j,k])) to be turned into another indexed object with indices, ([i],[j])

I'm not sure if this sort of implementation fits the requirements for a  
system in
Sympy but I need it for my own work anyway so I'm happy to develop it  
regardless.
Having it able to integrate well into Sympy would be a definite plus  
though, so
feedback is appreciated.

Attachments:
        indexed_prototype.patch  17.2 KB
          0 bytes



-- 
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

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

Reply via email to