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.Thu, 13 Feb 2020 10:34:31 +0100Lie bracket of derivations over polynomial ringhttps://ask.sagemath.org/question/49881/lie-bracket-of-derivations-over-polynomial-ring/I want to take the Lie bracket of derivations defined for an arbitrary polynomial ring. Using the notation for injecting variables into the global scope:
E.<x0,x1> = QQ[]
M = E.derivation_module()
f=(x1*M.gens()[0])
g=x0*M.gens()[1]
f.bracket(g)
gives `-x0*d/dx0 + x1*d/dx`. But I want to be able to construct vector fields programmatically for an arbitrary number of `x0, x1, x2, ..., xn` so I tried the following:
E = QQ[['x%i'%i for i in range(2)]]
E.inject_variables()
M = E.derivation_module()
f=(x1*M.gens()[0])
g=x0*M.gens()[1]
f.bracket(g)
which fails to take the Lie bracket with `TypeError: unable to convert x1 to a rational` (which causes another error `TypeError: Unable to coerce into background ring.`) ... which looks a bit like something is not right? or is this just not a permissible way to construct derivations in sagemath? or is the only way to do this using SageManifolds?
E = EuclideanSpace(2, coordinates='Cartesian', symbols='x0 x1')
U = E.default_chart()
f = U[2]*U.frame()[1]
g = U[1]*U.frame()[2]
f.bracket(g).display()
gives `-x0 e_x0 + x1 e_x1`
Wed, 12 Feb 2020 05:58:22 +0100https://ask.sagemath.org/question/49881/lie-bracket-of-derivations-over-polynomial-ring/Answer by rburing for <p>I want to take the Lie bracket of derivations defined for an arbitrary polynomial ring. Using the notation for injecting variables into the global scope:</p>
<pre><code>E.<x0,x1> = QQ[]
M = E.derivation_module()
f=(x1*M.gens()[0])
g=x0*M.gens()[1]
f.bracket(g)
</code></pre>
<p>gives <code>-x0*d/dx0 + x1*d/dx</code>. But I want to be able to construct vector fields programmatically for an arbitrary number of <code>x0, x1, x2, ..., xn</code> so I tried the following:</p>
<pre><code>E = QQ[['x%i'%i for i in range(2)]]
E.inject_variables()
M = E.derivation_module()
f=(x1*M.gens()[0])
g=x0*M.gens()[1]
f.bracket(g)
</code></pre>
<p>which fails to take the Lie bracket with <code>TypeError: unable to convert x1 to a rational</code> (which causes another error <code>TypeError: Unable to coerce into background ring.</code>) ... which looks a bit like something is not right? or is this just not a permissible way to construct derivations in sagemath? or is the only way to do this using SageManifolds?</p>
<pre><code>E = EuclideanSpace(2, coordinates='Cartesian', symbols='x0 x1')
U = E.default_chart()
f = U[2]*U.frame()[1]
g = U[1]*U.frame()[2]
f.bracket(g).display()
</code></pre>
<p>gives <code>-x0 e_x0 + x1 e_x1</code></p>
https://ask.sagemath.org/question/49881/lie-bracket-of-derivations-over-polynomial-ring/?answer=49905#post-id-49905You can do it like this:
E = PolynomialRing(QQ, 2, names='x')
x = E.gens()
M = E.derivation_module()
ddx = M.gens()
f=x[1]*ddx[0]
g=x[0]*ddx[1]
f.bracket(g)
Output:
-x0*d/dx0 + x1*d/dx1
You can pass `names` a list if you want to be more picky (and then you can omit the number of variables, `2` above, because it will be the length of the list).Thu, 13 Feb 2020 10:34:31 +0100https://ask.sagemath.org/question/49881/lie-bracket-of-derivations-over-polynomial-ring/?answer=49905#post-id-49905