def cg_simp(e):
 if isinstance(e, Add):
  return _cg_simp_add(e)
 elif isinstance(e, Sum):
  return _cg_simp_sum(e)
 elif isinstance(e, Mul):
  return Mul(*[cg_simp(arg) for arg in e.args])
 elif isinstance(e, Pow):
  return Pow(cg_simp(e.base), e.exp)
 else:
  return e

def cg_simp ( e ) : if isinstance ( e , Add ) : return _cg_simp_add ( e ) elif isinstance ( e , Sum ) : return _cg_simp_sum ( e ) elif isinstance ( e , Mul ) : return Mul ( * [ cg_simp ( arg ) for arg in e . args ] ) elif isinstance ( e , Pow ) : return Pow ( cg_simp ( e . base ) , e . exp ) else : return e
simplify and combine cg coefficients this function uses various symmetry and properties of sums and products of clebsch-gordan coefficients to simplify statements involving these terms [1]_ .