def ode_sol_simplicity(sol, func, trysolving=True):
 if iterable(sol):
  for i in sol:
   if (ode_sol_simplicity(i, func, trysolving=trysolving) == oo):
    return oo
  return len(str(sol))
 if sol.has(Integral):
  return oo
 if (((sol.lhs == func) and (not sol.rhs.has(func))) or ((sol.rhs == func) and (not sol.lhs.has(func)))):
  return (-2)
 if trysolving:
  try:
   sols = solve(sol, func)
   if (not sols):
    raise NotImplementedError
  except NotImplementedError:
   pass
  else:
   return (-1)
 return len(str(sol))

def ode_sol_simplicity ( sol , func , trysolving = True ) : if iterable ( sol ) : for i in sol : if ( ode_sol_simplicity ( i , func , trysolving = trysolving ) == oo ) : return oo return len ( str ( sol ) ) if sol . has ( Integral ) : return oo if ( ( ( sol . lhs == func ) and ( not sol . rhs . has ( func ) ) ) or ( ( sol . rhs == func ) and ( not sol . lhs . has ( func ) ) ) ) : return ( - 2 ) if trysolving : try : sols = solve ( sol , func ) if ( not sols ) : raise NotImplementedError except NotImplementedError : pass else : return ( - 1 ) return len ( str ( sol ) )
returns an extended integer representing how simple a solution to an ode is .