ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 19 Feb 2016 21:38:45 -0600Specifying names of variables in output of self.coordinate_ring()https://ask.sagemath.org/question/32524/specifying-names-of-variables-in-output-of-selfcoordinate_ring/Let
E = EllipticCurve([1,2,3,4,5])
Then E.coordinate_ring() outputs a ring with generators.
E.coordinate_ring().gens()
yields
(xbar,ybar,zbar)
Is there a way to change the names of these variables at any point in this process?
EDIT
The goal is to have sage treat the underlying rings to be treated as unique objects. Currently if I execute
E1 = EllipticCurve([1,2,3,4,5]).coordinate_ring()
E1._names = ('a','b','c')
E2 = EllipticCurve([1,2,3,4,5]).coordinate_ring()
E2._names =('l','m','n')
E1;E2
I get
Quotient of Multivariate Polynomial Ring in x, y, z over Rational Field by the ideal (-x^3 - 2*x^2*z + x*y*z + y^2*z - 4*x*z^2 + 3*y*z^2 - 5*z^3)
Quotient of Multivariate Polynomial Ring in x, y, z over Rational Field by the ideal (-x^3 - 2*x^2*z + x*y*z + y^2*z - 4*x*z^2 + 3*y*z^2 - 5*z^3)
(An indication that the rings are "the same":
E1sing = E1._singular_()
E2sing = E2._singular_()
ProdE1E2sing = singular.ringtensor(E1sing,E2sing);
ProdE1E2.sage()
gives
Quotient of Multivariate Polynomial Ring in x, y, z over Rational Field by the ideal (-x^3 - 2*x^2*z + x*y*z + y^2*z - 4*x*z^2 + 3*y*z^2 - 5*z^3)
whereas there should be 6 variables if the two rings were unique.)
---
Note: I have also tried to change the _gens, as well as injecting variables at every stage, but all with the same outcome.Wed, 10 Feb 2016 23:18:32 -0600https://ask.sagemath.org/question/32524/specifying-names-of-variables-in-output-of-selfcoordinate_ring/Answer by tmonteil for <p>Let </p>
<pre><code>E = EllipticCurve([1,2,3,4,5])
</code></pre>
<p>Then E.coordinate_ring() outputs a ring with generators.</p>
<pre><code>E.coordinate_ring().gens()
</code></pre>
<p>yields</p>
<pre><code>(xbar,ybar,zbar)
</code></pre>
<p>Is there a way to change the names of these variables at any point in this process?</p>
<p>EDIT
The goal is to have sage treat the underlying rings to be treated as unique objects. Currently if I execute</p>
<pre><code>E1 = EllipticCurve([1,2,3,4,5]).coordinate_ring()
E1._names = ('a','b','c')
E2 = EllipticCurve([1,2,3,4,5]).coordinate_ring()
E2._names =('l','m','n')
E1;E2
</code></pre>
<p>I get</p>
<pre><code>Quotient of Multivariate Polynomial Ring in x, y, z over Rational Field by the ideal (-x^3 - 2*x^2*z + x*y*z + y^2*z - 4*x*z^2 + 3*y*z^2 - 5*z^3)
Quotient of Multivariate Polynomial Ring in x, y, z over Rational Field by the ideal (-x^3 - 2*x^2*z + x*y*z + y^2*z - 4*x*z^2 + 3*y*z^2 - 5*z^3)
</code></pre>
<p>(An indication that the rings are "the same":</p>
<pre><code>E1sing = E1._singular_()
E2sing = E2._singular_()
ProdE1E2sing = singular.ringtensor(E1sing,E2sing);
ProdE1E2.sage()
</code></pre>
<p>gives</p>
<pre><code>Quotient of Multivariate Polynomial Ring in x, y, z over Rational Field by the ideal (-x^3 - 2*x^2*z + x*y*z + y^2*z - 4*x*z^2 + 3*y*z^2 - 5*z^3)
</code></pre>
<p>whereas there should be 6 variables if the two rings were unique.)</p>
<hr/>
<p>Note: I have also tried to change the _gens, as well as injecting variables at every stage, but all with the same outcome.</p>
https://ask.sagemath.org/question/32524/specifying-names-of-variables-in-output-of-selfcoordinate_ring/?answer=32534#post-id-32534This is probably an ugly hack, but you after reading the source code of such quotient rings, you can change the hidden `_names` attribute of your object as follows:
sage: R = E.coordinate_ring()
sage: R._names = ('X','Y','Z')
Then you can see:
sage: R.gens()
(X, Y, Z)
And you can let the Sage (=Python) variables `X`, `Y`, `Z` point to those indeterminates as follows:
sage: R.inject_variables()
Defining X, Y, Z
sage: X+Y^2
Y^2 + XThu, 11 Feb 2016 10:57:19 -0600https://ask.sagemath.org/question/32524/specifying-names-of-variables-in-output-of-selfcoordinate_ring/?answer=32534#post-id-32534Comment by admiraltso for <p>This is probably an ugly hack, but you after reading the source code of such quotient rings, you can change the hidden <code>_names</code> attribute of your object as follows:</p>
<pre><code>sage: R = E.coordinate_ring()
sage: R._names = ('X','Y','Z')
</code></pre>
<p>Then you can see:</p>
<pre><code>sage: R.gens()
(X, Y, Z)
</code></pre>
<p>And you can let the Sage (=Python) variables <code>X</code>, <code>Y</code>, <code>Z</code> point to those indeterminates as follows:</p>
<pre><code>sage: R.inject_variables()
Defining X, Y, Z
sage: X+Y^2
Y^2 + X
</code></pre>
https://ask.sagemath.org/question/32524/specifying-names-of-variables-in-output-of-selfcoordinate_ring/?comment=32602#post-id-32602@tmonteil I un-accepted this answer since it didn't seem to actually change the names. But if I should accept the answer based on the unedited question and ask a new question, please let me know (or whatever the correct thing to do is).Fri, 19 Feb 2016 21:38:45 -0600https://ask.sagemath.org/question/32524/specifying-names-of-variables-in-output-of-selfcoordinate_ring/?comment=32602#post-id-32602Comment by kcrisman for <p>This is probably an ugly hack, but you after reading the source code of such quotient rings, you can change the hidden <code>_names</code> attribute of your object as follows:</p>
<pre><code>sage: R = E.coordinate_ring()
sage: R._names = ('X','Y','Z')
</code></pre>
<p>Then you can see:</p>
<pre><code>sage: R.gens()
(X, Y, Z)
</code></pre>
<p>And you can let the Sage (=Python) variables <code>X</code>, <code>Y</code>, <code>Z</code> point to those indeterminates as follows:</p>
<pre><code>sage: R.inject_variables()
Defining X, Y, Z
sage: X+Y^2
Y^2 + X
</code></pre>
https://ask.sagemath.org/question/32524/specifying-names-of-variables-in-output-of-selfcoordinate_ring/?comment=32545#post-id-32545Agreed on the ugly hack.Thu, 11 Feb 2016 15:00:58 -0600https://ask.sagemath.org/question/32524/specifying-names-of-variables-in-output-of-selfcoordinate_ring/?comment=32545#post-id-32545