From: Antonio Jimenez Pastor Date: Fri, 12 Oct 2018 12:56:37 +0000 (+0200) Subject: Added a small guess function for transform DA-equation to DD-finite X-Git-Url: http://git.risc.jku.at/gitweb/?a=commitdiff_plain;h=cc3e1d62352614353b5eb4f6b244598cabe3f674;p=ajpastor%2Fdiff_defined_functions.git Added a small guess function for transform DA-equation to DD-finite --- diff --git a/ajpastor/dd_functions/toDiffAlgebraic.py b/ajpastor/dd_functions/toDiffAlgebraic.py index 9b9f885..04d8346 100644 --- a/ajpastor/dd_functions/toDiffAlgebraic.py +++ b/ajpastor/dd_functions/toDiffAlgebraic.py @@ -260,7 +260,47 @@ def inverse_DA(poly, vars=None): ## Computing the final equation return poly(**{str(g[i]): derivatives[i] for i in range(len(g))}).numerator(); - +def guess_DA_DDfinite(poly): + ''' + Method that tries to compute a DD-finite differential equation + for a DA-function with constant coefficients. + + It just tries all the possibilities. It uses the Composition class + to get the possibilities of the orders for the coefficients. + ''' + if(not poly.is_homogeneous()): + raise TypeError("We require a homogeneous polynomial"); + + S = poly.degree(); d = S - poly.parent().ngens() + 2; + + compositions = Compositions(S, length = d+1); + coeffs = [["a_%d_%d" %(i,j) for j in range(S)] for i in range(d+1)]; + R = ParametrizedDDRing(DFinite, sum(coeffs, [])); + R2 = R.to_depth(2); + coeffs = [[R.parameter(coeffs[i][j]) for j in range(S)] for i in range(d+1)]; + for c in compositions: + ## Building the parametrized guess + e = [R.element([coeffs[i][j] for j in range(c[i])] + [1],[1] + (c[i]-1)*[0]) for i in range(d+1)]; + f = R2.element(e); + + ## Computing the DA equation + poly2 = diff_to_diffalg(f); + + ## Comparing the algebraic equations + m = poly.monomials(); + m2 = poly2.monomials(); + + eqs = []; + for mon in m2: + if(mon in m): + eqs += [poly2.coefficient(mon) - poly.coefficient(mon)]; + else: + eqs += [poly2.coefficient(mon)]; + P = R.base_field.base(); eqs = [P(str(el)) for el in eqs]; + gb = ideal(eqs).groebner_basis(); + if(1 not in gb): + return f,gb; + raise ValueError("No relation of the coefficients found for the polynomial %s" %poly); #################################################################################################### #### PACKAGE ENVIRONMENT VARIABLES #################################################################################################### diff --git a/releases/diff_defined_functions__0.6.zip b/releases/diff_defined_functions__0.6.zip index 5c5445d..2e2f2d8 100644 Binary files a/releases/diff_defined_functions__0.6.zip and b/releases/diff_defined_functions__0.6.zip differ diff --git a/releases/old/diff_defined_functions__0.6__18.10.12_14:56:36.zip b/releases/old/diff_defined_functions__0.6__18.10.12_14:56:36.zip new file mode 100644 index 0000000..2e2f2d8 Binary files /dev/null and b/releases/old/diff_defined_functions__0.6__18.10.12_14:56:36.zip differ