Opened 4 years ago

Closed 4 years ago

#17299 closed defect (fixed)

Bug in LaTeX of modular symbols

Reported by: was Owned by: haochen_uw
Priority: critical Milestone: sage-6.9
Component: modular forms Keywords:
Cc: Merged in:
Authors: Hao Chen, David Loeffler Reviewers: David Loeffler, Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: a1c545f (Commits) Commit: a1c545f7ec4ce085d23221aeca50dc9889305f2c
Dependencies: Stopgaps:

Description (last modified by was)

I almost just got in trouble doing some research due to the following rather serious bug in modular symbols:

/scratch/wstein/sage-6.4.rc1$ ./sage
│ Sage Version 6.4.rc1, Release Date: 2014-11-01                     │

sage: x = EllipticCurve('64a1').modular_symbol_space(sign=1).basis()[0]
sage: x.modular_symbol_rep()
{-1/3, -1/4} - {1/5, 1/4}
sage: latex(x.modular_symbol_rep())
\left\{\frac{-1}{3}, \frac{-1}{4}\right\}

Notice that the latex representation completely omits the second summand. I was using show(x) to typeset output nicely, and getting massively misled.

Change History (15)

comment:1 Changed 4 years ago by haochen_uw

  • Branch set to u/haochen_uw/latexrepbug
  • Owner changed from (none) to haochen_uw

comment:2 Changed 4 years ago by git

  • Commit set to 35081a653922bc15298651161d307d8e9700bb80

Branch pushed to git repo; I updated commit sha1. New commits:

35081a6fixed latex representations of FormalSum objects bug.

comment:3 Changed 4 years ago by was

  • Description modified (diff)

comment:4 Changed 4 years ago by was

  • Priority changed from major to critical

This is really a bug in latex printing, not modular symbols, hence very, very critical. I think it will produce mathematically incorrect results in a lot of situations, potentially. So raising the priority to critical.

Hao's patch as I write this isn't correct, but I've emailed him about what to do.

This bug is my fault: I introduced it in 2009.

comment:5 Changed 4 years ago by aapitzsch

Something like this seems to work.

  • src/sage/misc/latex.py

    a b def repr_lincomb(symbols, coeffs): 
    23492349                    s += " + %s"%b
    23502350            else:
    23512351                coeff = coeff_repr(c)
     2352                if coeff == "-1":
     2353                    coeff = "-"
    23522354                if first:
    23532355                    coeff = str(coeff)
    23542356                else:
    def repr_lincomb(symbols, coeffs): 
    23592361                try:
    23602362                    if bv in CC:
    23612363                        s += "%s\cdot %s"%(coeff, b)
     2364                    else:
     2365                        s += "%s%s"%(coeff, b)
    23622366                except Exception:
    23632367                    s += "%s%s"%(coeff, b)
    23642368            first = False

comment:6 Changed 4 years ago by git

  • Commit changed from 35081a653922bc15298651161d307d8e9700bb80 to 6f7efb844ae91bfdc5a4f109bc8fe809b27a1bdb

Branch pushed to git repo; I updated commit sha1. New commits:

6f7efb8second try. Add doctests.

comment:7 Changed 4 years ago by jdemeyer

  • Summary changed from nasty bug in modular symbols, which is likely very easy to fix. to Bug in LaTeX of modular symbols

comment:8 Changed 4 years ago by davidloeffler

Is this ready for review? It looks like a complete solution to me. If so, please set the "status" to "needs_review" (and enter an author name).

comment:9 Changed 4 years ago by haochen_uw

  • Authors set to Hao Chen
  • Status changed from new to needs_review

comment:10 Changed 4 years ago by aapitzsch

  • Status changed from needs_review to needs_work

Replace trac ticket 17299(latex representation of modular symbols) by :trac:`17299`.

comment:11 Changed 4 years ago by davidloeffler

  • Branch changed from u/haochen_uw/latexrepbug to u/davidloeffler/latexrepbug

comment:12 Changed 4 years ago by davidloeffler

  • Commit changed from 6f7efb844ae91bfdc5a4f109bc8fe809b27a1bdb to 3451807c651ce4df163532490ee04fe914756ada
  • Status changed from needs_work to needs_review

New commits:

3451807Trac 17299: formatting fix

comment:13 Changed 4 years ago by chapoton

  • Authors changed from Hao Chen to Hao Chen, David Loeffler
  • Branch changed from u/davidloeffler/latexrepbug to public/ticket/17299
  • Commit changed from 3451807c651ce4df163532490ee04fe914756ada to a1c545f7ec4ce085d23221aeca50dc9889305f2c
  • Reviewers set to David Loeffler, Frédéric Chapoton
  • Status changed from needs_review to positive_review

Looks good to me. The patchbot is green, and this ticket has been waiting for too long.

As I made only cosmetic formatting of code, I allow myself to put this to positive review.


New commits:

2ad88bbMerge branch 'u/davidloeffler/latexrepbug' into 6.9.b6
a1c545ftrac #17299 cosmetic formatting of code

comment:14 Changed 4 years ago by chapoton

  • Milestone changed from sage-6.4 to sage-6.9

comment:15 Changed 4 years ago by vbraun

  • Branch changed from public/ticket/17299 to a1c545f7ec4ce085d23221aeca50dc9889305f2c
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.