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.Sat, 14 Apr 2018 14:37:04 +0200Mapping between isomorphic NumberFieldshttps://ask.sagemath.org/question/42011/mapping-between-isomorphic-numberfields/ If I set up two NumberFields that differ only in the variable used in their defining polynomials, they don't report equal:
<pre>
sage: a=QQ['a'].0
sage: aRing = NumberField(a^2 + 1, 'a')
sage:
sage: b=QQ['b'].0
sage: bRing = NumberField(b^2 + 1, 'a')
sage:
sage: aRing is bRing
False
</pre>
This I can live with. But shouldn't I be able to convert elements between them?
<pre>
sage: aa=aRing.0
sage: bb=bRing.0
sage: bRing(aa)
TypeError: No compatible natural embeddings found for Number Field in a with defining polynomial b^2 + 1 and Number Field in a with defining polynomial a^2 + 1
</pre>
I can convert like this:
<pre>
sage: bbb = aa.polynomial()(bb)
sage: bbb.parent() == bRing
True
</pre>
...but this seems awkward, and requires defining an auxilary function if you want to pass it to map or map_coefficients.
Is this a bug? Should I report it on Sage's Trac, or is there a good reason for this?Fri, 13 Apr 2018 22:35:18 +0200https://ask.sagemath.org/question/42011/mapping-between-isomorphic-numberfields/Answer by tmonteil for <p>If I set up two NumberFields that differ only in the variable used in their defining polynomials, they don't report equal:</p>
<pre>sage: a=QQ['a'].0
sage: aRing = NumberField(a^2 + 1, 'a')
sage:
sage: b=QQ['b'].0
sage: bRing = NumberField(b^2 + 1, 'a')
sage:
sage: aRing is bRing
False
</pre>
<p>This I can live with. But shouldn't I be able to convert elements between them?</p>
<pre>sage: aa=aRing.0
sage: bb=bRing.0
sage: bRing(aa)
TypeError: No compatible natural embeddings found for Number Field in a with defining polynomial b^2 + 1 and Number Field in a with defining polynomial a^2 + 1
</pre>
<p>I can convert like this:</p>
<pre>sage: bbb = aa.polynomial()(bb)
sage: bbb.parent() == bRing
True
</pre>
<p>...but this seems awkward, and requires defining an auxilary function if you want to pass it to map or map_coefficients.</p>
<p>Is this a bug? Should I report it on Sage's Trac, or is there a good reason for this?</p>
https://ask.sagemath.org/question/42011/mapping-between-isomorphic-numberfields/?answer=42012#post-id-42012Indeed, in Sage the name of the indeterminates matters, this is not a bug. Think about the multivariate case to be convinced of the reason why.
You can define the mapping as follows:
sage: h = bRing.hom([aa])
sage: h
Ring morphism:
From: Number Field in a with defining polynomial b^2 + 1
To: Number Field in a with defining polynomial a^2 + 1
Defn: a |--> a
sage: h(bb) == aa
TrueSat, 14 Apr 2018 14:37:04 +0200https://ask.sagemath.org/question/42011/mapping-between-isomorphic-numberfields/?answer=42012#post-id-42012