Added a small guess function for transform DA-equation to DD-finite
authorAntonio Jimenez Pastor <ajpastor@risc.uni-linz.ac.at>
Fri, 12 Oct 2018 12:56:37 +0000 (14:56 +0200)
committerAntonio Jimenez Pastor <ajpastor@risc.uni-linz.ac.at>
Fri, 12 Oct 2018 12:56:37 +0000 (14:56 +0200)
ajpastor/dd_functions/toDiffAlgebraic.py
releases/diff_defined_functions__0.6.zip
releases/old/diff_defined_functions__0.6__18.10.12_14:56:36.zip [new file with mode: 0644]

index 9b9f885..04d8346 100644 (file)
@@ -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
 ####################################################################################################
index 5c5445d..2e2f2d8 100644 (file)
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 (file)
index 0000000..2e2f2d8
Binary files /dev/null and b/releases/old/diff_defined_functions__0.6__18.10.12_14:56:36.zip differ