> I only have experience with matching expressions, particularly in the
> ode module with classify_ode. If you want to match some complicated
> expressions, you will run into some limitations soon. One issue is
> that you can't match "n" terms, so for example, I had to write a
> custom matcher for a linear ODE with constant coefficients (an*y^(n) +
> ... + a1*y' + a0*y = g).
>
I'm just trying to do fairly simple non-expr expressions. Here is an
example.
In [1]: p = Wild('p')
In [2]: s = Union(FiniteSet(1,2,3), Interval(5, 7))
In [3]: s.match(Union(p, Interval(5, 7)))
TypeError: Input must be Sets or iterables of Sets
Do we have a non-Expr wild?
Another issue is that the pattern matcher will give non-deterministic
> results unless you specify the exclude keyword on the Wild objects
> very carefully.
>
Right, I'd actually like to explore this. I want all of the possible
matches. This is one trivial way to defeat non-determinism :) Is there a
way to explore the non-determinism here?
> A third issue is that automatic simplification (and in many cases,
> even non-automatic simplification, i.e., expressions being written in
> different equivalent forms) can move an expression into a form that
> the pattern matcher won't recognize. For example:
>
In my particular case automatic simplification shouldn't be an issue but
yes, I can see how this could be annoying. Presumably this would work if
you built the expr and pattern with evaluate=False?
The good news is that there are a lot of good algorithms that you can
> use to write custom targeted matching solutions. For example, with
> the above, you could use some of the gcd algorithms (I'm not sure
> which exactly; terms_gcd I think) to pull out the coefficient, if
> that's what you want.
>
Are there good general pattern matching/unification algorihtms? Something
like risch or meijerint but for this domain?
> I thought we tried to document this a while back when we were fixing
> some bugs. Are the inline comments and docstrings not enough?
>
I was not sufficiently clever for this.
--
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.