Hi Sebastian!



 SebGruber1996:

Then why did my function ‘n_deriv__’ work like intended?


n_deriv__ is storing the results of calling functions in your dictionary,
rather than functions, themselves.  So the scoping issues with functions
(which apply equally to lambdas) don’t arise.
As an aside, capturing just i (rather than  g[str (i)]) into your lambda:
g[str(i+1)] = lambda y, i = i: jac(g[str (i)], y, create_graph=True)

addresses the core issue more directly.
Best.
K. Frank