On Sun, Oct 31, 2010 at 3:41 PM, Aaron S. Meurer <[email protected]> wrote: > I am still trying to fully understand the code below, but if one of the subs > is trying to do something like diff(f(x), x).subs(x, g(x)), then you will get > an error in SymPy for the above reason. > > Aaron Meurer
The basic approach is to substitute a symbol for f(x) say f1 and then take the derivative with respect to that. You know the substitution, so you can reverse it. Once the derivative is done, you reverse the substitution. Then, you can take the derivative with respect to x. So, the steps become. 1. Build list of symbols for functions. 2. Build a list of substitutions for the functions and the reverse. 3. Substitute for the functions. 4. Run derivatives with respect to the symbols. 5. Substitute functions for the symbols. 6. Take any derivatives with respect to the function variables. Hope that helps the explanation. A lot of what's done in the code is using zip and map to make the code fast, but I originally wrote it as above. Python has appropriate functions that this should still be fast. Cheers, Tim. -- Tim Lahey PhD Candidate, Systems Design Engineering University of Waterloo http://www.linkedin.com/in/timlahey -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
