import sys
sys.path.append("/home/marc/cur/ore_algebra/src/")
from ore_algebra import *
Pols.<z> = PolynomialRing(QQ)
(z + 1)*(z - 1)
z.degree()
DiffOps.<Dz> = OreAlgebra(Pols)
Dz*z
dop = (z*Dz - 1)*(z*Dz - 5)
dop
dop.polynomial_solutions()
(Dz - 1).numerical_solution(ini=[1], path=[0, 1])
(Dz - 1).numerical_solution(ini=[1], path=[0, 1], eps=1e-100)
(Dz - 1).numerical_solution(ini=[1], path=[0, i*pi])
dop = Dz*z*Dz; dop
dop(log(z))
dop.numerical_solution(ini=[0,1], path=[1,2])
dop.numerical_solution(ini=[0,1], path=[1, i, -1])
dop.numerical_solution(ini=[0,1], path=[1, -i, -1])
dop.numerical_solution(ini=[0,1], path=[1, i, -1, -i, 1, i, -1])
from ore_algebra.analytic.examples import fcc
fcc.dop4
fcc.dop4.numerical_solution([0, 0, 0, 1], [0, 1], 1e-60)
fcc.dop5
fcc.dop5.numerical_solution([0, 0, 0, 0, 1, 0], [0, 1/5+i/2, 1], 1e-60)
fcc.dop6
ini = [0, 0, 0, 0, 0, 1, 0, 0]
fcc.dop6.numerical_solution(ini, [0, 3/2 + i, 1], 1e-60)
from ore_algebra.analytic.examples import ssw
dop = ssw.dop[4,1,1]; dop
terms = oeis("A151331").first_terms()
terms[:5]
loc = dop.local_basis_monomials(0); loc
ini = [(terms[m.degree(t)] if m.is_polynomial(t) else 0) for m in loc]
ini
import itertools
rts = dop.leading_coefficient().roots(QQbar, multiplicities=False)
rts = [rt for rt in rts if not rt.is_zero()]
rts = sorted(rts, key=abs)
rts
loc = dop.local_basis_expansions(rts[0])
loc[0]
loc[1]
loc[2]
con = dop.numerical_transition_matrix([0, rts[0]])*vector(ini)
con
B.<n> = AsymptoticRing('QQ^n * n^QQ * log(n)^QQ', QQ)
B.coefficients_of_generating_function(lambda t: log(t-1/8), (1/8,), precision=2)
N(8/(3*pi))