I cannot reproduce this. match returns None for me in that case. If
it returns b:3, then it is wrong. According to the match docstring,
if you substitute each element in the dictionary into the match
expression, you should get the original expression back.
Either way, you should start an issue for it, at least as a feature
request. For now, you should just use b*x and do 1/b if you want
that. All division is just treated as Pow in a Mul with negative
exponent in SymPy. Do (x/y).args to see what I mean. Also, make sure
to check if b is 0, because (sympify(0)).match(b*x) returns {b:0}.
Aaron Meurer
On Jun 4, 2009, at 10:21 PM, smichr wrote:
>
> The following behavior should probably be documented as a feature of
> pattern matching or raised as an issue:
>
> ###
>>>> x=Symbol('x',dummy=True);b=Wild('b',exclude=[x]);(3*x).match(x/b)
> {b_: 3}
> ###
>
> I would have expected the result to be {b_:1/3}. So it appears that
> match() is only meant to work with multiplicative constants. Additive
> and subtractive constants are respected, however:
>
> ###
>>>> (x-3).match(x+b)
> {b_: -3}
>>>> (x-3).match(x-b)
> {b_: 3}
> ###
>
> /chris
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---