def dup_add(f, g, K):
 if (not f):
  return g
 if (not g):
  return f
 df = dup_degree(f)
 dg = dup_degree(g)
 if (df == dg):
  return dup_strip([(a + b) for (a, b) in zip(f, g)])
 else:
  k = abs((df - dg))
  if (df > dg):
   (h, f) = (f[:k], f[k:])
  else:
   (h, g) = (g[:k], g[k:])
  return (h + [(a + b) for (a, b) in zip(f, g)])

def dup_add ( f , g , K ) : if ( not f ) : return g if ( not g ) : return f df = dup_degree ( f ) dg = dup_degree ( g ) if ( df == dg ) : return dup_strip ( [ ( a + b ) for ( a , b ) in zip ( f , g ) ] ) else : k = abs ( ( df - dg ) ) if ( df > dg ) : ( h , f ) = ( f [ : k ] , f [ k : ] ) else : ( h , g ) = ( g [ : k ] , g [ k : ] ) return ( h + [ ( a + b ) for ( a , b ) in zip ( f , g ) ] )
add dense polynomials in k[x] .