Opened 5 years ago

Closed 5 years ago

#15970 closed defect (fixed)

j_invariant_qexp won't allow substitution

Reported by: katestange Owned by:
Priority: minor Milestone: sage-6.3
Component: number theory Keywords: j-invariant, laurent series, q-expansion, substitution
Cc: Merged in:
Authors: Alex Ghitza Reviewers: Peter Bruin
Report Upstream: N/A Work issues:
Branch: 856e661 (Commits) Commit: 856e6617de1d4ad26734d468f4ba43d8e3370388
Dependencies: Stopgaps:

Description

jq = j_invariant_qexp(10) 
jqsub = jq.substitute(q = e^(-2*pi))

This used to work (Sage 4.8). It ought to return an approximation to 1728 (this is useful behaviour...). E.g.

n(jqsub)

1727.99999999999

But now it raises...

ValueError: Can only substitute elements of positive valuation

Change History (10)

comment:1 Changed 5 years ago by fwclarke

The change was made in #3979. Until Sage 5.4, substitution into power series was incorrectly implemented in many ways. In particular, it was possible to substitute a non-zero scalar into a series only specified up to a given precision, but this cannot make sense.

In your case,

sage: jq = j_invariant_qexp(10)
sage: jq.truncate(10)(exp(-2*pi)).n(100)
1727.9999999999882175423506871

gives the answer you want. But its meaning depends on assuming (correctly) that the infinitely many unspecified terms can be ignored (to within 10-10).

In general, writing, say,

f = x + x^2 + O(x^3)

tells us nothing about how f(2) should be defined, or whether 6 might be a reasonable approximation.

comment:2 follow-ups: Changed 5 years ago by katestange

Thanks, that clears things up for me.  Probably I should have gone to the discussion list before opening a ticket (if so, I apologize).  But before we close the ticket, can we clarify what way the user should accomplish the intended calculation?  How can one approximate the j-invariant for various tau in the upper half plane?  This is something Sage ought to allow someone to do, in some fashion, so if isn't possible, then maybe this ticket should be changed to a requested feature.  But if this discussion ought to be carried out elsewhere (like ask.sagemath.org), please let me know.

comment:3 in reply to: ↑ 2 Changed 5 years ago by fwclarke

Replying to katestange:

But before we close the ticket, can we clarify what way the user should accomplish the intended calculation?  How can one approximate the j-invariant for various tau in the upper half plane?

For numerical computations, elliptic_j will do:

sage: elliptic_j(I)
1728.00000000000

and the precision can be increased as in

sage: elliptic_j(sqrt(-1).n(128))
1728.0000000000000000000000000000000000

or

sage: tau = (1 + sqrt(-163))/2
sage: elliptic_j(tau.n(100))
-2.6253741264076799999999999999e17 + 1.3012822400356849057448214481e-12*I
sage: (-elliptic_j(tau.n(100)).real().round())^(1/3)
640320

comment:4 Changed 5 years ago by katestange

Thank you!

comment:5 Changed 5 years ago by AlexGhitza

  • Branch set to u/AlexGhitza/ticket/15970
  • Created changed from 03/18/14 04:21:35 to 03/18/14 04:21:35
  • Modified changed from 03/20/14 15:09:34 to 03/20/14 15:09:34

comment:6 Changed 5 years ago by AlexGhitza

  • Authors set to Alex Ghitza
  • Commit set to 831373cb2b46477eb713b557765aa1439d1f627f
  • Status changed from new to needs_review

I added a link to elliptic_j in the docstring for j_invariant_qexp.


New commits:

831373cadd reference to elliptic_j in j_invariant_qexp

comment:7 in reply to: ↑ 2 Changed 5 years ago by nbruin

Replying to katestange:

How can one approximate the j-invariant for various tau in the upper half plane?  This is something Sage ought to allow someone to do, in some fashion, so if isn't possible, then maybe this ticket should be changed to a requested feature.

The request is of course a reasonable one. Sometimes all you have is a finite approximation, and evaluating that will be the best you'll get. The trick is to get rid of the O(..) term, which you can do with truncate:

sage: jq = j_invariant_qexp(10)
sage: jq.truncate(100)(e^(-2*pi)).n()
1727.99999999999

comment:8 Changed 5 years ago by pbruin

  • Branch changed from u/AlexGhitza/ticket/15970 to u/pbruin/15970-j_invariant_qexp
  • Commit changed from 831373cb2b46477eb713b557765aa1439d1f627f to 856e6617de1d4ad26734d468f4ba43d8e3370388
  • Reviewers set to Peter Bruin
  • Status changed from needs_review to positive_review

Looks good, just a small reviewer patch to add markup to symbols and a variable name.

comment:9 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:10 Changed 5 years ago by vbraun

  • Branch changed from u/pbruin/15970-j_invariant_qexp to 856e6617de1d4ad26734d468f4ba43d8e3370388
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.