def _guess_expansion(f, x):
 from sympy import expand_trig
 from sympy.functions.elementary.trigonometric import TrigonometricFunction
 res = [(f, 'original integrand')]
 orig = res[(-1)][0]
 saw = {orig}
 expanded = expand_mul(orig)
 if (expanded not in saw):
  res += [(expanded, 'expand_mul')]
  saw.add(expanded)
 expanded = expand(orig)
 if (expanded not in saw):
  res += [(expanded, 'expand')]
  saw.add(expanded)
 if orig.has(TrigonometricFunction, HyperbolicFunction):
  expanded = expand_mul(expand_trig(orig))
  if (expanded not in saw):
   res += [(expanded, 'expand_trig, expand_mul')]
   saw.add(expanded)
 return res

def _guess_expansion ( f , x ) : from sympy import expand_trig from sympy . functions . elementary . trigonometric import TrigonometricFunction res = [ ( f , 'original integrand' ) ] orig = res [ ( - 1 ) ] [ 0 ] saw = { orig } expanded = expand_mul ( orig ) if ( expanded not in saw ) : res += [ ( expanded , 'expand_mul' ) ] saw . add ( expanded ) expanded = expand ( orig ) if ( expanded not in saw ) : res += [ ( expanded , 'expand' ) ] saw . add ( expanded ) if orig . has ( TrigonometricFunction , HyperbolicFunction ) : expanded = expand_mul ( expand_trig ( orig ) ) if ( expanded not in saw ) : res += [ ( expanded , 'expand_trig, expand_mul' ) ] saw . add ( expanded ) return res
try to guess sensible rewritings for integrand f(x) .