Opened 3 years ago

Closed 3 years ago

#28395 closed defect (fixed)

Bug in is_weil_polynomial

Reported by: kedlaya Owned by:
Priority: major Milestone: sage-8.9
Component: algebra Keywords: Weil polynomial
Cc: Merged in:
Authors: Kiran Kedlaya Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 92a22f5 (Commits, GitHub, GitLab) Commit: 92a22f5d52dd25f82d1f5ac51809c50b99edca8a
Dependencies: Stopgaps:

Status badges

Description

This is a bug:

sage: P.<t> = QQ[]
sage: u = t^10 + 4*t^9 + 8*t^8 + 18*t^7 + 81*t^6 + 272*t^5 + 567*t^4 + 882*t^3 + 2744*t^2 + 9604*t + 16807
sage: [abs(x[0])^2 for x in u.roots(CC)]
[7.00000000000000,
 7.00000000000000,
 7.00000000000000,
 7.00000000000000,
 7.00000000000000,
 7.00000000000000,
 7.00000000000000,
 7.00000000000000,
 7.00000000000000,
 7.00000000000000]
sage: u.is_weil_polynomial() # Should return True
False

Change History (5)

comment:1 Changed 3 years ago by kedlaya

  • Branch set to u/kedlaya/bug_in_is_weil_polynomial

comment:2 Changed 3 years ago by kedlaya

  • Commit set to 92a22f5d52dd25f82d1f5ac51809c50b99edca8a
  • Status changed from new to needs_review

The underlying bug is in trace_polynomial:

sage: Q[t] = t
sage: u  = t^4 + 3*t^2 + 1
sage: u.trace_polynomial() ## First answer should be t^2+1
(t^2 + t + 1, 1, 1)

The code is currently accessing the leading coefficient without checking the degree; the corner case that triggers this bug is when the expected "leading" coefficient is zero, and so the wrong coefficient is accessed instead.


New commits:

eb0a15cFix bug in trace_polynomial
92a22f5Fix bug in trace_polynomial

comment:3 Changed 3 years ago by kedlaya

  • Authors set to Kiran Kedlaya

comment:4 Changed 3 years ago by chapoton

  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review

ok, looks good. Thanks a lot.

comment:5 Changed 3 years ago by vbraun

  • Branch changed from u/kedlaya/bug_in_is_weil_polynomial to 92a22f5d52dd25f82d1f5ac51809c50b99edca8a
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.