Skip to content

Conversation

@ManojVS06
Copy link

Refactor iter_lie to iter_lie_numeric for numerical computation of Lie derivatives. Introduced helper functions for gradient and derivative calculations.

Refactor iter_lie to iter_lie_numeric for numerical computation of Lie derivatives. Introduced helper functions for gradient and derivative calculations.
@iperezav
Copy link
Owner

iperezav commented Feb 6, 2026

Hello @ManojVS06,

Thanks for putting effort on this package. I did some checking. I took the system example in
https://arxiv.org/pdf/2509.19908

and defined it in your code:

if __name__ == "__main__":
    # define state functions and vector fields
    def h(z):
        # output function h = x2
        return float(z[1])

    # vector fields as callables: g0, g1, g2 producing arrays of length 2
    def g0(z):
        x1, x2 = z
        return np.array([-x1 + (1-x1)*sp.exp(x2/(1+x2)), -2*x2 + (1-x1)*sp.exp(x2/(1+x2))], dtype=float)

    def g1(z):
        x1, x2 = z
        return np.array([0.0, 1.0], dtype=float)  # example; adapt to your system

    #def g2(z):
    #    x1, x2 = z
    #    return np.array([0.0, -x2], dtype=float)

    g_list = [g0, g1]

    z0 = np.array([0.0, 0.0], dtype=float)
    Ntrunc = 2

    funcs, vals = iter_lie_numeric(h, g_list, z0, Ntrunc)
    print("Total Lie derivatives:", vals.size)
    print("Values at z0:\n", vals)

checked it with the package:

import numpy as np
import sympy as sp
from CFS import iter_lie

# Define the symbolic variables
x1, x2 = sp.symbols('x1 x2')
x = sp.Matrix([x1, x2])


# Define the system symbolically
g = sp.transpose(sp.Matrix([[-x1 + (1-x1)*sp.exp(x2/(1+x2)), -2*x2 + (1-x1)*sp.exp(x2/(1+x2))], [0, 1]]))

# Define the output symbolically
h = x2

# The truncation of the length of the words that index the Chen-Fliess series
Ntrunc = 2

# Coefficients of the Chen-Fliess series evaluated at the initial state
Ceta = np.array(iter_lie(h,g,x,Ntrunc).subs([(x[0], 0),(x[1], 0)]))

print(Ceta)

and they don't coincide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants