[sympy] Re: Python sympy question on creating list of functions

2013-04-17 Thread Manoj Kumar
Is f assumed to be a function of all coords? Just of the top of my head I suppose something like this can be done. >>> coords = symbols("x,y,z") >>> derivatives = [diff(f, coor) for coor in coords] So that you get a list of your derivatives. Or I might have been completely wrong in understandi

[sympy] Re: Python sympy question on creating list of functions

2013-04-17 Thread thomas hisch
Maybe you want to use nested lambdas: map(lambda c: lambda f: Diff(f,c), coords) On Wednesday, April 17, 2013 10:11:14 PM UTC+2, brombo wrote: > > Consider the following > > coords = symbols('x,y,z') > > I wish to contruct the list of functions: > > [Dx,Dy,Dx] > > where > > def Dx(f): >

Re: [sympy] Re: Python sympy question on creating list of functions

2013-04-17 Thread Aaron Meurer
You can do the whole thing symbolically with Lambda [Lambda(f, Derivative(f, coord)) for coord in coordinates] Unlike the normal list comprehension, Derivative is unevaluated, so you create the object before you actually have f, and unlike the lambda version, you can access and manipulate the obj

Re: [sympy] Re: Python sympy question on creating list of functions

2013-04-17 Thread Prasoon Shukla
Thanks for the answer (and for the question too). I had been thinking of a way to implement methods that would be independent of number of coordinates. I just ran some test code and this method works great. I think I can use this for the proposed vector calculus module. Also, I suppose we can u