On Wednesday, December 2, 2015 at 5:22:24 AM UTC+2, Andrey Grozin wrote:
>
> вторник, 1 декабря 2015 г., 12:58:34 UTC+6 пользователь Andrey Grozin
> написал:
>>
>> I need the action inverse to expand_trig (I think it is needed more often
>> than expand_trig; suppose I want to multiply two truncated Fourier series,
>> I do expand, what next?).
>>
> No easy way to do this? In Mathematica I could use substitutions like
> Cos[x_]*Cos[y_]->(Cos[x+y]+Cos[x-y])/2
> (similarly in Reduce, Maxima,...). But in sympy .replace(...) will not
> find cos(x)*cos(y) in a larger product:
>
> >>> a=Wild('a')
> >>> b=Wild('b')
> >>> (z*cos(x)*cos(y)).replace(cos(a)*cos(b),(cos(a+b)+cos(a-b))/2)
> z*cos(x)*cos(y)
>
> So, how to do this?
>
In sympy.simplify.fu there are some tools that might be useful. For example,
```
>>> from sympy.simplify.fu import *
>>> TR8(z*cos(x)*cos(y))
z*(cos(x - y) + cos(x + y))/2
```
--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/6719e1d1-4c9a-449d-b7bd-81081c2f9306%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.