Path: blob/master/sage/schemes/elliptic_curves/ell_modular_symbols.py
4159 views
# -*- coding: utf-8 -*-1r"""2Modular symbols34To an elliptic curves `E` over the rational numbers one can associate5a space - or better two spaces - of modular symbols of level `N`,6equal to the conductor of `E`; because `E` is known to be modular.78There are two implementations of modular symbols, one within ``sage``9and the other as part of Cremona's ``eclib``. One can choose here which10one is used.1112The normalisation of our modular symbols attached to `E` can be chosen, too.13For instance one can make it depended on `E` rather than on its14isogeny class. This is useful for `p`-adic L-functions.1516For more details on modular symbols consult the following1718REFERENCES:1920- [MTT] B. Mazur, J. Tate, and J. Teitelbaum,21On `p`-adic analogues of the conjectures of Birch and22Swinnerton-Dyer, Inventiones mathematicae 84, (1986), 1-48.2324- [Cre] John Cremona, Algorithms for modular elliptic curves,25Cambridge University Press, 1997.2627- [SW] William Stein and Christian Wuthrich, Computations About Tate-Shafarevich Groups28using Iwasawa theory, preprint 2009.2930AUTHORS:3132- William Stein (2007): first version3334- Chris Wuthrich (2008): add scaling and reference to eclib3536"""3738#*****************************************************************************39# Copyright (C) 2007 William Stein <[email protected]>40#41# Distributed under the terms of the GNU General Public License (GPL)42#43# This code is distributed in the hope that it will be useful,44# but WITHOUT ANY WARRANTY; without even the implied warranty of45# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU46# General Public License for more details.47#48# The full text of the GPL is available at:49#50# http://www.gnu.org/licenses/51#*****************************************************************************5253from sage.structure.sage_object import SageObject54from sage.modular.modsym.all import ModularSymbols55from sage.libs.cremona.newforms import ECModularSymbol56from sage.databases.cremona import parse_cremona_label5758from sage.rings.arith import next_prime, kronecker_symbol, prime_divisors, valuation59from sage.rings.infinity import unsigned_infinity as infinity60from sage.rings.integer import Integer61from sage.modular.cusps import Cusps62from sage.rings.integer_ring import ZZ63from sage.rings.rational_field import QQ64from sage.misc.all import verbose6566from sage.schemes.elliptic_curves.constructor import EllipticCurve6768oo = Cusps(infinity)69zero = Integer(0)7071def modular_symbol_space(E, sign, base_ring, bound=None):72r"""73Creates the space of modular symbols of a given sign over a give base_ring,74attached to the isogeny class of elliptic curves.7576INPUT:7778- ``E`` - an elliptic curve over `\QQ`79- ``sign`` - integer, -1, 0, or 180- ``base_ring`` - ring81- ``bound`` - (default: None) maximum number of Hecke operators to82use to cut out modular symbols factor. If None, use83enough to provably get the correct answer.8485OUTPUT: a space of modular symbols8687EXAMPLES::8889sage: import sage.schemes.elliptic_curves.ell_modular_symbols90sage: E=EllipticCurve('11a1')91sage: M=sage.schemes.elliptic_curves.ell_modular_symbols.modular_symbol_space(E,-1,GF(37))92sage: M93Modular Symbols space of dimension 1 for Gamma_0(11) of weight 2 with sign -1 over Finite Field of size 379495"""96_sign = int(sign)97if _sign != sign:98raise TypeError, 'sign must be an integer'99if not (_sign in [-1,0,1]):100raise TypeError, 'sign must -1, 0, or 1'101N = E.conductor()102M = ModularSymbols(N, sign=sign, base_ring=base_ring)103if bound is None:104bound = M.hecke_bound() + 10105V = M106p = 2107while p <= bound and V.dimension() > 1:108t = V.T(p)109ap = E.ap(p)110V = (t - ap).kernel()111p = next_prime(p)112113return V114115class ModularSymbol(SageObject):116r"""117A modular symbol attached to an elliptic curve, which is the map118`\QQ\to \QQ` obtained by sending `r` to the normalized119symmetrized (or anti-symmetrized) integral from `r` to `\infty`.120121This is as defined in [MTT], but normalized122to depend on the curve and not only its isogeny class as in [SW].123124See the documentation of ``E.modular_symbol()`` in125Elliptic curves over the rational numbers126for help.127128REFERENCES:129130- [MTT] B. Mazur, J. Tate, and J. Teitelbaum,131On `p`-adic analogues of the conjectures of Birch and132Swinnerton-Dyer, Inventiones mathematicae 84, (1986), 1-48.133134- [SW] William Stein and Christian Wuthrich, Computations About Tate-Shafarevich Groups135using Iwasawa theory, preprint 2009.136137"""138139def sign(self):140r"""141Return the sign of this elliptic curve modular symbol.142143EXAMPLES::144145sage: m = EllipticCurve('11a1').modular_symbol()146sage: m.sign()1471148sage: m = EllipticCurve('11a1').modular_symbol(sign=-1)149sage: m.sign()150-1151"""152153return self._sign154155def elliptic_curve(self):156r"""157Return the elliptic curve of this modular symbol.158159EXAMPLES::160161sage: m = EllipticCurve('11a1').modular_symbol()162sage: m.elliptic_curve()163Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field164165"""166return self._E167168def base_ring(self):169r"""170Return the base ring for this modular symbol.171172EXAMPLES::173174sage: m = EllipticCurve('11a1').modular_symbol()175sage: m.base_ring()176Rational Field177"""178return self._base_ring179180def _repr_(self):181r"""182String representation of modular symbols.183184EXAMPLES::185186sage: m = EllipticCurve('11a1').modular_symbol(use_eclib=True)187sage: m188Modular symbol with sign 1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field189sage: m = EllipticCurve('43a1').modular_symbol(sign=-1)190sage: m191Modular symbol with sign -1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 + x^2 over Rational Field192"""193return "Modular symbol with sign %s over %s attached to %s"%(194self._sign, self._base_ring, self._E)195196def _find_scaling_L_ratio(self):197r"""198This function is use to set ``_scaling``, the factor used to adjust the199scalar multiple of the modular symbol.200If `[0]`, the modular symbol evaluated at 0, is non-zero, we can just scale201it with respect to the approximation of the L-value. It is known that202the quotient is a rational number with small denominator.203Otherwise we try to scale using quadratic twists.204205``_scaling`` will be set to a rational non-zero multiple if we succeed and to 1 otherwise.206Even if we fail we scale at least to make up the difference between the periods207of the `X_0`-optimal curve and our given curve `E` in the isogeny class.208209EXAMPLES::210211sage : m = EllipticCurve('11a1').modular_symbol(use_eclib=True)212sage : m._scaling2131214sage: m = EllipticCurve('11a2').modular_symbol(use_eclib=True)215sage: m._scaling2165/2217sage: m = EllipticCurve('11a3').modular_symbol(use_eclib=True)218sage: m._scaling2191/10220sage: m = EllipticCurve('11a1').modular_symbol(use_eclib=False)221sage: m._scaling2221/5223sage: m = EllipticCurve('11a2').modular_symbol(use_eclib=False)224sage: m._scaling2251226sage: m = EllipticCurve('11a3').modular_symbol(use_eclib=False)227sage: m._scaling2281/25229sage: m = EllipticCurve('37a1').modular_symbol(use_eclib=False)230sage: m._scaling2311232sage: m = EllipticCurve('37a1').modular_symbol(use_eclib=True)233sage: m._scaling234-1235sage: m = EllipticCurve('389a1').modular_symbol(use_eclib=True)236sage: m._scaling237-1/2238sage: m = EllipticCurve('389a1').modular_symbol(use_eclib=False)239sage: m._scaling2402241sage: m = EllipticCurve('196a1').modular_symbol(use_eclib=False)242sage: m._scaling2431/2244245Some harder cases fail::246247sage: m = EllipticCurve('121b1').modular_symbol(use_eclib=False)248Warning : Could not normalize the modular symbols, maybe all further results will be multiplied by -1, 2 or -2.249sage: m._scaling2501251252TESTS::253254sage: rk0 = ['11a1', '11a2', '15a1', '27a1', '37b1']255sage: for la in rk0: # long time (3s on sage.math, 2011)256... E = EllipticCurve(la)257... me = E.modular_symbol(use_eclib = True)258... ms = E.modular_symbol(use_eclib = False)259... print E.lseries().L_ratio()*E.real_components(), me(0), ms(0)2601/5 1/5 1/52611 1 12621/4 1/4 1/42631/3 1/3 1/32642/3 2/3 2/3265266sage: rk1 = ['37a1','43a1','53a1', '91b1','91b2','91b3']267sage: [EllipticCurve(la).modular_symbol(use_eclib=True)(0) for la in rk1] # long time (1s on sage.math, 2011)268[0, 0, 0, 0, 0, 0]269sage: for la in rk1: # long time (8s on sage.math, 2011)270... E = EllipticCurve(la)271... m = E.modular_symbol(use_eclib = True)272... lp = E.padic_lseries(5)273... for D in [5,17,12,8]:274... ED = E.quadratic_twist(D)275... md = sum([kronecker(D,u)*m(ZZ(u)/D) for u in range(D)])276... etaa = lp._quotient_of_periods_to_twist(D)277... assert ED.lseries().L_ratio()*ED.real_components()*etaa == md278279"""280E = self._E281self._scaling = 1 # by now.282self._failed_to_scale = False283284if self._sign == 1 :285at0 = self(0)286# print 'modular symbol evaluates to ',at0,' at 0'287if at0 != 0 :288l1 = self.__lalg__(1)289if at0 != l1:290verbose('scale modular symbols by %s'%(l1/at0))291self._scaling = l1/at0292else :293# if [0] = 0, we can still hope to scale it correctly by considering twists of E294Dlist = [5,8,12,13,17,21,24,28,29, 33, 37, 40, 41, 44, 53, 56, 57, 60, 61, 65, 69, 73, 76, 77, 85, 88, 89, 92, 93, 97] # a list of positive fundamental discriminants295j = 0296at0 = 0297# computes [0]+ for the twist of E by D until one value is non-zero298while j < 30 and at0 == 0 :299D = Dlist[j]300# the following line checks if the twist of the newform of E by D is a newform301# this is to avoid that we 'twist back'302if all( valuation(E.conductor(),ell)<= valuation(D,ell) for ell in prime_divisors(D) ) :303at0 = sum([kronecker_symbol(D,u) * self(ZZ(u)/D) for u in range(1,abs(D))])304j += 1305if j == 30 and at0 == 0: # curves like "121b1", "225a1", "225e1", "256a1", "256b1", "289a1", "361a1", "400a1", "400c1", "400h1", "441b1", "441c1", "441d1", "441f1 .. will arrive here306self.__scale_by_periods_only__()307else :308l1 = self.__lalg__(D)309if at0 != l1:310verbose('scale modular symbols by %s found at D=%s '%(l1/at0,D), level=2)311self._scaling = l1/at0312313else : # that is when sign = -1314Dlist = [-3,-4,-7,-8,-11,-15,-19,-20,-23,-24, -31, -35, -39, -40, -43, -47, -51, -52, -55, -56, -59, -67, -68, -71, -79, -83, -84, -87, -88, -91] # a list of negative fundamental discriminants315j = 0316at0 = 0317while j < 30 and at0 == 0 :318# computes [0]+ for the twist of E by D until one value is non-zero319D = Dlist[j]320if all( valuation(E.conductor(),ell)<= valuation(D,ell) for ell in prime_divisors(D) ) :321at0 = - sum([kronecker_symbol(D,u) * self(ZZ(u)/D) for u in range(1,abs(D))])322j += 1323if j == 30 and at0 == 0: # no more hope for a normalization324# we do at least a scaling with the quotient of the periods325self.__scale_by_periods_only__()326else :327l1 = self.__lalg__(D)328if at0 != l1:329verbose('scale modular symbols by %s'%(l1/at0))330self._scaling = l1/at0331332333def __lalg__(self,D):334r"""335For positive `D`, this function evaluates the quotient336`L(E_D,1)\cdot \sqrt(D)/\Omega_E` where `E_D` is the twist of337`E` by `D`, `\Omega_E` is the least positive period of `E`.338For negative `E`, it is the quotient339`L(E_D,1)\cdot \sqrt(-D)/\Omega^{-}_E`340where `\Omega^{-}_E` is the least positive imaginary part of a341non-real period of `E`.342343EXMAPLES::344345sage: E = EllipticCurve('11a1')346sage: m = E.modular_symbol(sign=+1)347sage: m.__lalg__(1)3481/5349sage: m.__lalg__(3)3505/2351352"""353from sage.functions.all import sqrt354# the computation of the L-value could take a lot of time,355# but then the conductor is so large356# that the computation of modular symbols for E took even longer357358E = self._E359ED = E.quadratic_twist(D)360lv = ED.lseries().L_ratio() # this is L(ED,1) divided by the Neron period omD of ED361lv *= ED.real_components()362omD = ED.period_lattice().basis()[0]363if D > 0 :364om = E.period_lattice().basis()[0]365q = sqrt(D)*omD/om * 8366else :367om = E.period_lattice().basis()[1].imag()368q = sqrt(-D)*omD/om*8369370# see padic_lseries.pAdicLeries._quotient_of_periods_to_twist371# for the explanation of the second factor372verbose('real approximation is %s'%q)373return lv/8 * QQ(int(round(q)))374375def __scale_by_periods_only__(self):376r"""377If we fail to scale with ``_find_scaling_L_ratio``, we drop here378to try and find the scaling by the quotient of the379periods to the `X_0`-optimal curve. The resulting ``_scaling``380is not guaranteed to be correct, but could well be.381382EXAMPLES::383384sage: E = EllipticCurve('11a1')385sage: m = E.modular_symbol(sign=+1)386sage: m.__scale_by_periods_only__()387Warning : Could not normalize the modular symbols, maybe all further results will be multiplied by -1, 2 or -2.388sage: m._scaling3891390391sage: E = EllipticCurve('11a3')392sage: m = E.modular_symbol(sign=+1, use_eclib=True)393sage: m.__scale_by_periods_only__()394Warning : Could not normalize the modular symbols, maybe all further results will be multiplied by -1, 2 or -2.395sage: m._scaling3961/5397398"""399# we only do this inside the cremona-tables.400try :401crla = parse_cremona_label(self._E.label())402except RuntimeError: # raised when curve is outside of the table403print "Warning : Could not normalize the modular symbols, maybe all further results will be multiplied by a rational number."404self._scaling = 1405else :406print "Warning : Could not normalize the modular symbols, maybe all further results will be multiplied by -1, 2 or -2."407cr0 = Integer(crla[0]).str() + crla[1] + '1'408E0 = EllipticCurve(cr0)409q = E0.period_lattice().basis()[0]/self._E.period_lattice().basis()[0]410q = QQ(int(round(q*200)))/200411verbose('scale modular symbols by %s'%q)412self._scaling = q413414415class ModularSymbolECLIB(ModularSymbol):416def __init__(self, E, sign, normalize="L_ratio"):417r"""418Modular symbols attached to `E` using ``eclib``.419420INPUT:421422- ``E`` - an elliptic curve423- ``sign`` - an integer, -1 or 1424- ``normalize`` - either 'L_ratio' (default) or 'none';425For 'L_ratio', the modular symbol is correctly normalized426by comparing it to the quotient of `L(E,1)` by the least427positive period for the curve and some small twists.428For 'none', the modular symbol is almost certainly429not correctly normalized, i.e. all values will be a430fixed scalar multiple of what they should be.431432EXAMPLES::433434sage: import sage.schemes.elliptic_curves.ell_modular_symbols435sage: E=EllipticCurve('11a1')436sage: M=sage.schemes.elliptic_curves.ell_modular_symbols.ModularSymbolECLIB(E,+1)437sage: M438Modular symbol with sign 1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field439sage: M(0)4401/5441sage: E=EllipticCurve('11a2')442sage: M=sage.schemes.elliptic_curves.ell_modular_symbols.ModularSymbolECLIB(E,+1)443sage: M(0)4441445446This is a rank 1 case with vanishing positive twists.447The modular symbol can not be adjusted::448449sage: E=EllipticCurve('121b1')450sage: M=sage.schemes.elliptic_curves.ell_modular_symbols.ModularSymbolECLIB(E,+1)451Warning : Could not normalize the modular symbols, maybe all further results will be multiplied by -1, 2 or -2.452sage: M(0)4530454sage: M(1/7)455-2456457sage: M = EllipticCurve('121d1').modular_symbol(use_eclib=True)458sage: M(0)4592460sage: M = EllipticCurve('121d1').modular_symbol(use_eclib=True,normalize='none')461sage: M(0)4628463464sage: E = EllipticCurve('15a1')465sage: [C.modular_symbol(use_eclib=True,normalize='L_ratio')(0) for C in E.isogeny_class()[0]]466[1/4, 1/8, 1/4, 1/2, 1/8, 1/16, 1/2, 1]467sage: [C.modular_symbol(use_eclib=True,normalize='none')(0) for C in E.isogeny_class()[0]]468[1/4, 1/4, 1/4, 1/4, 1/4, 1/4, 1/4, 1/4]469470Currently, the interface for negative modular symbols in eclib is not yet written::471472sage: E.modular_symbol(use_eclib=True,sign=-1)473Traceback (most recent call last):474...475NotImplementedError: Despite that eclib has now -1 modular symbols the interface to them is not yet written.476477TESTS (for trac 10236)::478479sage: E = EllipticCurve('11a1')480sage: m = E.modular_symbol(use_eclib=True)481sage: m(1/7)4827/10483sage: m(0)4841/5485"""486self._sign = ZZ(sign)487if self._sign != sign:488raise TypeError, 'sign must be an integer'489if self._sign != -1 and self._sign != 1:490raise TypeError, 'sign must -1 or 1'491if self._sign == -1:492raise NotImplementedError, "Despite that eclib has now -1 modular symbols the interface to them is not yet written."493self._E = E494self._use_eclib = True495self._base_ring = QQ496self._normalize = normalize497self._modsym = ECModularSymbol(E)498p = ZZ(2)499while not E.is_good(p):500p = p.next_prime()501# this computes {0,oo} using the Hecke-operator at p502self._atzero = sum([self._modsym(ZZ(a)/p) for a in range(p)])/E.Np(p)503504if normalize == "L_ratio":505self._find_scaling_L_ratio()506elif normalize == "none":507self._scaling = ZZ(1)508else :509raise ValueError, "no normalization '%s' known for modular symbols using John Cremona's eclib"%normalize510511512def _call_with_caching(self, r):513r"""514Evaluates the modular symbol at `r`, caching the computed value.515516EXAMPLES::517518sage: m = EllipticCurve('11a1').modular_symbol(use_eclib=True)519sage: m._call_with_caching(0)5201/5521"""522try:523return self.__cache[r]524except AttributeError:525self.__cache = {}526except KeyError:527pass528c = (self._atzero - self._modsym(r))*self._scaling529self.__cache[r] = c530return c531532def __call__(self, r):533r"""534Evaluates the modular symbol at `r`.535536EXAMPLES::537538sage: m = EllipticCurve('11a1').modular_symbol(use_eclib=True)539sage: m(0)5401/5541542"""543# this computes {0,oo} - {0,r} = {r,oo}544return (self._atzero - self._modsym(r))*self._scaling545546547class ModularSymbolSage(ModularSymbol):548def __init__(self, E, sign, normalize="L_ratio"):549"""550Modular symbols attached to `E` using ``sage``.551552INPUT:553554- ``E`` -- an elliptic curve555- ``sign`` -- an integer, -1 or 1556- ``normalize`` -- either 'L_ratio' (default), 'period', or 'none';557For 'L_ratio', the modular symbol is correctly normalized558by comparing it to the quotient of `L(E,1)` by the least559positive period for the curve and some small twists.560The normalization 'period' uses the integral_period_map561for modular symbols and is known to be equal to the above562normalization up to the sign and a possible power of 2.563For 'none', the modular symbol is almost certainly564not correctly normalized, i.e. all values will be a565fixed scalar multiple of what they should be. But566the initial computation of the modular symbol is567much faster, though evaluation of568it after computing it won't be any faster.569570EXAMPLES::571572sage: E=EllipticCurve('11a1')573sage: import sage.schemes.elliptic_curves.ell_modular_symbols574sage: M=sage.schemes.elliptic_curves.ell_modular_symbols.ModularSymbolSage(E,+1)575sage: M576Modular symbol with sign 1 over Rational Field attached to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field577sage: M(0)5781/5579sage: E=EllipticCurve('11a2')580sage: M=sage.schemes.elliptic_curves.ell_modular_symbols.ModularSymbolSage(E,+1)581sage: M(0)5821583sage: M=sage.schemes.elliptic_curves.ell_modular_symbols.ModularSymbolSage(E,-1)584sage: M(1/3)5851586587This is a rank 1 case with vanishing positive twists.588The modular symbol is adjusted by -2::589590sage: E=EllipticCurve('121b1')591sage: M=sage.schemes.elliptic_curves.ell_modular_symbols.ModularSymbolSage(E,-1,normalize='L_ratio')592sage: M(1/3)5932594sage: M._scaling595-2596597sage: M = EllipticCurve('121d1').modular_symbol(use_eclib=False)598sage: M(0)5992600sage: M = EllipticCurve('121d1').modular_symbol(use_eclib=False,normalize='none')601sage: M(0)6021603604sage: E = EllipticCurve('15a1')605sage: [C.modular_symbol(use_eclib=False, normalize='L_ratio')(0) for C in E.isogeny_class()[0]]606[1/4, 1/8, 1/4, 1/2, 1/8, 1/16, 1/2, 1]607sage: [C.modular_symbol(use_eclib=False, normalize='period')(0) for C in E.isogeny_class()[0]]608[1/8, 1/16, 1/8, 1/4, 1/16, 1/32, 1/4, 1/2]609sage: [C.modular_symbol(use_eclib=False, normalize='none')(0) for C in E.isogeny_class()[0]]610[1, 1, 1, 1, 1, 1, 1, 1]611612"""613self._sign = ZZ(sign)614if self._sign != sign:615raise TypeError, 'sign must be an integer'616if self._sign != -1 and self._sign != 1:617raise TypeError, 'sign must -1 or 1'618self._E = E619self._use_eclib = False620self._normalize = normalize621self._modsym = E.modular_symbol_space(sign=self._sign)622self._base_ring = self._modsym.base_ring()623self._ambient_modsym = self._modsym.ambient_module()624625if normalize == "L_ratio":626self._e = self._modsym.dual_eigenvector()627self._find_scaling_L_ratio()628self._e *= self._scaling629elif normalize == "period" :630self._find_scaling_period() # this will set _e and _scaling631elif normalize == "none":632self._scaling = 1633self._e = self._modsym.dual_eigenvector()634else :635raise ValueError, "no normalization %s known for modular symbols"%normalize636637638def _find_scaling_period(self):639r"""640Uses the integral period map of the modular symbol implementation in sage641in order to determine the scaling. The resulting modular symbol is correct642only for the `X_0`-optimal curve, at least up to a possible factor +-1 or +-2.643644EXAMPLES::645646sage: E = EllipticCurve('11a1')647sage: m = sage.schemes.elliptic_curves.ell_modular_symbols.ModularSymbolSage(E,+1,normalize='period')648sage: m._e649(1/5, 1)650sage: E = EllipticCurve('11a2')651sage: m = sage.schemes.elliptic_curves.ell_modular_symbols.ModularSymbolSage(E,+1,normalize='period')652sage: m._e653(1, 5)654sage: E = EllipticCurve('121b2')655sage: m = sage.schemes.elliptic_curves.ell_modular_symbols.ModularSymbolSage(E,+1,normalize='period')656sage: m._e657(0, 11/2, 0, 11/2, 11/2, 0, 0, -3, 2, 1/2, -1, 3/2)658659"""660661P = self._modsym.integral_period_mapping()662self._e = P.matrix().transpose().row(0)663self._e /= 2664E = self._E665try :666crla = parse_cremona_label(E.label())667except RuntimeError: # raised when curve is outside of the table668self._scaling = 1669else :670cr0 = Integer(crla[0]).str() + crla[1] + '1'671E0 = EllipticCurve(cr0)672q = E0.period_lattice().basis()[0]/E.period_lattice().basis()[0]673q = QQ(int(round(q*200)))/200674verbose('scale modular symbols by %s'%q)675self._scaling = q676self._e *= self._scaling677678def _call_with_caching(self, r):679r"""680Evaluates the modular symbol at `r`, caching the computed value.681682EXAMPLES::683684sage: m = EllipticCurve('11a1').modular_symbol(use_eclib=False)685sage: m._call_with_caching(0)6861/5687"""688try:689return self.__cache[r]690except AttributeError:691self.__cache = {}692except KeyError:693pass694w = self._ambient_modsym([oo,r]).element()695c = (self._e).dot_product(w)696self.__cache[r] = c697return c698699def __call__(self, r):700r"""701Evaluates the modular symbol at `r`.702703EXAMPLES::704705sage: m = EllipticCurve('11a1').modular_symbol(use_eclib=False)706sage: m(0)7071/5708709"""710# this next line takes most of the time711w = self._ambient_modsym.modular_symbol([zero, oo, Cusps(r)], check=False)712713return (self._e).dot_product(w.element())714715716