From: Antonio Jimenez Pastor Date: Tue, 4 Dec 2018 15:33:14 +0000 (+0100) Subject: Work done concerning the functional inverse of Dn-finite functions. X-Git-Url: http://git.risc.jku.at/gitweb/?a=commitdiff_plain;h=f95f3ee669525f97502dd6ba1a9070665efb2319;p=ajpastor%2Fdiff_defined_functions.git Work done concerning the functional inverse of Dn-finite functions. New feature: - Method func_inverse_DA: it computes the differentially algebraic equation for the functional inverse of a Dn-finite function. - Method FaaDiBruno_polynomials: method that returns the numerator and denominator of f^(k)(g(x)) as differential polynomials on g(x) when f(g(x)) = x. --- diff --git a/ajpastor/dd_functions/ddFunction.py b/ajpastor/dd_functions/ddFunction.py index 99eb519..86109db 100644 --- a/ajpastor/dd_functions/ddFunction.py +++ b/ajpastor/dd_functions/ddFunction.py @@ -2728,6 +2728,7 @@ def _get_initial_poly(poly, dic, m): return result; else: raise ValueError("An impossible point was reached"); + ################################################################################################### ### COMMAND CONVERSION OF DD_FUNCTIONS diff --git a/ajpastor/dd_functions/toDiffAlgebraic.py b/ajpastor/dd_functions/toDiffAlgebraic.py index 41bca2c..ec4d207 100644 --- a/ajpastor/dd_functions/toDiffAlgebraic.py +++ b/ajpastor/dd_functions/toDiffAlgebraic.py @@ -273,6 +273,25 @@ 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 func_inverse_DA(func, _debug=False): + equation = diff_to_diffalg(func, _debug=_debug); + + if(_debug): print equation; + + parent = equation.parent(); + y = parent.gens()[0]; + + n = len(equation.variables()); + + quot = [FaaDiBruno_polynomials(i, parent)[0]/FaaDiBruno_polynomials(i,parent)[1] for i in range(n)]; + coeffs = [el(**{str(parent.base().gens()[0]) : y[0]}) for el in equation.coefficients()]; + monomials = equation.monomials(); + + sol = sum(monomials[i](**{str(y[j]) : quot[j] for j in range(n)})*coeffs[i] for i in range(len(monomials))); + if(hasattr(sol, "numerator")): + return parent(sol.numerator()); + return parent(sol); + def guess_DA_DDfinite(poly, init=[], bS=None, bd = None, all=True): ''' Method that tries to compute a DD-finite differential equation @@ -373,7 +392,35 @@ def guess_DA_DDfinite(poly, init=[], bS=None, bd = None, all=True): return sols[0]; return sols; + +################################################################################################### +### FAA DI BRUNO functions +################################################################################################### +@cached_function +def FaaDiBruno_polynomials(n, parent): + if(n < 0): + raise ValueError("No Faa Di Bruno polynomial can be computed for negative index"); + elif(not(is_InfinitePolynomialRing(parent))): + if((not(is_PolynomialRing(parent))) and (not(is_MPolynomialRing(parent)))): + raise TypeError("The parent ring is not valid: needed polynomial rings or InfinitePolynomialRing"); + return FaaDiBruno_polynomials(n, InfinitePolynomialRing(parent, "y")); + + if(parent.base().ngens() == 0 or parent.base().gens()[0] == 1): + raise TypeError("Needed a inner variable in the coefficient ring"); + + + x = parent.base().gens()[0]; + y = parent.gens()[0]; + if(n == 0): + return (parent(parent.base().gens()[0]), parent.one()); + if(n == 1): + return (parent.one(), y[1]); + else: + prev = [FaaDiBruno_polynomials(k, parent) for k in range(n)]; + ele = -sum(prev[k][0]*bell_polynomial(n,k)(**{"x%d" %i : y[i+1] for i in range(n-k+1)})/prev[k][1] for k in range(1,n))/(y[1]**n); + return (ele.numerator(), ele.denominator()); + S #################################################################################################### #### PACKAGE ENVIRONMENT VARIABLES #################################################################################################### -__all__ = ["is_InfinitePolynomialRing", "get_InfinitePolynomialRingGen", "get_InfinitePolynomialRingVaribale", "infinite_derivative", "toDifferentiallyAlgebraic_Below", "diff_to_diffalg", "inverse_DA", "guess_DA_DDfinite"]; +__all__ = ["is_InfinitePolynomialRing", "get_InfinitePolynomialRingGen", "get_InfinitePolynomialRingVaribale", "infinite_derivative", "toDifferentiallyAlgebraic_Below", "diff_to_diffalg", "inverse_DA", "func_inverse_DA", "guess_DA_DDfinite", "FaaDiBruno_polynomials"]; diff --git a/releases/diff_defined_functions__0.6.zip b/releases/diff_defined_functions__0.6.zip index 24332e0..bed74e0 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.12.04_16:33:14.zip b/releases/old/diff_defined_functions__0.6__18.12.04_16:33:14.zip new file mode 100644 index 0000000..bed74e0 Binary files /dev/null and b/releases/old/diff_defined_functions__0.6__18.12.04_16:33:14.zip differ