On 18 February 2016 at 09:43, Paul Royik <distantjob...@gmail.com> wrote: > I'm trying to simplify a*cos(b)**2+a*sin(b)**2 to a > > So, I write > > a = sympy.Wild('a') > b = sympy.Wild('b') > expr = 49*cos(x)**2+49*sin(x)**2 + 5 > expr.replace(a*sympy.sin(b)**2+a*sympy.cos(b)**2, a, exact=True) > > > But this doesn't work. expr is unchanged.
How about: >>> x = Symbol('x') >>> trigsimp(49*cos(x)**2 + 49*sin(x)**2 + 5) 54 Or is your question about the fact that expr.replace does not modify expr but rather returns a different expression? Maybe you wanted something like: expr = expr.replace(...) -- Oscar -- 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 sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAHVvXxSuE%2B3WkgOzSiALSwVcHEi%2B1tYvnypmZrq-DWdf2BsDkw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.