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)
Oh well, I missed that.
> 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).
>
>
Well, there is a discussion here about a C++ Sympy core, so I think that we
should avoid commands such as *isinstance*, which are proper of Python, as
it would be hard to port them into C++. What about:
x = Wild('x', atom=True, name='x')
This is easier to port to the C++ core.
The question is how hard it is to make this work with the pattern
> matching algorithm that is currently implemented.
>
Good question, I have a bad feeling about that.
--
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.