Hello Aaron, thanks for the info, in the meantime I found another way of dealing with this expression. Not completely satisfied yet, but I am still sifting through the sympy docs. Will try your other suggestions as well.
Cheers, Francesco. On 4 October 2013 04:23, Aaron Meurer <[email protected]> wrote: > I think as_independent() will help you extract the constant part. > There are probably smarter functions that can try harder, but I'm not > sure which ones they are right now. Maybe separatevars(dict=True). > > As for using Wild, make sure to include exclude=[x] in your Wilds. > Otherwise, you can get very strange matches that are technically > correct but not very helpful (see > https://github.com/sympy/sympy/wiki/Idioms-and-Antipatterns#wild-and-match > ). > > Also, if you know you have a polynomial, you can just use collect() and > coeff(). > > Aaron Meurer > > On Wed, Oct 2, 2013 at 3:39 AM, Francesco Biscani <[email protected]> > wrote: > > Hello, > > > > as a complete sympy newbie I am having some problems solving the > following > > problem. > > > > I have an expression of the general form: > > > > E0/(E1*E2*...*En * (ax+bx+c+d...)) > > > > where E0...En are some "constant expressions" and x is my variable of > > interest. What I need to do is to transform this expression into > something > > like: > > > > E0/(E1*E2*...*En) * 1/((a+b)*x+c+d+...) > > > > IOW, I need to separate the nucleus > > > > 1/((a+b)*x+c+d+...) > > > > from the rest of the expression. As a next step I would then need to > isolate > > and extract the coefficient of x (i.e., (a+b)) and the constant part of > the > > expression on the denominator (i.e., c+d+....) > > > > (For a bit of a context, the 'x' variable in my case is Weierstrass' > > elliptic function \wp. What I am trying to do is to integrate forms of > the > > type 1/(\wp + C) by matching, isolating and substituting subexpressions. > > What I am trying to do here is to extract the uninteresting parts of the > > expression - the constant expresssions - and isolate the fundamental > > integrable form 1/(\wp + C)) > > > > I have played a bit with replace() and Wild symbols, but I have not gone > > very far - I can't really understand what's going on, but I think I am > > making some fundamental mistake building the pattern matching > expressions. > > > > Can anyone point me in the general direction? How one would start solving > > such a problem? > > > > Thanks, > > > > Francesco. > > > > -- > > You received this message because you are subscribed to the Google Groups > > "sympy" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to [email protected]. > > To post to this group, send email to [email protected]. > > Visit this group at http://groups.google.com/group/sympy. > > For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
