Try to use unification, if this can help

http://matthewrocklin.com/blog/work/2012/11/01/Unification/

The problem with this module is that it appears not to be flexible on 
missing args in *Add*. If you add *A* you don't get any matches.

Here is a slightly modified example

>>> from sympy.unify import unify
>>> B, n, k = var('B n k')
>>> exp = S('3*x**2+2*x**3')
>>> patt = B + k*x**n
>>> u = unify(exp, patt, {}, variables=[B, n, k])
>>> list(u)
⎡⎧      3            ⎫  ⎧      2            ⎫⎤
⎢⎨B: 2⋅x , k: 3, n: 2⎬, ⎨B: 3⋅x , k: 2, n: 3⎬⎥
⎣⎩                   ⎭  ⎩                   ⎭⎦


Maybe Matthew Rocklin could help.

On Tuesday, February 11, 2014 10:40:27 PM UTC+1, Vincent MAILLE wrote:
>
> Hi, is it possible to find all possible matches : 
>
> exp = S('3*x**2+2*x**3')
> k, n, A,B  = Wild('k',exclude = [0]), Wild('n',exclude =  
> set([0,1])),Wild('A'), Wild('B')
> T = (A+k*x**n+B).matches(exp)
>
> returns 
>
> {k_: 2, n_: 3, A_: 0, B_: 3*x**2}
>
> But can I have : 
> [{k_: 2, n_: 3, A_: 0, B_: 3*x**2}, {k_: 3, n_: 2, A_: 2*x**3, B_: 0}]
>
> Thanks
>
> Vincent
>
>

-- 
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.

Reply via email to