Ask Your Question

Defining manifolds in a systematic way.

I'm working on writing an algorithm that does some specific computations with manifolds. I would like to be able to simply enter 2 numbers "p" and "q" which determine the manifold's dimension p*q, and have the algorithm run right from there. This requires having Sage set up the manifold right from those two numbers. I'm having trouble at the level of defining the chart. Below I begin a naive attempt.

Sage: p=1
Sage: q=2
Sage: M = Manifold((2*p*q), 'M', field='complex')
Sage: U = M.open_subset('U')
Sage: x = list(var('x_%d' %i) for i in range((2*p*q)))


Everything works fine up to this point. Now, I need to define variables for a chart for this manifold. I would like to do something like

Sage: c.<x[0],x[1],x[2],x[3]> = U.chart()


where I'm using the variables I've defined as my coordinates. However, Sage doesn't allow me to do this. Furthermore, even if I could, I'm not sure how I would set this up so I didn't have to type in the variables by hand, because I want to set it up so I just have to feed Sage p and q, and let it build the manifold on its own.

edit retag close merge delete

1 Answer

Sort by » oldest newest most voted

See the documentation on charts, particularly the arguments coordinates and names.

For example, you can do the following:

sage: x = U.chart(names=tuple('x_%d' % i for i in range(2*p*q)))
sage: x[:]
(x_0, x_1, x_2, x_3)
sage: x[0]
x_0


Another example, upon request:

x_indices = [(i,j,k) for i in range(2) for j in range(2) for k in range(2)]
M = Manifold(len(x_indices), 'M', field='complex')
U = M.open_subset('U')
x_names = tuple('x_{}_{}_{}'.format(i,j,k) for (i,j,k) in x_indices)
x_coords = U.chart(names=x_names)
x = dict(zip(x_indices,x_coords))


Then you can do:

sage: x[(0,0,0)]
x_0_0_0

more

Comments

How do I define a frame then? My naive attempt in analogy to the usual situation,

Sage: eU = x.frame()


but this doesn't work.

( 2019-07-10 19:06:07 +0200 )edit

That should work (and it does for me). What version of SageMath are you running?

( 2019-07-10 20:00:34 +0200 )edit
1

Oh, I just tried it again and it worked, must have made a typo the first time, thanks.

( 2019-07-10 20:06:16 +0200 )edit

Hey, is there a way to do this in such a way that the coordinates have multiple indices, like x[(i,j,k)]?

( 2019-08-19 18:10:02 +0200 )edit

Sure, I added another example.

( 2019-08-19 18:55:41 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Stats

Asked: 2019-07-10 18:35:45 +0200

Seen: 121 times

Last updated: Aug 19 '19