# 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:

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


This I can live with. But shouldn't I be able to convert elements between them?

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


I can convert like this:

sage: bbb = aa.polynomial()(bb)
sage: bbb.parent() == bRing
True


...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?

edit retag close merge delete

Sort by ยป oldest newest most voted

Indeed, 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
True

more