[sympy] Re: expanding powers of cos()

2015-03-28 Thread mario
For example >>> expand((cos(x)**5).rewrite(exp)).rewrite(cos) 5*cos(x)/8 + 5*cos(3*x)/16 + cos(5*x)/16 On Saturday, March 28, 2015 at 8:59:13 AM UTC+1, Kalevi Suominen wrote: > > > > On Saturday, March 28, 2015 at 2:01:38 AM UTC+2, Jeremy Holleman wrote: >> >> I just mean that if I'm trying to wr

[sympy] Re: expanding powers of cos()

2015-03-28 Thread Kalevi Suominen
On Saturday, March 28, 2015 at 2:01:38 AM UTC+2, Jeremy Holleman wrote: > > I just mean that if I'm trying to write a script and I want to reduce all > of the powers of cos or sin, I'm not sure how I would code that, because I > can't tell if there's a pattern of which calls need to be made in

Re: [sympy] Re: expanding powers of cos()

2015-03-28 Thread Paul Royik
It seems like TR7 reduces only cos(x)**2 On Saturday, March 28, 2015 at 3:16:53 AM UTC+2, Jeremy Holleman wrote: > > I'll do that. Thanks to both of you for the help! > > On Friday, March 27, 2015 at 8:30:03 PM UTC-4, Aaron Meurer wrote: >> >> I would take a look at the fu paper for more refere

Re: [sympy] Re: expanding powers of cos()

2015-03-27 Thread Jeremy Holleman
I'll do that. Thanks to both of you for the help! On Friday, March 27, 2015 at 8:30:03 PM UTC-4, Aaron Meurer wrote: > > I would take a look at the fu paper for more references on what these > rules are supposed to be, but I suspect that this is a bug. > > Aaron Meurer > > On Fri, Mar 27, 20

Re: [sympy] Re: expanding powers of cos()

2015-03-27 Thread Aaron Meurer
I would take a look at the fu paper for more references on what these rules are supposed to be, but I suspect that this is a bug. Aaron Meurer On Fri, Mar 27, 2015 at 7:01 PM, Jeremy Holleman wrote: > I just mean that if I'm trying to write a script and I want to reduce all of > the powers of co

[sympy] Re: expanding powers of cos()

2015-03-27 Thread Jeremy Holleman
I just mean that if I'm trying to write a script and I want to reduce all of the powers of cos or sin, I'm not sure how I would code that, because I can't tell if there's a pattern of which calls need to be made in which order to reduce an arbitrary polynomial of trig functions. For my present

[sympy] Re: expanding powers of cos()

2015-03-27 Thread Paul Royik
What do you mean "how I would do that in a programmatic way"? On Friday, March 27, 2015 at 11:33:27 PM UTC+2, Jeremy Holleman wrote: > > Update - Some combination of TR7, TR8, and expand() seems to work for > powers that I've tried. For example: > > In [5]: TR8(expand(TR8(cos(x)**7))) >> Out[5]

[sympy] Re: expanding powers of cos()

2015-03-27 Thread Jeremy Holleman
Update - Some combination of TR7, TR8, and expand() seems to work for powers that I've tried. For example: In [5]: TR8(expand(TR8(cos(x)**7))) > Out[5]: 35*cos(x)/64 + 21*cos(3*x)/64 + 7*cos(5*x)/64 + cos(7*x)/64 But it's not clear to me how I would do that in a programmatic way. Jeremy O

[sympy] Re: expanding powers of cos()

2015-03-27 Thread Jeremy Holleman
Thanks! That did exactly what I want for cos**2. I would also like to reduce the power on higher order terms. I tried TR7() on cos(x)**3 and cos(x)**4 and it did not make any changes. From quick glance here (https://github.com/sympy/sympy/blob/master/sympy/simplify/fu.py), TR7 seems like th

[sympy] Re: expanding powers of cos()

2015-03-27 Thread Paul Royik
Hello, Jeremy. Try this: from sympy.simplify.fu import TR7 TR7(cos(x)**2) On Friday, March 27, 2015 at 8:36:43 PM UTC+2, Jeremy Holleman wrote: > > Hi, > > I'm relatively new to SymPy, and enjoying it so far. I'm trying to > analyze the harmonics that result when a sinusoid goes through a no