I need to perform some calculations within a ring R in which x**3 = x for
each x in R.
To make simplifications I would have like to do something like:

>>> p = Wild('p')
>>> q = Wild('q', properties=(lambda w: w.is_Integer and w > 2,))
>>> (2*x**4 + y**2 - x**2 + y**3).subs(p**q, p**(q - 2*floor((q - 1)/2)))
y + x**2 + y**2

Unfortunately, "subs" doesn't work with "wild" symbols.
So I write a new simple "Basic" method:

def _eval_wild_subs(self, old, new):
    old = sympify(old)
    new = sympify(new)
    m = self.match(old)
    if m:
        return new.subs(m)
    elif self.args:
        return self.func(*[arg._eval_wild_subs(old, new) for arg in
self.args])
    else:
        return self

That does what I need. Now, my questions are:
1) Is there a more "conventional" way, I missed, to achieve the above
result?
2) If not, are you interested in a commit of that kind?

Thanks...

Raffaele

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to