If we have an expression (string) that contains an indexed variable (like x[0]), we should be able to differentiate w.r.t. it as well.
As explained in the updated docstring, the way to do it is to pass a sympy.Indexed instance as the independent variable (not to be confused with an sympy.IndexedBase instance!).
Note that we also need to pass an sympy.IndexedBase into the SymPy list of known symbols (i.e. as one of vars), otherwise the parser breaks.
For reference, we added mod files with indexed vars in #1504.
If we have an expression (string) that contains an indexed variable (like
x[0]
), we should be able to differentiate w.r.t. it as well. As explained in the updated docstring, the way to do it is to pass asympy.Indexed
instance as the independent variable (not to be confused with ansympy.IndexedBase
instance!). Note that we also need to pass ansympy.IndexedBase
into the SymPy list of known symbols (i.e. as one ofvars
), otherwise the parser breaks.For reference, we added mod files with indexed vars in #1504.