ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 25 Jun 2019 18:45:38 +0200(Update) How to change/set variables?https://ask.sagemath.org/question/46993/update-how-to-changeset-variables/ I asked a simplified version of this question, and got an answer here:
https://ask.sagemath.org/question/46945/how-to-changeset-variables/
However I'm still having difficulty with a more complicated version of the same set-up, which I present here. Essentially I want to take a trace of an exponential of a matrix valued in forms. When I try running it with the forms I want, the run time takes far too long, certainly over an hour on my laptop. However, it's much shorter if I use forms with symbolic coefficients. What follows below is my attempt at computing the forms I want with symbols first, and then trying to set the coefficients at the end.
To start, I have
sage: M = Manifold(6, 'M', field='complex')
sage: U = M.open_subset('U')
sage: c_xyzXYZ.<x,y,z,X,Y,Z> = U.chart()
sage: eU = c_xyzXYZ.frame()
sage: var('x,y,z,X,Y,Z')
I create some symbolic differential forms in the following way,
sage: g = {(i, j, k): var("g_{}{}{}".format(i, j, k), latex_name="g_{{{}{}{}}}".format(i,
sage:... j, k)) for i in range(9) for j in range[3, 4, 5] for k in range(3)}
sage: f = [M.diff_form(2, name='f_{}'.format(i)) for i in range(9)]
sage: for i in range(9):
sage: for j in [3, 4, 5]:
sage: for k in range(3):
sage: f[i][eU, j, k] = g[(i, j, k)]
sage: F = [M.mixed_form(comp=[0, 0, f[i], 0, 0, 0, 0]) for i in range(9)]
Now I create a matrix valued in differential forms (I'm running the current beta version), define an identity matrix of mixed forms, define an exponential function (the usual .exp() for matrices doesn't seem to work when the matrix is valued in mixed forms)
sage: FF = Matrix([[F[0], F[1], F[2]], [F[3], F[4], F[5]], [F[6], F[7], F[8]]])
sage: G = FF.apply_map(lambda f: (I/2*pi)*f)
sage: I_00 = M.mixed_form(comp=[1, 0, 0, 0, 0, 0, 0])
sage: I_01 = M.mixed_form(comp=[0, 0, 0, 0, 0, 0, 0])
Id = matrix([[I_00, I_01, I_01], [I_01, I_00, I_01], [I_01, I_01, I_00]])
sage: EXP = lambda f: Id+f+(f^2).apply_map(lambda g: (1/2)*g)
sage: ...+(f^3).apply_map(lambda g: (1/6)*g)
sage: ...+(f^4).apply_map(lambda g: (1/24)*g)
sage: ...+(f^5).apply_map(lambda g: (1/120)*g)
sage: ...+(f^6).apply_map(lambda g: (1/720)*g)
Finally I compute the trace of the exponential of the matrix G,
sage: E = EXP(G)
sage: CH = E.trace()
Now if one trys to display CH in the frame eU, after about 10 minutes, this will print out some massive mixed form with coefficients being the g[(i, j, k)]. I now want to change the components of these forms to explicit forms. For simplicity of the example, lets just assume I want them all to be x^2.
sage: for i in range(9):
sage: for j in [3, 4, 5]:
sage: for k in range(3):
sage: g[(i, j, k)] = x^2
Than I update the forms as suggested in the answer to my original question,
sage: for i in range(9):
sage: for j in [3, 4, 5]:
sage: for k in range(3):
sage: f[i][eU, j, k] = g[(i, j, k)]
If you trying displaying any f, it's clear that this has worked. However, when I try to write
sage: CH.display(eU)
all the components are still in terms of g_{}{}{}, they have not been changed to x^2. Is there some way to do this without having to run the computation of CH again? The whole point of this convoluted example was to avoid doing this computation with the functions I'm actually interested in, and only set them at the end.sum8tionTue, 25 Jun 2019 18:45:38 +0200https://ask.sagemath.org/question/46993/