def h(t, prec): Dop, x, Dx = DifferentialOperators(QQ) L = Dx * (x * (x - 1) * (x - t)) * Dx + x hprec = prec + 100 C = ComplexField(hprec) CBF = ComplexBallField(hprec) # Formal monodromy + connection matrices base = t / 2 m1 = L.numerical_transition_matrix([0, base], ZZ(2)**(-prec)) m2 = L.numerical_transition_matrix([t, base], ZZ(2)**(-prec)) delta = matrix(CBF, [[1, 0], [2 * pi * i, 1]]) mat = m1 * delta * ~m1 * m2 * delta * ~m2 # log(eigenvalue) tr = mat.trace().real().mid() Pol, la = PolynomialRing(C, 'la').objgen() char = (la + 1 / la - tr).numerator() rt = char.roots(multiplicities=False)[0] val = (rt.log() / C(2 * i * pi))**2 return val
....: print("{}\t{}".format(k, asy(dop, 50))) 2 [0.5613226189564568270393235883810334361992061196...] 3 [0.6049645385653542644762421366594344081594004532...] 4 [0.8724609101215661991266866210277371543438236597...] 5 [1.6248570260792824202355889447707451896274397227...] 6 [3.7818686091669627122667627632166635874791894574...] 7 [10.708084931657092542368755716629129442143758729...] 8 [36.087875288239535234327556576384625828336477172...] 9 [142.21543933025087303695985127830779667104241363...] 10 [645.82842969986593153458120613640308394397361391...] """ from sage.all import ZZ, QQ from ore_algebra import DifferentialOperators Dops, z, Dz = DifferentialOperators(QQ, 'z') egf = (1+z+(ZZ(3)/2)*z**2+(ZZ(5)/2)*z**3+(ZZ(37)/8)*z**4+(ZZ(373)/40)*z**5 +(ZZ(4829)/240)*z**6+(ZZ(76981)/1680)*z**7+(ZZ(293057)/2688)*z**8 +(ZZ(32536277)/120960)*z**9+(ZZ(827662693)/1209600)*z**10) dop = {} dop[2] = (z**2-3*z+1)*Dz**3+(-z**2+6*z-6)*Dz**2+(-2*z+3)*Dz dop[3] = ((3*z**2-4*z+1)*Dz**4+(-4*z**2+18*z-10)*Dz**3+(z**2-12*z+14)*Dz**2 +(z-3)*Dz) dop[4] = ((-z**3+6*z**2-5*z+1)*Dz**5+(2*z**3-18*z**2+40*z-15)*Dz**4 +(-z**3+16*z**2-54*z+41)*Dz**3+(-4*z**2+22*z-24)*Dz**2+(-2*z+3)*Dz) dop[5] = ((-4*z**3+10*z**2-6*z+1)*Dz**6+(9*z**3-58*z**2+75*z-21)*Dz**5 +(-6*z**3+78*z**2-184*z+95)*Dz**4+(z**3-33*z**2+141*z-110)*Dz**3 +(3*z**2-32*z+40)*Dz**2+(z-3)*Dz)
sage: ea.dop.numerical_solution(ea.ini, [ea.pt, 1]) [1.17691287735093...] sage: stdfun.sin.dop(sin(x)) 0 sage: stdfun.sin.dop.numerical_solution( ....: stdfun.sin.ini, [stdfun.sin.pt, pi/3]) [0.86602540378443...] """ import collections import sage.functions.all as funs from sage.all import pi, prod, QQ, ZZ from ore_algebra import DifferentialOperators Dops, x, Dx = DifferentialOperators(QQ, 'x') # XXX: perhaps use DFiniteFunction once it gets stable enough. IVP = collections.namedtuple("IVP", ["pt", "dop", "ini"]) airy_ai = IVP(0, Dx**2 - x, [ QQ(1) / 3 * 3**(QQ(1) / 3) / funs.gamma(QQ(2) / 3), -QQ(1) / 2 * 3**(QQ(1) / 6) / pi * funs.gamma(QQ(2) / 3) ]) airy_bi = IVP(0, airy_ai.dop, [ QQ(1) / 3 * 3**(QQ(5) / 6) / funs.gamma(QQ(2) / 3), QQ(1) / 2 * 3**(QQ(2) / 3) / pi * funs.gamma(QQ(2) / 3) ]) arctan = IVP(0, (x**2 + 1) * Dx**2 + 2 * x * Dx, [0, 1])
(A.68) [-0.1404863030270...] (A.69) [-0.9708046956249...] (A.70) [-0.0018467475220...] """ import string from sage.functions.all import log, sqrt from sage.misc.misc_c import prod from sage.rings.all import AA, QQ, ZZ from sage.symbolic.all import SR, I, pi from ore_algebra import DifferentialOperators from ore_algebra.analytic.path import Point Dops, x, Dx = DifferentialOperators() Rat = Dops.base_ring().fraction_field() def diffop(word): dlog = [Rat(log(a).diff().canonicalize_radical()) for a in word] factors = [(Dx - sum(dlog[:i])) for i in range(len(dlog))] dop = prod(reversed([(Dx - sum(dlog[:i])) for i in range(len(dlog) + 1)])) dop = dop.numerator() return dop # - Second part not robust, but seems to be enough for all our examples # - The last call to series() MUST use :-series (as opposed to # MultiSeries:-series), for MultiSeries always assumes that the expansion # variable tends to zero along the positive real axis
efficiently:: sage: from ore_algebra.analytic.examples.misc import iint_quadratic_alg as pb sage: pb.dop.numerical_solution(pb.ini, [0, 1/5000*sqrt(277774997191/11111)], 2^(-100)) # 1.6 s [3368168.805821918535950852115...] """ import collections from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.all import NumberField from sage.rings.all import ZZ, QQ, AA, RIF, RR from ore_algebra import DifferentialOperators IVP = collections.namedtuple("IVP", ["dop", "ini"]) DiffOps_a, a, Da = DifferentialOperators(QQ, 'a') koutschan1 = IVP( dop = (1315013644371957611900*a**2+263002728874391522380*a+13150136443719576119)*Da**3 + (2630027288743915223800*a**2+16306169190212274387560*a+1604316646133788286518)*Da**2 + (1315013644371957611900*a**2-39881765316802329075320*a+35449082663034775873349)*Da + (-278967152068515080896550+6575068221859788059500*a), ini = [ QQ(5494216492395559)/3051757812500000000000000000000, QQ(6932746783438351)/610351562500000000000000000000, 1/QQ(2) * QQ(1142339612827789)/19073486328125000000000000000 ] ) y, z = PolynomialRing(QQ, ['y', 'z']).gens() salvy1_pol = (16*y**6*z**2 + 8*y**5*z**3 + y**4*z**4 + 128*y**5*z**2 + 48*y**4*z**3 + 4*y**3*z**4 + 32*y**5* z + 372*y**4*z**2 + 107*y**3*z**3 + 6*y**2*z**4 + 88*y**4*z + 498*y**3*z**2 + 113*y**2*z**3 + 4*y*z**4 + 16*y**4 + 43*y**3*z + 311*y**2*z**2 + 57*y*z**3 + z**4 + 24*y**3 - 43*y**2*z + 72*y*z **2 + 11*z**3 +
def _test_monodromy_matrices(): r""" TESTS:: sage: from ore_algebra.analytic.monodromy import _test_monodromy_matrices sage: _test_monodromy_matrices() """ from sage.all import matrix from ore_algebra import DifferentialOperators Dops, x, Dx = DifferentialOperators() h = QQ(1) / 2 i = QQi.gen() def norm(m): return sum(c.abs()**2 for c in m.list()).sqrtpos() mon = monodromy_matrices((x**2 + 1) * Dx - 1, QQ(1000000)) assert norm(mon[0] - CBF(pi).exp()) < RBF(1e-10) assert norm(mon[1] - CBF(-pi).exp()) < RBF(1e-10) mon = monodromy_matrices((x**2 - 1) * Dx - 1, QQ(0)) assert all(m == -1 for m in mon) dop = (x**2 + 1) * Dx**2 + 2 * x * Dx mon = monodromy_matrices(dop, QQbar(i + 1)) # mon[0] <--> i assert norm(mon[0] - matrix(CBF, [[1, pi * (1 + 2 * i)], [0, 1]])) < RBF(1e-10) assert norm(mon[1] - matrix(CBF, [[1, -pi * (1 + 2 * i)], [0, 1]])) < RBF(1e-10) mon = monodromy_matrices(dop, QQbar(-i + 1)) # mon[0] <--> -i assert norm(mon[0] - matrix(CBF, [[1, pi * (-1 + 2 * i)], [0, 1]])) < RBF(1e-10) assert norm(mon[1] - matrix(CBF, [[1, pi * (1 - 2 * i)], [0, 1]])) < RBF(1e-10) mon = monodromy_matrices(dop, QQbar(i)) # mon[0] <--> i assert norm(mon[0] - matrix(CBF, [[1, 0], [2 * pi * i, 1]])) < RBF(1e-10) assert norm(mon[1] - matrix(CBF, [[1, 0], [-2 * pi * i, 1]])) < RBF(1e-10) mon = monodromy_matrices(dop, QQbar(i), sing=[QQbar(i)]) assert len(mon) == 1 assert norm(mon[0] - matrix(CBF, [[1, 0], [2 * pi * i, 1]])) < RBF(1e-10) mon = monodromy_matrices(dop, QQbar(i), sing=[QQbar(-i)]) assert len(mon) == 1 assert norm(mon[0] - matrix(CBF, [[1, 0], [-2 * pi * i, 1]])) < RBF(1e-10) mon = monodromy_matrices(dop, QQbar(-i), sing=[QQbar(i)]) assert len(mon) == 1 assert norm(mon[0] - matrix(CBF, [[1, 0], [-2 * pi * i, 1]])) < RBF(1e-10) mon = monodromy_matrices(dop, QQbar(i), sing=[]) assert mon == [] dop = (x**2 + 1) * (x**2 - 1) * Dx**2 + 1 mon = monodromy_matrices(dop, QQ(0), sing=[QQ(1), QQbar(i)]) m0 = dop.numerical_transition_matrix([0, i + 1, 2 * i, i - 1, 0]) assert norm(m0 - mon[0]) < RBF(1e-10) m1 = dop.numerical_transition_matrix([0, 1 - i, 2, 1 + i, 0]) assert norm(m1 - mon[1]) < RBF(1e-10) dop = x * (x - 3) * (x - 4) * (x**2 - 6 * x + 10) * Dx**2 - 1 mon = monodromy_matrices(dop, QQ(-1)) m0 = dop.numerical_transition_matrix([-1, -i, 1, i, -1]) assert norm(m0 - mon[0]) < RBF(1e-10) m1 = dop.numerical_transition_matrix( [-1, i / 2, 3 - i / 2, 3 + h, 3 + i / 2, i / 2, -1]) assert norm(m1 - mon[1]) < RBF(1e-10) m2 = dop.numerical_transition_matrix( [-1, i / 2, 3 + i / 2, 4 - i / 2, 4 + h, 4 + i / 2, i / 2, -1]) assert norm(m2 - mon[2]) < RBF(1e-10) m3 = dop.numerical_transition_matrix([-1, 3 + i + h, 3 + 2 * i, -1]) assert norm(m3 - mon[3]) < RBF(1e-10) m4 = dop.numerical_transition_matrix( [-1, 3 - 2 * i, 3 - i + h, 3 - i / 2, -1]) assert norm(m4 - mon[4]) < RBF(1e-10) dop = (x - i)**2 * (x + i) * Dx - 1 mon = monodromy_matrices(dop, 0) assert norm(mon[0] + i) < RBF(1e-10) assert norm(mon[1] - i) < RBF(1e-10) dop = (x - i)**2 * (x + i) * Dx**2 - 1 mon = monodromy_matrices(dop, 0) m0 = dop.numerical_transition_matrix([0, i + 1, 2 * i, i - 1, 0]) assert norm(m0 - mon[0]) < RBF(1e-10) m1 = dop.numerical_transition_matrix([0, -i - 1, -2 * i, -i + 1, 0]) assert norm(m1 - mon[1]) < RBF(1e-10)
sage: ssw.dop2.numerical_solution(ssw.ini2, [0,1]) # long time (4.3 s), TODO: double-check result [10.662510694...] The operator P[1, 0, 0, "xy"] from the same work:: sage: ssw.dop3.numerical_transition_matrix([0, 1/4]) [ [-206.5126691369...] + [...]*I [16.000000000000...] + [...]*I [1.20938909474579...] + [...]*I] [ [1489.126691369...] + [...]*I [-128.00000000000...] + [...]*I [3.9061090525420...] + [...]*I] [ [1925.57548817...] + [-1536.00000000...]*I [768.000000000...] + [...]*I [-124.21690469554...] + [128.000000000000...]*I] """ from sage.rings.all import Integer, QQ from ore_algebra import DifferentialOperators DiffOps, t, Dt = DifferentialOperators(QQ, 't') dop1 = ( (20643840 * t**11 - 8650752 * t**10 + 24975360 * t**9 + 1711488 * t**8 + 52224 * t**7 - 978144 * t**6 - 179040 * t**5 - 52176 * t**4 - 12552 * t**3 - 4944 * t**2 - 552 * t - 96) + (103219200 * t**12 - 53280768 * t**11 + 115279872 * t**10 - 2172288 * t**9 - 10069632 * t**8 - 2219040 * t**7 - 435456 * t**6 + 269016 * t**5 - 25992 * t**4 + 17496 * t**3 + 5496 * t**2 + 648 * t + 96) * Dt + (103219200 * t**13 - 63307776 * t**12 + 99222528 * t**11 - 4771776 * t**10 - 27972480 * t**9 + 4192752 * t**8 - 1230384 * t**7 + 880272 * t**6 - 126672 * t**5 + 52656 * t**4 - 1620 * t**3 - 600 * t**2 - 96 * t) * Dt**2 + (34406400 * t**14 - 24444928 * t**13 + 25568256 * t**12 + 606272 * t**11 - 17373888 * t**10 + 4926192 * t**9 - 857568 * t**8 + 477496 * t**7 - 48240 * t**6 + 13480 * t**5 - 3036 * t**4 - 1308 * t**3 + 48 * t**2) *
r""" Miscellaneous examples An example kindly provided by Christoph Koutschan:: sage: from ore_algebra.analytic.examples.misc import koutschan1 sage: koutschan1.dop.numerical_solution(koutschan1.ini, [0, 84]) [0.011501537469552017...] """ import collections from sage.rings.rational_field import QQ from ore_algebra import DifferentialOperators IVP = collections.namedtuple("IVP", ["dop", "ini"]) DiffOps, a, Da = DifferentialOperators(QQ, 'a') koutschan1 = IVP( dop = (1315013644371957611900*a**2+263002728874391522380*a+13150136443719576119)*Da**3 + (2630027288743915223800*a**2+16306169190212274387560*a+1604316646133788286518)*Da**2 + (1315013644371957611900*a**2-39881765316802329075320*a+35449082663034775873349)*Da + (-278967152068515080896550+6575068221859788059500*a), ini = [ QQ(5494216492395559)/3051757812500000000000000000000, QQ(6932746783438351)/610351562500000000000000000000, 1/QQ(2) * QQ(1142339612827789)/19073486328125000000000000000 ] )
sage: melczer1.numerical_transition_matrix([0, rts[1]])[0, 0] [4.64191240683...] + [-0.01596122801...]*I sage: melczer1.local_basis_expansions(rts[1]) [1 + (1269/32*a+3105/28)*(z + 0.086...? + 0.069...*I)^4 + ..., sqrt(z + 0.086...? + 0.069...*I) + (365/96*a+13/3)*(z + 0.086...? + 0.069...*I)^(3/2) - ..., ...] """ import collections from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.rational_field import QQ from ore_algebra import DifferentialOperators IVP = collections.namedtuple("IVP", ["dop", "ini"]) DiffOps_a, a, Da = DifferentialOperators(QQ, 'a') koutschan1 = IVP( dop=(1315013644371957611900 * a**2 + 263002728874391522380 * a + 13150136443719576119) * Da**3 + (2630027288743915223800 * a**2 + 16306169190212274387560 * a + 1604316646133788286518) * Da**2 + (1315013644371957611900 * a**2 - 39881765316802329075320 * a + 35449082663034775873349) * Da + (-278967152068515080896550 + 6575068221859788059500 * a), ini=[ QQ(5494216492395559) / 3051757812500000000000000000000, QQ(6932746783438351) / 610351562500000000000000000000, 1 / QQ(2) * QQ(1142339612827789) / 19073486328125000000000000000 ]) y, z = PolynomialRing(QQ, ['y', 'z']).gens()