On 21 February 2012 15:10, Hauke Strasdat <[email protected]> wrote: > Hi, > > I recently discovered sympy and I must say it is really great! I am > mainly interested in matrices (matrix functions) > and symbolic derivatives. > > However, one thing I haven't quite understood yet: What is sympy's > relatation to numpy? I would say "undefined". Check http://code.google.com/p/sympy/issues/detail?id=537 > > Sympy has some support for numpy arrays. But is it in general a good > idea to use numpy.array instead of sympy.Matrix? Ideally I'd like to > define some matrix function which I can use then for numerical as well > as symbolic calculations. As far as I understand, Sympy has also some > numerical computation capabilities. So, is it actually a good idea to > use numpy in conjunction with sympy? Or should I better stick to pure > sympy? I found out there is also mpmath. Should I use this instead? Of > course, there are probably good arguments for all three choices. But, > it would be really great to hear some thoughts/arguments from you > guys. I would use numpy arrays for every numerical calculation (and will take care to actually use the float dtype instead of 'object'). If you need to create such an array from sympy expression evaluated for different inputs you can use lambdify (I personally don't like it because of many corner cases that are not covered by it, but it works well for simple expressions). Or you can use .subs(...).evalf() and map/list comprehension and then cast it to an array.
For symbolic stuff I would use sympy Matrix. Recently the MatrixSymbol and ImmutableMatrix were added to the code base, so you can do much more with matrices now. But this is not done yet: http://code.google.com/p/sympy/issues/detail?id=2759 So for arrays and big numerical matrices - numpy and lambdify (but do you _really_ need lambdify, I would type small simple expressions by hand) For small symbolic matrices - sympy and Matrix Bear in mind that others may have different advices and generally more trust in the way sympy and numpy interoperate. > > Thanks a lot, > Hauke > > -- > 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. > -- 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.
