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