def _nth_linear_match(eq, func, order):
 x = func.args[0]
 one_x = {x}
 terms = {i: S.Zero for i in range((-1), (order + 1))}
 for i in Add.make_args(eq):
  if (not i.has(func)):
   terms[(-1)] += i
  else:
   (c, f) = i.as_independent(func)
   if (not ((isinstance(f, Derivative) and (set(f.variables) == one_x)) or (f == func))):
    return None
   else:
    terms[len(f.args[1:])] += c
 return terms

def _nth_linear_match ( eq , func , order ) : x = func . args [ 0 ] one_x = { x } terms = { i : S . Zero for i in range ( ( - 1 ) , ( order + 1 ) ) } for i in Add . make_args ( eq ) : if ( not i . has ( func ) ) : terms [ ( - 1 ) ] += i else : ( c , f ) = i . as_independent ( func ) if ( not ( ( isinstance ( f , Derivative ) and ( set ( f . variables ) == one_x ) ) or ( f == func ) ) ) : return None else : terms [ len ( f . args [ 1 : ] ) ] += c return terms
matches a differential equation to the linear form: .