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)

I guess what isn't supported so well is making x itself be a Wild
representing a Symbol.

What I would do is extend Wild to accept a callable, which can be used
to determine if an expression should match it. So for instance, you
could match only Symbols with Wild('x', param=lambda i: isinstance(i,
Symbol)) (what should "param" be called?). The exclude parameter would
be a special case of this with lambda i: not i.has(exclude). We could
also add a special case for isinstance to avoid having to type lambda
in the common case.

One could then do

x = Wild('x', isinstance=[Symbol])
a = Wild('a', exclude=[x])
b = Wild('b', exclude=[x])
expr.replace(Integral(cos(a + b*x), x), sin(a + b*x)/b)

and it would do the right thing, for instance, for expr =
Integral(cos(1 + 2*t), t).

The question is how hard it is to make this work with the pattern
matching algorithm that is currently implemented.

Aaron Meurer

On Thu, Sep 19, 2013 at 10:40 AM, F. B. <[email protected]> wrote:
> Mathematica has the ability to do pattern matching such as:
>
> Int[cos[a_.+b_.*x_], x_Symbol] := Sin[a+b*x] / b /; FreeQ[{a, b}, x]
>
> Here a and b are matched if they do not contain x.
>
> As far as I know, SymPy is unable to perform such a match. Are there any
> ideas to extend the pattern matching algorithm?
>
> --
> 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