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.Wed, 19 Jun 2019 19:57:49 +0200How to change/set variables?https://ask.sagemath.org/question/46945/how-to-changeset-variables/I created a list of formal variables that I want to work with under addition, multiplication etc. in the following way:
g = list(var('g_%d' % i) for i in rang(4))
Specifically I'm working with differential forms
M = Manifold(4, 'M', field='complex')
U = M.open_subset('U')
c_xyXY<x, y, X, Y>=U.chart()
eU = c_xyXY.frame()
d = [[M.diff_form(2, name='d_{}{}'.format(j, i)) for i in range(2)] for j in range(2)]
d[0][0] [eU, 2, 0] = g[0]
d[0][1] [eU, 3, 0] = g[1]
d[1][0] [eU, 2, 1] = g[2]
d[1][1] [eU, 3, 1] = g[3]
I then want to set the variables to something specific like
g[0] = x^2
but when I try to display this I get
d[0][0].display(eU)
d_00 = -g_0dx/\dX
What I want is
d_00 = -x^2dx/\dX
EDIT: The question as originally asked has been sufficiently answered by eric_g below. However I'm still having difficulty with a more complicated version of the same set-up, which I present here:
https://ask.sagemath.org/question/46993/update-how-to-changeset-variables/sum8tionWed, 19 Jun 2019 19:57:49 +0200https://ask.sagemath.org/question/46945/