# Setting the components of a differential form systematically.

Suppose for some p and q we have a manifold

Sage: p=1
Sage: q=2

Sage: M = Manifold((2*p*q), 'M', field='complex')
Sage: U = M.open_subset('U')
Sage: x = U.chart(names=tuple('x_%d' % i for i in range(2*p*q)))
Sage: eU = x.frame()


and some differential forms

Sage: d = {(i): var("d_{}".format(i)) for i in range(2*p*q)}

Sage: for i in range(2*p*q):
Sage:     d[i] = M.diff_form(i)


I want to construct and/or inspect components of these differential forms in a systematic way, which is to say I want to be able to iterate over the components. So for example, one way in which I've tried to do this is to create lists.
For example, if we let

Sage: R = [eU, 0, 1]


I would want to say

Sage: d[2]R = 1


but this gives me a syntax error.
I've also tried something like

Sage: S = [0, 1]
Sage: d[2][eU, :]S = 1


but again I get a syntax error.

edit retag close merge delete

Sort by » oldest newest most voted

You should write

sage: d[2][R] = 1


Indeed, when R is the list [eU, 0, 1], as in your example, the above is equivalent to

sage: d[2][eU, 0, 1] = 1


Side note: in your example, the line

sage: d = {(i): var("d_{}".format(i)) for i in range(2*p*q)}


is useless, because the elements of the dictionary d are fully redefined in the two lines that follow:

sage: for i in range(2*p*q):
sage:     d[i] = M.diff_form(i)


If you want to give names to the differential forms d[i], you could write simply

sage: d = {i: M.diff_form(i, name="d_{}".format(i)) for i in range(2*p*q)}


Then

sage: d[2]
2-form d_2 on the 4-dimensional complex manifold M
sage: R = [eU, 0, 1]
sage: d[2][R] = 1
sage: d[2].display()
d_2 = dx_0/\dx_1

more