Ask Your Question
0

Define a differential form recursively

asked 2014-01-16 14:04:02 +0100

rfauffar gravatar image

I have the following code:

n=3;
x = list(var('x_%d' % i) for i in (1..2*n));
U = CoordinatePatch(x);
F = DifferentialForms(U);
w = DifferentialForm(F,2);
  for j in range(2*n-1):
     for k in range(2*n-1):
        w[j,k]=j+k;
w;

It's supposed to define a differential form whose (j,k)th member is j+k, but this code just returns the 0 differential form. I've tried many variations using for, while, etc., but none seem to work. I suspect it's because a differential form is stored as a dictionary, but since I'm a beginner in Sage, I have no idea what to do. Any help is appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-01-20 17:01:56 +0100

kcrisman gravatar image

I seem to get something reasonable here, not the zero form.

??????????????????????????????????????????????????????????????????????
? Sage Version 5.12, Release Date: 2013-10-07                        ?
? Type "notebook()" for the browser-based notebook interface.        ?
? Type "help()" for help.                                            ?
??????????????????????????????????????????????????????????????????????
sage: n=3;
sage: x = list(var('x_%d' % i) for i in (1..2*n));
sage: U = CoordinatePatch(x);
sage: F = DifferentialForms(U);
sage: w = DifferentialForm(F,2);
sage:   for j in range(2*n-1):
....:          for k in range(2*n-1):
....:                 w[j,k]=j+k;
....:         
sage: w
-1*dx_1/\dx_2 + -3*dx_2/\dx_3 + 0*dx_1/\dx_1 + 0*dx_4/\dx_4 + 0*dx_3/\dx_3 + 0*dx_5/\dx_5 + -5*dx_2/\dx_5 + -2*dx_1/\dx_3 + -4*dx_2/\dx_4 + -5*dx_3/\dx_4 + -4*dx_1/\dx_5 + -6*dx_3/\dx_5 + -3*dx_1/\dx_4 + -7*dx_4/\dx_5 + 0*dx_2/\dx_2

I will point out that perhaps you are using 1-based counting, but Python starts counting at 0. Is this what you are looking for?

sage: for j in range(2*n-1):
....:     for k in range(2*n-1):
....:         w[j,k] = j+1+k+1
....:         
sage: w
-3*dx_1/\dx_2 + -5*dx_2/\dx_3 + 0*dx_1/\dx_1 + 0*dx_4/\dx_4 + 0*dx_3/\dx_3 + 0*dx_5/\dx_5 + -7*dx_2/\dx_5 + -4*dx_1/\dx_3 + -6*dx_2/\dx_4 + -7*dx_3/\dx_4 + -6*dx_1/\dx_5 + -8*dx_3/\dx_5 + -5*dx_1/\dx_4 + -9*dx_4/\dx_5 + 0*dx_2/\dx_2

I don't know whether the negatives are what you want or not, nor why the necessarily zero differentials are even included, but I've never used this functionality before, so you will have to peruse the documentation for technical points like this.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2014-01-16 14:04:02 +0100

Seen: 306 times

Last updated: Jan 20 '14