Can sympy do tensor based Euler-Lagrange?

119 views
Skip to first unread message

Joseph Smidt

unread,
Mar 10, 2014, 1:24:27 PM3/10/14
to sy...@googlegroups.com
Hey everyone,

     From documentation I see sympy has a tensor package (awesome) and I see some discussion on being able to calculate Eular-Lagrange equations. However, I was wondering if sympy can calculate tensor based Euler-Lagrange equations of motion. 

    For, example, let's take the example of electricity and magnitism [1].  Here our Lagrangian = 1/4 F_uv F^uv - A_a J^a. Here F_uv is the maxwell tensor, A_a is the E&M vector potential and J^a is the source of that potential.  Varying this action with respect A_a gives:

d(F^uv)dx_u = J^v, the standard E&M equation of motion.   See the wikipedia link below for a better description.

   Does anyone know if sympy is equipped to handle tensor based Eular-Lagrange equations equations such as these? If so, how would I go about solving for this E&M example? Thanks.

Alan Bromborsky

unread,
Mar 10, 2014, 2:00:40 PM3/10/14
to sy...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/904a5890-3d53-4a42-812c-6648efda3541%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
For an alternate approach to tensors see sections 8.2.4 - 8.2.6 in attached pdf.  Also see chapter 7 in attached for alternate treatment of tensors.
LagrangianFieldTheory.pdf

Joseph Smidt

unread,
Mar 10, 2014, 2:16:41 PM3/10/14
to sy...@googlegroups.com
Brombo,

    I appreciate that there is an alternative formulation of E&M but I am wondering is sympy has the capability to do these calculations? If so, is there any relevant documentation or examples in sympy you could point to or provide so that I can see?  Thanks.

F. B.

unread,
Mar 10, 2014, 5:36:28 PM3/10/14
to sy...@googlegroups.com

On Monday, March 10, 2014 7:16:41 PM UTC+1, Joseph Smidt wrote:
Brombo,

    I appreciate that there is an alternative formulation of E&M but I am wondering is sympy has the capability to do these calculations? If so, is there any relevant documentation or examples in sympy you could point to or provide so that I can see?  Thanks.

The current approach to symbolic tensors, encoded in sympy.tensor.tensor, does not support that, nor does it support partial derivatives or operators on tensors.

Aaron Meurer

unread,
Mar 10, 2014, 9:16:29 PM3/10/14
to sy...@googlegroups.com
How similar is that to the idea from
https://github.com/sympy/sympy/issues/5858? Maybe one could be
implemented and use to make the other work?

This would all be great work for a GSoC project, by the way.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/f5d7a6bb-171f-41ca-890b-c144edc343a8%40googlegroups.com.

Joseph Smidt

unread,
Mar 11, 2014, 12:34:19 AM3/11/14
to sy...@googlegroups.com
> This would all be great work for a GSoC project, by the way. 

This would be a great project if it could be done because in the theoretical physics world deriving equations of motian from tensorial actions (Like this E&M example)  is very common and can lead to pages of algebra.

Thanks.

Sergey Kirpichev

unread,
Mar 13, 2014, 10:52:48 AM3/13/14
to sy...@googlegroups.com
On Monday, March 10, 2014 9:24:27 PM UTC+4, Joseph Smidt wrote:
   Does anyone know if sympy is equipped to handle tensor based Eular-Lagrange equations equations such as these?

Yes, with euler_equations from calculus module.  But it doesn't support tensor notation directly.

Alan Bromborsky

unread,
Mar 13, 2014, 11:29:40 AM3/13/14
to sy...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.

For more options, visit https://groups.google.com/d/optout.
If you are talking about Lagrangian field theory the question is how do you take a derivative with respect to the field and the gradient of the field and not with respect to the position vector the field is a function of.

Sergey Kirpichev

unread,
Mar 14, 2014, 10:52:10 AM3/14/14
to sy...@googlegroups.com
On Thursday, March 13, 2014 7:29:40 PM UTC+4, brombo wrote:
If you are talking about Lagrangian field theory the question is how do you take a derivative with respect to the field and the gradient of the field and not with respect to the position vector the field is a function of.

The docstring of euler_equation function has a trivial example of scalar field.  There should not be any problems for more complex field (e.g. for electrodynamics).
Reply all
Reply to author
Forward
0 new messages