On Sat, Sep 21, 2013 at 9:20 PM, Angus Griffith <[email protected]> wrote:
> On Friday, 20 September 2013 04:54:00 UTC+10, F. B. wrote:
>>
>>
>> On Thursday, September 19, 2013 8:08:09 PM UTC+2, Aaron Meurer wrote:
>>>
>>> I don't understand everything that the Mathematica syntax is doing
>>> there, but is this the same as
>>>
>>> a = Wild('a', exclude=[x])
>>> b = Wild('b', exclude=[x])
>>> expr.replace(Integral(cos(a + b*x), x), sin(a + b*x)/b)
>
>
> In this case I think it's roughly equivalent to the Mathematica pattern (a
> and b are optional and must be 'free of' x)
>
> I'm more familiar with Mathematica's pattern matching than SymPy's, but to
> summarize what I perceive as the the major differences:
>
> In Mathematica you can build up a pattern object and apply conditions to the
> pattern as a whole.
>
> Consider the example pattern 'a_. + b_ /; FreeQ[a + b x, x]'. That is, 'a'
> is optional, 'b' is required but we have the condition that a + b x can't be
> an expression in x. This would match '1/x', 'z + 1/x', 'Unevaluated[z + 0]',
> '-1 + x' etc. I'm not sure if such a thing is possible in SymPy.

I see. Yes, we should implement this. I think the only way to do this
in SymPy now is to do recursive matching, but that wouldn't work in
every case because there would be no backtracking.

>
> Mathematica has the concept of a repeated patterns. Could this be added to
> SymPy?. (E.g. Repeated
> http://reference.wolfram.com/mathematica/ref/Repeated.html)
>
> e.g. '{{_Real, _Real}..}' which matches a list of pairs of real numbers.
> Related to this is patterns for matching sequences (E.g.
> BlankSequence
> http://reference.wolfram.com/mathematica/ref/BlankSequence.html)

Some of this stuff might exist in the unify module.

>
> Mathematica has a variety of Test functions, designed for putting
> constraints on patterns. About half way down this guide:
> http://reference.wolfram.com/mathematica/tutorial/PuttingConstraintsOnPatterns.html

Ah. So I think we should aim to use the new assumptions system for
this, entirely if possible. That way, when the assumptions system
grows and gets smarter, so will the pattern matching.

>
> Mathematica pattern matching feels more mature and more natural than
> Sympy's. Part of this is the abundance of documentation on Mathematica's
> patterns. Patterns really feel like first class citizens in Mathematica and
> are used extensively internally (every MMA function has a pattern), while in
> SymPy they feel a little bolted on.

Yes, this is true. This is because the programming language itself is
built around it. SymPy's strengths come from the fact that things that
feel natural in Python feel natural in SymPy, whereas in other systems
they feel bolted on (unfortunately, this often refers to things as
simple as "writing a loop" or "defining a function").

Aaron Meurer

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

Reply via email to