Feeds:
Posts
Comments

Posts Tagged ‘Forms’


In a previous post we discuss the definition of the coordinated patch on a manifold, how to define differential forms, wedge them or calculate their exterior derivative… even simplify’em.

This time a zero form will be defined and a list of forms will be created… So, let’s begin!

Define a 0-form

Once created the coordinated patch and the differential forms algebra

sage: reset()
sage: var('t,x,y,z')
sage: U = CoordinatePatch((t,x,y,z))
sage: Omega = DifferentialForms(U)

A 0-form is defined as an element of \Omega^0(U), but the value of the 0-form is given inside the declaration command,

sage: A = DifferentialForm(Omega, 0, exp(x*y))

I tried addition, multiplication, wedge product and exterior differentiation on 0-forms and they worked!

Of course you can combine them with forms of different degrees.

New method of defining a form

I wrote to Joris this morning… but before he was able to answer, from the documentation of the differential form package.

When one calls the generators of the differential form,

sage: Omega.gen(1)
dx

and the result is a differential form… Thus, one can assign a form as follow,

sage: A = sin(x)* Omega.gen(2)
sage: B = cos(y) * Omega.gen(0)
sage: C = sin(z) *Omega.gen(1)
sage: D = cos(y) * Omega.gen(2)

And this forms can be wedged, differentiated, et cetera. 🙂

List of forms

Finally, after discovering the above behavior I tried the following, a list of differential forms ;-), for example,

sage: pro = matrix([[A, B], [C, D]])
sage: for i in range(2):
...       for j in range(2):
...           show(pro[i,j].diff())

returns
cos(x)dx\wedge dz
sin(y)dx\wedge dy
-cos(z)dy\wedge dz
-sin(y)dy\wedge dz

This implies that somehow one can manage a series of forms by using list properties… I expect to go deeper on this subject in the future! 😀

Enjoy people!!!

Dox

Read Full Post »


This post is more about a personal opinion.

Most of the followers of my blog know that I’m a devote Linux user, and that I prefer Open Source than any other software.

It is clear than most business people prefer to spend money for a piece of software which get the job done. And additionally, developers will align with the mainstream vendor… or in some cases, money convince them.

The last to months I’ve been working in some supergravity theory, and you might imagine that even a easy calculation is messy… at least, and will take a huge amount of time to complete.

On the other hand Mathematica offers a huge (really huge) toolkit for mathematicians, physicists, economists, and so on. I admit it… I sort of hate to use Mathematica, really do!, but although we all know is amazing as a toolkit.

Nonetheless, most scientist (specially those who grow up using this kind of software), trust the results as if it was not possible to be wrong!!! But if you look further…. there is a book, as enormous as Mathematica user’s guide, of bugs :-S

A year ago one of my office mate found two bugs: one in an integration routine, and another in a loop routine!!!! A LOOP ROUTINE… Do you know someone who has never used a loop routine? How many possible errors have been publish and propagated?! Moreover, I found a bug myself… in the plot function 😐

Since then I use SAGE… or Python, so I’ve spent a lot of time learning, developing and proving routines, asking in the help channels and so on!

I know that this alternatives are far away from Mathematica or Maple or whatever your favourite calculation software is… but imagine!

Today I found a Mathematica package for computing GR tensors, you can use differential forms, first order formalism, redefine quantities in term of vielbeins, write equations using differential forms (with Hodge star and so on)… Incredible! Isn’t it?

Who develop this package? It was not Wolfram!!!! If I were the developer of this marvelous package, I’d prefer to kill myself before writing such a thing for a product which is not available for everyone. Exaggeration?! yes, may be… but I’m citizen of a wealth country, full of poor people. Yes, I also know that any pirate page has a cracked copy of Mathematica… but why should I crack a program?

I don’t want to crack Mathematica… I want an open source software which do as Mathematica. Sorry, I correct: I want an open source software which do BETTER than Mathematica.

My bet is on SAGE, and that’s why I’m willing to contribute with this project.

Live wide and prosper! Enjoy!

Dox

Read Full Post »


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:

  • Seven variables have been declared,
  • These are converted into a list,
  • and also are the coordinated of the Coordinate Patch.
  • Finally, \Omega is the algebra of differential forms. Just like \Omega^\bullet(M), where M is the manifold (in this case the patch).
  • 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 A as an element of \Omega^1(M).

    The rest of the lines are for setting the components of A. 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.,

    A = -\frac{1}{4}d\theta -\frac{1}{4}(\cos(\theta) + \sin(\theta))d\phi + \cos(\bar{\psi})\sin(\bar{\theta})\sin(\bar{\phi})d\bar{\psi} +\cdots

    Exterior Differentiation

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

    sage: A.diff()

    returns

    (\frac{1}{4} \, \sin\left(\theta\right) - \frac{1}{4} \, \cos\left(\theta\right)) d \theta \wedge d \phi

    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 B\in \Omega^2(M), and has only one non-vanishing component.

    Thus, A\wedge B 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

    Read Full Post »


    Hi everyone, today I start to write a new class for dealing with non-Abelian forms, i.e., forms with values in a certain Lie-algebra. This could be really useful when computing Yang-Mills theories in physics.

    So, I started by defining a new object which have two entries, a differential form and a matrix, and call it nAform. The code I wrote was,

    class nAform(object): 
        def __init__(self, a, b): 
            self._form = a 
            self._matrix = b 
        def __add__(self, other): 
            if isinstance(other, nAform): 
                if (self._matrix == other._matrix): 
                    return nAform(self._form + other._form, self._matrix) 
                else: 
                    return NotImplemented 
            return NotImplemented 
        def __mul__(self, other): 
            if isinstance(other, nAform): 
                return nAform(self._form.wedge(other._form), self._matrix.commutator(other._matrix)) 
            return NotImplemented 
        def diff(self): 
            return nAform(self._form.diff(), self._matrix) 
        def __repr__(self): 
            return str((self._form, self._matrix)) 
        def __str__(self): 
            return self.__repr__()

    Explanation

    One should enter a couple of arguments when defining the nAform object. The __init__ attribute recognize them.

    Then an addition attribute is defined, this is incomplete!!!

    Another attribute is the multiplication, which take the wedge product of the forms and the commutator of the matrices.

    I also implement the exterior derivative on nAform objects.

    Finally the __repr__ and __str__ are attributes for returning the data.

    TO-DO

  • I couldn’t implement the addition of nAform’s if the matrices are different. As
    Nicolas M. Thiery note, this objects should define a Monoid (or something quit close to it). But my programming skills are not so developed.
  • It would be great if one could define the multiplication by a constant or function.
  • The show attribute is not implemented, but one can show either forms of matrices by themselves… I think that is someone knows how they work, would be easy to do that! 😉
  • One could try to implement the simplification attributes on differential forms.
  • I don’t remember exactly why I was looking for it, but I think could be useful to define and attribute on forms which show the generator, like .gens(), but for a given differential form, say
    sage: x, y, z = var('x, y, z')
    sage: U = CoordinatePatch((x, y, z)); U
    Open subset of R^3 with coordinates x, y, z
    sage: F = DifferentialForms(U); F
    Algebra of differential forms in the variables x, y, z
    sage: F.gens()
    (dx, dy, dz)
    sage: F.ngens()
    3

    I’d like one which do like this,

    sage: form1 = DifferentialForm(F, 1); form1.ngens()
    3
    sage: form1 = DifferentialForm(F, 1); form1.gens()
    (dx, dy, dz)
    form2 = DifferentialForm(F, 2); form2.ngens()
    3
    sage: form1 = DifferentialForm(F, 1); form1.gens()
    (dx/\dy, dy/\dz, dz/\dx)
  • Simple SAGE sheet

    Worksheet

    Hope you can help me with these plenty tasks.

    Enjoy!

    Dox

    Read Full Post »