Ticket #3105 (closed defect: fixed)
[with patch, positive review] new _latex_ and modified __repr__ for elements of relative number fields
| Reported by: | mabshoff | Owned by: | was |
|---|---|---|---|
| Priority: | major | Milestone: | sage-3.0.2 |
| Component: | number theory | Keywords: | |
| Cc: | F.Clarke@… | Work issues: | |
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
Patch by Francis Clarke. He should fill in the details once his new trac account works.
Cheers,
Michael
Attachments
Change History
comment:1 Changed 5 years ago by cremona
- Cc F.Clarke@… added
- Summary changed from [with patch, needs review] new _latex_ and modified __repr__ for elements of relative number fields to [with patch, positive review] new _latex_ and modified __repr__ for elements of relative number fields
This patch appliesw fine to 3.0.1 and the doctests in sage/rings/number_field all pass.
It looks fine to me.
comment:2 Changed 5 years ago by mabshoff
- Status changed from new to closed
- Resolution set to fixed
Merged in Sage 3.0.2.alpha0
comment:3 Changed 5 years ago by fwclarke
- Status changed from closed to reopened
- Resolution fixed deleted
comment:4 Changed 5 years ago by fwclarke
- Status changed from reopened to closed
- Resolution set to fixed
----------------------------------------------------------------------
| SAGE Version 3.0, Release Date: 2008-04-21 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: A.<a> = CyclotomicField(3)
sage: P.<x> = PolynomialRing(A)
sage: B.<b> = NumberField(x^2 - 5)
sage: (a + b)^2
2*a*b - a + 4
sage: latex((a + b)^2)
\frac{4}{23} b^{3} - \frac{29}{23} b^{2} - \frac{8}{23} b + \frac{212}{23}
This is clearly wrong. What is happening is the element is being represented in the absolute number field, but using the variable appropriate to the relative field:
sage: C.<c> = B.absolute_field()
sage: from_abs, to_abs = C.structure()
sage: to_abs((a + b)^2)
4/23*c^3 - 29/23*c^2 - 8/23*c + 212/23
sage: latex(to_abs((a + b)^2))
\frac{4}{23} c^{3} - \frac{29}{23} c^{2} - \frac{8}{23} c + \frac{212}{23}
The patch below fixes this by providing a _latex_ function for elements of relative number fields.
It also simplifies __repr__ for such elements slightly.
Note: See
TracTickets for help on using
tickets.

