another polynomial operation query



Many thanks to Richard Fateman for his suggestion. It certainly works.

Example: extracting the homogeneous polynomial of degree 7 in two variables (x_1,x_2) from the product of two polynomials p(x_1), q(x_2) each of degree 10.

(%i1) batching #pC:/Maxima/Work/poly.mc
(%i2) display2d : false
(%i3) array([a,b],10)
(%i4) array(x,2)
(%i5) p:sum(a[i]*x[1]^i,i,0,10)
(%i6) q:sum(b[i]*x[2]^i,i,0,10)
(%i7) r:expand(p*q)
(%i8) ratweight(x[1],1)
(%i9) ratweight(x[2],1)
(%i10) ratwtlvl:7
(%i11) terms_7:rat(r)
(%i12) ratwtlvl:6
(%i13) terms_6:rat(r)
(%i14) ratwtlvl:7
(%i15) ratexpand(terms_7-terms_6)
(%o15) a[0]*x[2]^7*b[7]+b[0]*x[1]^7*a[7]+a[1]*x[1]*x[2]^6*b[6]
         +b[1]*x[1]^6*x[2]*a[6]+x[1]^2*a[2]*x[2]^5*b[5]
         +x[1]^5*b[2]*x[2]^2*a[5]+x[1]^3*x[2]^4*a[3]*b[4]
         +x[1]^4*x[2]^3*b[3]*a[4]


R J-M Grognard
  ----- Original Message ----- 
  From: Richard Fateman 
  To: 'Renatus' ; maxima at math.utexas.edu 
  Sent: Wednesday, November 29, 2006 11:41 AM
  Subject: RE: [Maxima] another polynomial operation query


  Maybe to be more precise, you could compute the terms of degree less than or equal to k, and subtract those terms of degree less than or equal to k-1, giving terms of degree exactly k.

   

  Something like this..

   

  ratweight(x[1],1)$ ratweight(x[2],1)$    etc. do in a loop.

  ratwtlvl:k$

  terms_k:  rat( expression)$

  ratwtlvl:k-1$

  terms_km1: rat(expression)$

  ratwtlvl:k$

  ratexpand (terms_k - terms_km1);

   

  RJF