# Functions for Lie Derivatives # ----------------------------------------------------------------------------------------------------------------------------- # # for a variable list 'V', and a vector space 'F' and a polynomial 'PHI' # generate the lie derivative in the direction 'F' of 'PHI' def lie_derivative(V, F, PHI): LIE = Matrix([diff(PHI, v) for v in V])*F return LIE[0][0] # ----------------------------------------------------------------------------------------------------------------------------- # # for a degree 'd', and a parameter list 'P', and a variable list 'V', and a linear vector space 'F1' # generate the representing matrix of the lie derivative in the direction 'F1' of the homogeneous polynomial of degree 'd' def linear_lie_derivative_representation(d, P, V, F1): # a basis 'Bd' of the finitely generated vector space of homogeneous polynomials of degree 'd' Bd = [mul(v) for v in [[V[i] for i in pd] for pd in Combinations([i for i in range(len(V))]*d, d).list()]] # the lie derivative $Ld$ in the direction 'F1' of each base of 'Bd' Ld = [Matrix([diff(bd, v) for v in V]) * F1 for bd in Bd] # the representing matrix 'Rd' of the lie derivative in the direction 'F1' of the homogeneous polynomial of degree 'd' Rd = Matrix([[l[0][0].monomial_coefficient(b) for b in Bd] for l in Ld]) return [Rd, Bd] # ----------------------------------------------------------------------------------------------------------------------------- # # for a degree 'd', and a parameter list 'P', and a variable list 'V', # and the the minimal polynomial 'C1' of the lie derivative of the homogeneous polynomials of degree '1' # and the the minimal polynomial 'Cdp' of the lie derivative of the homogeneous polynomials of degree 'd-1' # generate an annihilating polynomial of the lie derivative of the homogeneous polynomial of degree 'd' # where 'Cdp' is of the form 'x**deg_Cdp + c1 * x**(deg_Cdp-1) + ... + c(deg_Cdp)' # where 'Cdp' is of the form 'x**deg_C1 + b1 * x**(deg_C1-1) + ... + b(deg_C1)' def linear_lie_derivative_annihilating_polynomial(d, P, V, C1, Cdp, PF, lib_log_opt = 0): # prepare if lib_log_opt != 0: TIME0 = cputime(subprocesses=True) # the coefficients 'Coe1 = [-b1,b2,...,(-1)**(deg_C1)*b(deg_C1)]' of the the minimal polynomial 'C1' Coe1 = C1.coefficients(sparse=False) Coe1 = list(reversed(Coe1)) deg_C1 = C1.degree() Coe1 = [Coe1[i] if i % 2 == 0 else -Coe1[i] for i in range(deg_C1+1)] # the representation 'Cdp_t = mul(((x-di)**deg_Cdp + c1 * (x-di)**(deg_Cdp-1) + ... + c(deg_Cdp)) for i in range(deg_C1))' deg_Cdp = Cdp.degree() DV = var(['c%d' % i for i in range(deg_C1)]) x = parent(Cdp).gen() ParaR = parent(Cdp.coefficients()[0]) PR = PolynomialRing(ParaR, DV, order='lex') DV = PR.gens() SymR = PolynomialRing(PR, x) x = SymR.gen() Cdp_t = mul([Cdp.subs(x = x - d) for d in DV]) if lib_log_opt != 0: TIME1 = cputime(subprocesses=True) print(lib_log_opt+1, '-th Annihilating Polynomial of Symmetric Representation:', TIME1-TIME0, 'seconds') # the symmetric reductions for the coefficients of 'Cdp_t' Coe = Cdp_t.coefficients(sparse=False) SV = var(['e%d' % i for i in range(deg_C1)]) SymR = PolynomialRing(ParaR, SV) SV = SymR.gens() Coe = [symmetric_reduction(c, SV, DV, SymR, PR, deg_C1) for c in Coe] if lib_log_opt != 0: TIME2 = cputime(subprocesses=True) print(lib_log_opt+1, '-th Symmetric Reduction for Annihilating Polynomial:', TIME2-TIME1, 'seconds') Coe = [c.subs({SV[i]:Coe1[i+1] for i in range(deg_C1)}) for c in Coe] Coe = [PF(c) for c in Coe] if Coe[0] == 0 and Coe[1] == 0: Coe = Coe[1:] min_poly = sum(PF(Coe[i])*x**i for i in range(len(Coe))) fct = min_poly.factor() min_poly = mul(f[0] for f in fct) if lib_log_opt != 0: TIME3 = cputime(subprocesses=True) print(lib_log_opt+1, '-th Simplification for Annihilating Polynomial:', TIME3-TIME2, 'seconds') return min_poly # ----------------------------------------------------------------------------------------------------------------------------- # # for a parameter list 'P', and a variable list 'V', and a linear vector space 'F1' # generate a basis of the kernel of the lie derivative in the direction 'F1' of the homogeneous polynomial of degree '2' def linear_lie_derivative_kernel(P, V, Rep2, Liu0, opt): # the representing matrix 'Rd' of the lie derivative in the direction 'F1' of the homogeneous polynomial of degree '2' if opt == 1: A = Rep2.with_rescaled_row(0, 1) DET = A.determinant(); for i in range(len(Rep2[0])): flag = 1 if A[i][i] == 0: flag = 0 for j in range(len(Rep2[0])): if A[j][i] != 0: A.swap_rows(i,j) flag = 1 if flag == 1: for j in [i+1..len(Rep2[0])-1]: if A[j][i] != 0: AAA = A[i][i]; BBB = A[j][i] A.rescale_row(i, BBB) A.rescale_row(j, AAA) A.add_multiple_of_row(j, i, -1) A = Matrix([[((a1.numerator()).reduce(Liu0))/(a1.denominator()) for a1 in a] for a in A]) print(A) return kernel(A) else: return kernel(Rep2) # ----------------------------------------------------------------------------------------------------------------------------- #