# 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,x,x,x> = 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

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
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

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.

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

1

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

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