A few weeks ago I realize there is a package for working with differential forms in SAGE. So, I’ve tried to take advantage of that!

This is what I’ve learnt so far.

# Define your manifold

If you work with differential forms you should know (probably better than me), that you define forms in a coordinate patch… rarely globally.

I’d like to start with something like this!

sage: reset() sage: # The variables sage: var('theta,phi,r') sage: var("bps", latex_name=r"\bar{\psi}") sage: var("bph", latex_name=r"\bar{\phi}") sage: var("bth", latex_name=r"\bar{\theta}") sage: # The coordinate system sage: coords = [r,theta, phi, bps, bth, bph] sage: U = CoordinatePatch((r,theta, phi, bps, bth, bph)) sage: Omega = DifferentialForms(U)

From a previous post a weird declaration of variables has been made.

But don’t lose yourself into the code!!!… the important here is:

## Define the differential forms

Differential form have to be defined… like this,

sage: A = DifferentialForm(Omega, 1) sage: A[1] = -1/4 sage: A[2] = 1/4*(-cos(theta) - sin(theta)) sage: A[3] = cos(bps)*sin(bth)*sin(bph) sage: A[4] = sin(bps)*cos(bth)*sin(bph) sage: A[5] = sin(bps)*sin(bth)*cos(bph)

The first line defines as an element of .

The rest of the lines are for setting the components of . Remember that the coordinates run from 0 to 6 in this example! 😛 And, of course, they are ordered strictly as we declared them, i.e.,

## Exterior Differentiation

Once the form has been declared, one might differentiate it by using the *diff* command,

sage: A.diff()

returns

## Showing the forms

It’s very useful to see the formulas in a nice written way… this is one of the features I love the more from SAGE, to see your form, use

sage: show(A)

## Wedge Product

Of course one of the most important operations when working with forms is the wedge product. For using this, try

sage: C = A.wedge(A.diff()) sage: show(C)

it vanishes. One might try to define another form,

sage: B = DifferentialForm(Omega,2) sage: B[0,1] = sin(bth)

Note that , and has only one non-vanishing component.

Thus, is calculated,

sage: A.wedge(B)

One can also define multiple wedge product,

sage: A.wedge(B.diff()).wedge(B)

Needless to say one can multiply a form by a function, or number.

## Simplifying a form

Forms have not implemented the *simplify_full* attribute, but their components, which are functions, do. So, after a very complicated calculation one might try to implement a long routine of simplification, say,

sage: D = A.wedge(B.diff()).wedge(B) for i in xrange(Omega.ngens()): for j in xrange(i+1, Omega.ngens()): for k in xrange(j+1, Omega.ngens()): for l in xrange(k+1, Omega.ngens()): for m in xrange(l+1, Omega.ngens()): D[i,j,k,l,m] = D[i,j,k,l,m].simplify_full()

In the above, `Omega.ngens()`

returns the dimension of the patch. Additionally, each index runs from the value of the previous plus one, in order to avoid repetition (due to anti-symmetric property) or the zeros values.

if someone find a better way, doesn’t hesitate in post a comment!!! 🙂

Well, I think this is much of it! I’ll keep you posted, in case I learn more about ot.

Enjoy life! and Happy Valentine’s day! 😉

Dox

on March 2, 2011 at 8:35 pm |SAGE tip: More about Differential Forms « Doxdrum's Blog[…] a previous post we discuss the definition of the coordinated patch on a manifold, how to define differential forms, […]