def fourier_series(f, limits=None):
 f = sympify(f)
 limits = _process_limits(f, limits)
 x = limits[0]
 if (x not in f.free_symbols):
  return f
 n = Dummy('n')
 neg_f = f.subs(x, (- x))
 if (f == neg_f):
  (a0, an) = fourier_cos_seq(f, limits, n)
  bn = SeqFormula(0, (1, oo))
 elif (f == (- neg_f)):
  a0 = S.Zero
  an = SeqFormula(0, (1, oo))
  bn = fourier_sin_seq(f, limits, n)
 else:
  (a0, an) = fourier_cos_seq(f, limits, n)
  bn = fourier_sin_seq(f, limits, n)
 return FourierSeries(f, limits, (a0, an, bn))

def fourier_series ( f , limits = None ) : f = sympify ( f ) limits = _process_limits ( f , limits ) x = limits [ 0 ] if ( x not in f . free_symbols ) : return f n = Dummy ( 'n' ) neg_f = f . subs ( x , ( - x ) ) if ( f == neg_f ) : ( a0 , an ) = fourier_cos_seq ( f , limits , n ) bn = SeqFormula ( 0 , ( 1 , oo ) ) elif ( f == ( - neg_f ) ) : a0 = S . Zero an = SeqFormula ( 0 , ( 1 , oo ) ) bn = fourier_sin_seq ( f , limits , n ) else : ( a0 , an ) = fourier_cos_seq ( f , limits , n ) bn = fourier_sin_seq ( f , limits , n ) return FourierSeries ( f , limits , ( a0 , an , bn ) )
computes fourier sine/cosine series expansion .