On Mar 21, 5:01 pm, Ondrej Certik <ond...@certik.cz> wrote: > On Sat, Mar 21, 2009 at 5:58 AM, Vinzent Steinberg > > <vinzent.steinb...@googlemail.com> wrote: > > > What is the best way to replace tan(x) with sin(x)/cos(x)? > > > *.match() does not seem to be suited, because I don't care where tan > > (x) occurs, I just want to replace it. > > WildFunction() seems to be broken. > > That's a good question. You need to know the argument of tan(x). If > it's just x, then: > I would use: > > e.subs(tan(x), sin(x)/cos(x))
This is not general enough. Please note that you already can do e.subs(tan, sin) It would be great to improve this to use a = Wild('a') e.subs(tan(a), sin(a)/cos(a)) for replacing. > > I think we should maybe enhance our .match() or introduce .find() so > that one can do e.find(tan(Wild("a"))) and it would return tan(x**2) > or whatever is in the expression. Then you can use .subs() to > substitute it. > > Ondrej e.find() would be really useful, often you just want to find a term and don't care whether it's nested in some other expressions. It should be relatively easy to implement. Vinzent --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@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 -~----------~----~----~----~------~----~------~--~---