Re: [sympy] Running collect() on indices

2010-10-08 Thread Øyvind Jensen
to., 07.10.2010 kl. 17.46 -0600, skrev Nicholas Kinar: > Hello, > > Working again with the FDTD re-arrangement of terms, I am wondering if > there is any way to run collect() on indices of an IndexedBase object > using the current master sympy git repository. Rather than having (n+1) > express

Re: [sympy] Running collect() on indices

2010-10-08 Thread Nicholas Kinar
Hello, Working again with the FDTD re-arrangement of terms, I am wondering if there is any way to run collect() on indices of an IndexedBase object using the current master sympy git repository. Rather than having (n+1) expressed as a power, is it possible to run collect() in the manner shown

Re: [sympy] Running collect() on indices

2010-10-08 Thread Nicholas Kinar
#begin modified sample code from sympy import * from sympy.tensor import Indexed, Idx, IndexedBase from sympy.matrices import * p = IndexedBase('p') var('deltax deltay delta deltat A B') i,j,n = symbols('i j n', integer = True) def generate_fdtd(expr, nsolve): w = Wild('w') expr0 = ex

[sympy] Using as_independent() with filter and lambda

2010-10-08 Thread Nicholas Kinar
Hello, Looking back at a previous thread (http://groups.google.com/group/sympy/browse_thread/thread/a406176eeb28eb04), an interesting procedure was discussed to place p[i,j,n+1] terms on the LHS of the expression. (Thanks again, Aaron!) As shown in another sample code below, the procedure u

Re: [sympy] Using as_independent() with filter and lambda

2010-10-08 Thread Aaron S. Meurer
Your problem comes from using atoms(IndexedBase). Here is what that gives: In [24]: expr.atoms(IndexedBase) Out[24]: set(p) But this doesn't have the i, j, n args that you want. I think what you really want to do is use atoms(Indexed) (Øyvind, correct me if I am wrong here). That gives: In

Re: [sympy] Using as_independent() with filter and lambda

2010-10-08 Thread Nicholas Kinar
Your problem comes from using atoms(IndexedBase). Here is what that gives: In [24]: expr.atoms(IndexedBase) Out[24]: set(p) But this doesn't have the i, j, n args that you want. I think what you really want to do is use atoms(Indexed) (Øyvind, correct me if I am wrong here). That gives:

Re: [sympy] Using as_independent() with filter and lambda

2010-10-08 Thread Nicholas Kinar
Yes, this is exactly what I wanted, Aaron; many thanks for pointing me in the right direction. As shown in the final example code below, I've done as you've suggested and used atoms(Indexed). I've also taken a poet's license with the code and called expand() to be able to distribute through

Re: [sympy] Using as_independent() with filter and lambda

2010-10-08 Thread Aaron S. Meurer
> Here's a short comment: using Idx(n+1) seems to work a little better for me, > since I've noticed that if I use Idx(n) with a very complicated expression, > there is a possibility of terms with (n+1) indices ending up on the same side > as the (n) indices. That sounds like a bug. Can you giv

Re: [sympy] Using as_independent() with filter and lambda

2010-10-08 Thread Nicholas Kinar
Here's a short comment: using Idx(n+1) seems to work a little better for me, since I've noticed that if I use Idx(n) with a very complicated expression, there is a possibility of terms with (n+1) indices ending up on the same side as the (n) indices. That sounds like a bug. Can you gi

Re: [sympy] Using as_independent() with filter and lambda

2010-10-08 Thread Nicholas Kinar
Here's a short comment: using Idx(n+1) seems to work a little better for me, since I've noticed that if I use Idx(n) with a very complicated expression, there is a possibility of terms with (n+1) indices ending up on the same side as the (n) indices. That sounds like a bug. Can you give a spe

Re: [sympy] Using as_independent() with filter and lambda

2010-10-08 Thread Aaron S. Meurer
I think what you are getting is expected behavior. Remember that when you switch n and n + 1, you are switching the side of the equation that they will end up on. So in the first one, you have all terms with n on the right-hand side, and in the second one, you have all the terms with n + 1 on

Re: [sympy] Using as_independent() with filter and lambda

2010-10-08 Thread Nicholas Kinar
I think what you are getting is expected behavior. Remember that when you switch n and n + 1, you are switching the side of the equation that they will end up on. So in the first one, you have all terms with n on the right-hand side, and in the second one, you have all the terms with n + 1