def dup_sqr(f, K):
 (df, h) = ((len(f) - 1), [])
 for i in range(0, ((2 * df) + 1)):
  c = K.zero
  jmin = max(0, (i - df))
  jmax = min(i, df)
  n = ((jmax - jmin) + 1)
  jmax = ((jmin + (n // 2)) - 1)
  for j in range(jmin, (jmax + 1)):
   c += (f[j] * f[(i - j)])
  c += c
  if (n & 1):
   elem = f[(jmax + 1)]
   c += (elem ** 2)
  h.append(c)
 return dup_strip(h)

def dup_sqr ( f , K ) : ( df , h ) = ( ( len ( f ) - 1 ) , [ ] ) for i in range ( 0 , ( ( 2 * df ) + 1 ) ) : c = K . zero jmin = max ( 0 , ( i - df ) ) jmax = min ( i , df ) n = ( ( jmax - jmin ) + 1 ) jmax = ( ( jmin + ( n // 2 ) ) - 1 ) for j in range ( jmin , ( jmax + 1 ) ) : c += ( f [ j ] * f [ ( i - j ) ] ) c += c if ( n & 1 ) : elem = f [ ( jmax + 1 ) ] c += ( elem ** 2 ) h . append ( c ) return dup_strip ( h )
square dense polynomials in k[x] .