OK, I have a version that this works for now. Something I noticed is that there could be simplifications applied inside some of the cos and sin functions - because of the factor of I. How do you simplify inside a cos or sin? Alternatively, how do I get the expression with common factors of I in the exponentials?
all the best --cjc On 31 Mar, 16:30, "Aaron S. Meurer" <[email protected]> wrote: > Use expr.rewrite(cos), as in > > In [22]: print a.rewrite(cos) > 3**(1/2)*(I*sin(k_1/4) + cos(k_1/4))/45 + 3**(1/2)*(-I*sin(k_1/4) + > cos(k_1/4))/45 + 3**(1/2)*(-I*sin(I*(I*k_1/4 - I*k_2*3**(1/2)/4)) + > cos(I*(I*k_1/4 - I*k_2*3**(1/2)/4)))/45 + 3**(1/2)*(-I*sin(I*(-I*k_1/4 + > I*k_2*3**(1/2)/4)) + cos(I*(-I*k_1/4 + I*k_2*3**(1/2)/4)))/45 + > 3**(1/2)*(-I*sin(I*(I*k_1/8 + I*k_2*3**(1/2)/8)) + cos(I*(I*k_1/8 + > I*k_2*3**(1/2)/8)))/45 + 3**(1/2)*(I*sin(-I*(-I*k_1/8 - I*k_2*3**(1/2)/8)) + > cos(-I*(-I*k_1/8 - I*k_2*3**(1/2)/8)))/45 > > You could then use expand() to simplify things. > > Aaron Meurer > On Mar 31, 2010, at 9:18 AM, Colin wrote: > > > > > Dear list, > > I have expressions coming from my calculation of the type: > > > (1/45)*3**(1/2)*exp(-1/4*I*k_1 + (1/4)*I*k_2*3**(1/2)) + > > (1/45)*3**(1/2)*exp(-1/8*I*k_1 - 1/8*I*k_2*3**(1/2)) + > > (1/45)*3**(1/2)*exp((1/4)*I*k_1 - 1/4*I*k_2*3**(1/2)) + > > (1/45)*3**(1/2)*exp((1/8)*I*k_1 + (1/8)*I*k_2*3**(1/2)) + > > (1/45)*3**(1/2)*exp(-1/4*I*k_1) + (1/45)*3**(1/2)*exp((1/4)*I*k_1) > > > where k_1,k_2 are real numbers. What is the best way to automatically > > rewrite this as a weighted sum of cosines? > > > all the best > > --Colin > > > -- > > You received this message because you are subscribed to the Google Groups > > "sympy" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group > > athttp://groups.google.com/group/sympy?hl=en. -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
