def __init__(self,b=sqrt(2),fixpoint_number=0,u=None,prec=53,iprec=None,N=5,direction=-1,debug=0): """ for the numbering of fixed points see function exp_fixpoint u is the initial value such that slog(u)=0 and sexp(0)=u for the attracting fixed point it defaults to u=1 otherwise it is undetermined direction can be +1 (real values when approaching from the right of the fixpoint) or -1 (real values when approaching from the left of the fixed point) """ if debug >= 1: if b==sqrt(2): print 'b:',b if fixpoint_number==0: print 'fixpoint_number:',fixpoint_number if prec==53: print 'prec:',prec if N==5: print 'N:',N if direction==-1: print 'direction:',direction bsym = b self.bsym = bsym self.N = N if iprec==None: iprec=prec+10 if debug>=1: print 'iprec:',iprec self.iprec = iprec self.prec = prec self.fixpoint_number = fixpoint_number eta = e**(1/e) bname = repr(bsym).strip('0').replace('.',',') if bsym == sqrt(2): bname = "sqrt2" if bsym == eta: bname = "eta" self.lnb = num(ln(bsym),iprec) b = num(bsym,iprec) self.b = b self.path = "savings/islog_%s"%bname + "_N%04d"%N + "_iprec%05d"%iprec + "_fp%d"%fixpoint_number if iprec != None: b = num(b,iprec) self.b = b else: if b == e and x0 == 0: R = QQ else: R = SR self.attracting = False if b < eta and fixpoint_number == 0: self.attracting = True self.real_fp = False if b <= eta and abs(fixpoint_number) <= 1: self.real_fp = True self.parabolic = False if self.bsym == eta and abs(fixpoint_number) <= 1: self.parabolic = True if direction == +1: self.attracting = False if direction == -1: self.attracting = True if b <= eta and abs(fixpoint_number) <= 1: R = RealField(iprec) else: R = ComplexField(iprec) self.R = R if self.parabolic: fp = R(e) #just for not messing it into a complex number else: fp = exp_fixpoint(b,fixpoint_number,prec=iprec) self.fp = fp #fixpoint self.fpd = self.log(fp) #fixpont derivative self.direction = direction FR = FormalPowerSeriesRing(R) fps = FR.Dec_exp(FR([0,b.log()])).rmul(fp) if self.parabolic: fps=fps.set_item(1,1).reclass() if debug>=1: print "fp:",fp [rho,ps] = fps.abel_coeffs() if debug>=2: print 'fps:',fps if debug>=2: print 'rho:',rho if debug>=2: print 'abel_ps:',ps self.chi_ps = fps.schroeder() self.chipoly = self.chi_ps.polynomial(N+1) self.chi_raw0 = lambda z: self.chipoly(direction*(z-self.fp)) PR = PolynomialRing(R,'x') self.slogpoly = ps.polynomial(N) if debug>=2: print self.slogpoly self.slog_raw0 = lambda z: rho*(direction*(z-self.fp)).log() + self.slogpoly(z-self.fp) #slog(u)==0 self.c = 0 if self.attracting and direction==-1 and u==None: u=1 if debug>=1: print 'u:',u if not u==None: self.c = -self.slog(u) pass
def Zinf_Schwarzchild_PN(l, m, r): r""" Amplitude factor of the mode `(\ell,m)` for a Schwarzschild BH at the 1.5PN level. The 1.5PN formulas are taken from E. Poisson, Phys. Rev. D **47**, 1497 (1993), :doi:`10.1103/PhysRevD.47.1497`. INPUT: - ``l`` -- integer >= 2; the harmonic degree `\ell` - ``m`` -- integer within the range ``[-l, l]``; the azimuthal number `m` - ``r`` -- areal radius of the orbit (in units of `M`, the BH mass) OUTPUT: - coefficient `Z^\infty_{\ell m}(r)` (in units of `M^{-2}`) EXAMPLES:: sage: from kerrgeodesic_gw import Zinf_Schwarzchild_PN sage: Zinf_Schwarzchild_PN(2, 2, 6.) # tol 1.0e-13 -0.00981450418730346 + 0.003855681972781947*I sage: Zinf_Schwarzchild_PN(5, 3, 6.) # tol 1.0e-13 -6.958527913913504e-05*I """ if m < 0: return (-1)**l * Zinf_Schwarzchild_PN(l, -m, r).conjugate() v = 1. / sqrt(r) if l == 2: b = RDF(sqrt(pi / 5.) / r**4) if m == 1: return CDF(4. / 3. * I * b * v * (1 - 17. / 28. * v**2)) if m == 2: return CDF(-16 * b * (1 - 107. / 42. * v**2 + (2 * pi + 4 * I * (3 * ln(2 * v) - 0.839451001765134)) * v**3)) if l == 3: b = RDF(sqrt(pi / 7.) / r**(4.5)) if m == 1: return CDF(I / 3. * b / sqrt(10.) * (1 - 8. / 3. * v**2)) if m == 2: return CDF(-16. / 3. * b * v) if m == 3: return CDF(-81 * I * b / sqrt(8.) * (1 - 4 * v**2)) if l == 4: b = RDF(sqrt(pi) / r**5) if m == 1: return CDF(I / 105. * b / sqrt(2) * v) if m == 2: return CDF(-16. / 63. * b) if m == 3: return CDF(-81. / 5. * I * b / sqrt(14.) * v) if m == 4: return CDF(512. / 9. * b / sqrt(7.)) if l == 5: b = RDF(sqrt(pi) / r**(5.5)) if m == 1: return CDF(I / 360. * b / sqrt(77.)) if m == 2: return CDF(0) if m == 3: return CDF(-81. / 40. * I * b * sqrt(3. / 22.)) if m == 4: return CDF(0) if m == 5: return CDF(3125. / 24. * I * b * sqrt(5. / 66.)) raise NotImplementedError("{} not implemented".format((l, m)))
def __init__(self,n,symbolic=False,iprec=53,prec=53,N=10,pred=None): self.N = N self.iprec = iprec self.prec = prec mp.prec = iprec L = PolynomialRing(QQ,'ln2') ln2 = L.gen() self.ln2 = ln2 FPL = FormalPowerSeriesRing(L) self.FPL = FPL R = RealField(iprec) self.R = R FPR = FormalPowerSeriesRing(R) self.FPR = FPR def log2(x): return ln(x)/R(ln(2)) if n==1: self.hfop = lambda x,y: log2(R(2)**x+R(2)**y) self.hp = FPL([1,1]) self.hf = lambda x: x+1 self.hfi = lambda x: x-1 self.op = lambda x,y: x+y elif n==2: self.hfop = lambda x,y: x + y self.hp = FPL([0,2]) self.hf = lambda x: R(2)*x self.hfi = lambda x: x/R(2) self.op = lambda x,y: x*y # 2**(log2(x)+log2(y)) elif n==3: self.hfop = lambda x,y: x*(R(2)**y) self.hp = FPL.Exp(FPL([0,ln2])) * FPL([0,1]) self.hp.reclass() self.hpr = FPR.Exp(FPR([0,R(ln(2))])) * FPR([0,1]) self.hpr.reclass() self.hf = lambda x: R(x)*R(2)**R(x) self.hfi = lambda y: R(lambertw(R(y)*R(ln(2))))/R(ln(2)) self.op = lambda x,y: x**y else: if pred != None: self.G = pred else: self.G = Balanced(n-1,symbolic=symbolic,iprec=iprec,prec=prec,N=N) self.hpop = lambda y: self.G.hp.it(y) self.hp = self.G.hp.selfit() self.hp.reclass() if symbolic: def subs(e): if type(e) == int: return R(e) return e.subs(R( log( 2 ) )) self.hprop = lambda y: FPR.by_formal_powerseries(self.hpop(y),subs) self.hpr = FPR.by_formal_powerseries(self.hp, subs) else: self.hprop = lambda y: self.G.hpr.it(y) self.hpr = self.G.hpr.selfit() self.hpr.reclass() self.hfop = self.f() self.hf = lambda x: self.hfop(x,x) #self.hfi = self.f(self.hp.inv()) self.op = lambda x,y: R(2)**(self.hfop(log2(x),log2(y)))
def log2(x): return ln(x)/R(ln(2))
def __init__(self,b,N,iprec=512,u=None,x0=0): """ x0 is the development point for the Carleman matrix for the slog u is the initial value such that slog(u)=0 or equivalently sexp(0)=u if no u is specified we have slog(x0)=0 """ bsym = b self.bsym = bsym self.N = N self.iprec = iprec x0sym = x0 self.x0sym = x0sym self.prec = None bname = repr(bsym).strip('0').replace('.',',') if bsym == sqrt(2): bname = "sqrt2" if bsym == e**(1/e): bname = "eta" x0name = repr(x0sym) if x0name.find('.') > -1: if x0.is_real(): x0name = repr(float(x0sym)).strip('0').replace('.',',') else: x0name = repr(complex(x0sym)).strip('0').replace('.',',') # by some reason save does not work with additional . inside the path self.path = "savings/itet_%s"%bname + "_N%04d"%N + "_iprec%05d"%iprec + "_a%s"%x0name if iprec != None: b = num(bsym,iprec) self.b = b x0 = num(x0sym,iprec) if x0.is_real(): R = RealField(iprec) else: R = ComplexField(iprec) self.x0 = x0 else: if b == e and x0 == 0: R = QQ else: R = SR self.R = R #Carleman matrix if x0 == 0: #C = Matrix([[ m**n*log(b)**n/factorial(n) for n in range(N)] for m in range(N)]) coeffs = [ln(b)**n/factorial(n) for n in xrange(N)] else: #too slow #C = Matrix([ [ln(b)**n/factorial(n)*sum([binomial(m,k)*k**n*(b**x0)**k*(-x0)**(m-k) for k in range(m+1)]) for n in range(N)] for m in range(N)]) coeffs = [b**x0-x0]+[b**x0*ln(b)**n/factorial(n) for n in xrange(1,N)] def psmul(A,B): N = len(B) return [sum([A[k]*B[n-k] for k in xrange(n+1)]) for n in xrange(N)] C = Matrix(R,N) row = vector(R,[1]+(N-1)*[0]) C[0] = row for m in xrange(1,N): row = psmul(row,coeffs) C[m] = row A = (C - identity_matrix(N)).submatrix(1,0,N-1,N-1) self.A = A print "A computed." if iprec != None: A = num(A,iprec) row = A.solve_left(vector([1] + (N-2)*[0])) print "A solved." self.slog0coeffs = [0]+[row[n] for n in range(N-1)] self.slog0poly = PolynomialRing(R,'x')(self.slog0coeffs[:int(N)/2]) slog0ps = FormalPowerSeriesRing(R)(self.slog0coeffs) sexp0ps = slog0ps.inv() #print self.slog0ps | self.sexp0ps self.sexp0coeffs = sexp0ps[:N] self.sexp0poly = PolynomialRing(R,'x')(self.sexp0coeffs[:int(N)/2]) self.slog_raw0 = lambda z: self.slog0poly(z-self.x0) print "slog reversed." #the primary or the upper fixed point pfp = exp_fixpoint(b,1,prec=iprec) self.pfp = pfp r = abs(x0-pfp) #lower fixed point lfp = None if b <= R(e**(1/e)): lfp = exp_fixpoint(b,0,prec=iprec) r = min(r,abs(x0-lfp)) self.lfp = lfp self.r = r self.c = 0 if not u == None: self.c = - self.slog(u)