Dear all, first, thanks to all the contributors for providing such a great and free tool.
For x-ray structure factor calculations, I end up with huge sums of trigonometric terms that I want to simplify knowing that the arguments of the trigonometric functions contain summands being multiples of Pi and Pi/2. In general, the step I am missing is to get from sin(Pi*h/2) for integer h to -(-1^(h-1))*mod(h,2) with integer h. The simplification should also simplify sin(Pi*h/2+x) to a sum of sin(x) and cos(x) depending on the phase Pi*h/2 with h integer. Then I would collect all the sin and cos terms... Is that doable with sympy? I would be very thankful for a hint how to proceed... Below is a working code that results in the following expression (h,k,l) integer that should be simplified (d real) into something f1(h,k,l)*sin(2pi(dh-dk))+f2(h,k,l)*sin(2pi(dh+dk))+... import sympy as sp from numpy import * import matplotlib.pyplot as plt sp.init_printing(use_latex=True) u=sp.symbols('u',positive=True) d=sp.symbols('d',positive=True) h=sp.symbols('h',integer=True) k=sp.symbols('k',integer=True) l=sp.symbols('l',integer=True) #h=sp.Integer(2) #k=sp.Integer(1) #l=sp.Integer(1) onehalf=sp.Integer(1)/sp.Integer(2) x=sp.symarray('x',8) y=sp.symarray('y',8) z=sp.symarray('z',8) # Wyckoff 8 h sites x[0:4]=([u,-u,-u+onehalf,u+onehalf]) y[0:4]=([u+onehalf,-u+onehalf,u,-u]) z[0:4]=([0,0,0,0]) [x[4:8],y[4:8],z[4:8]]=[x[0:4]+onehalf,y[0:4]+onehalf,z[0:4]+onehalf] s=sp.Integer(0) for j in range (0,8): s=s+sp.exp(-sp.Integer(2)*sp.I*sp.pi*(x[j]*h+y[j]*k+z[j]*l)) s=s.subs(u,sp.Integer(1)/sp.Integer(4)-d) s= (sp.expand_complex(s).simplify()) s Thank you for reading Best, Michael -- 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 email@example.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/d215e005-aa29-4e20-8bc1-852e508ef685%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.