Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11186 closed defect (fixed)

Missing parentheses when typesetting coefficients of multivariate polynomials over number fields

Reported by: jsrn Owned by: was
Priority: minor Milestone: sage-4.7.1
Component: user interface Keywords: latex, multivariate polynomials, singular
Cc: Merged in: sage-4.7.1.alpha4
Authors: Johan Sebastian Rosenkilde Nielsen Reviewers: Mariah Lenox
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


Notice the missing parenthesis when attempting to typeset a simple multivariate polynomial:

sage: K.<z> = QQ.extension(x^2 + x + 1)
sage: PK.<v,w> = K[]
sage: (z+1)*v
(z + 1)*v
sage: latex((z+1)*v)
z + 1 v

This, of course, means that typesetting in the Notebook will also be wrong.

The error seems not to happen with univariate polynomials.

Attachments (1)

11186_missing_parenthesis_multi_singular.patch (3.8 KB) - added by jsrn 11 years ago.
Patches sage.libs.singular.polynomial.pyx

Download all attachments as: .zip

Change History (7)

comment:1 Changed 11 years ago by jsrn

  • Authors set to Johan S. R. Nielsen
  • Status changed from new to needs_review

I wrote a simple patch to fix the issue and added a doctest for it.

However, sage.libs.singular.polynomial._latex_ (used for typesetting Singular polynomials) is still very different from -- and seemingly more simple -- than the generic sage.rings.polynomial.polynomial_element._latex_; this is perhaps a bit disconcerting and should be looked?

Changed 11 years ago by jsrn

Patches sage.libs.singular.polynomial.pyx

comment:2 Changed 11 years ago by jsrn

Slightly improved my patch as I discovered that negative coefficients we typeset with a parenthesis. My fix simplifies some existing code as well.

I discovered simultaneously that in univariate polynomials, certain coefficients will get parentheses around them, even when not needed, such as sqrt{-1} (because it contains a '-' even though it's inside the squareroot). As I copied some code from there, multivariate polynomials now also have this behaviour. This broke a doctests, which I changed.

This is not optimal behaviour, but I didn't want to patch univariate polynomials here (the patch might not be simple either -- parsing TeX, eew). Also, I "introduced" the error in multivariate polynomials to this for two reasons: first of all, without a solution to this sqrt-problem, it's a side-effect of "doing the right thing most of the time"; namely in cases such as the one in the ticket description. And this error is worse than a superfluous parenthesis once in a while. Thirdly, I think that it's nice, if all polynomials render more or less the same way.

comment:3 Changed 11 years ago by mariah

  • Reviewers set to Mariah Lenox
  • Status changed from needs_review to positive_review

The patch fixes the reported problem. Ran 'make testlong' and all tests passed. Positive review!

comment:4 Changed 11 years ago by jdemeyer

  • Milestone set to sage-4.7.1

comment:5 Changed 11 years ago by jdemeyer

  • Merged in set to sage-4.7.1.alpha4
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:6 Changed 11 years ago by jdemeyer

  • Authors changed from Johan S. R. Nielsen to Johan Sebastian Rosenkilde Nielsen
Note: See TracTickets for help on using tickets.