Menu

Extracting the coefficients of a mixed polynomial

Help
videohead
2022-02-14
2022-02-14
  • videohead

    videohead - 2022-02-14

    How can I extract the six coefficients a ... f of a mixed polynomial ax^2 + by^2 + cxy + dx + ey + f? Unfortunately, the operator coeff doesn't quite work well for mixed polynomials.

    Please advise.

    Regards.

     

    Last edit: videohead 2022-02-14
    • Arthur Norman

      Arthur Norman - 2022-02-14

      On Mon, 14 Feb 2022, videohead wrote:

      How can I extract the six coefficients a ... f of an algebraic expression ax^2 + by^2 + cxy + dx + ey + f? Unfortunately, the operator coeff doesn't quite work well for mixed polynomials.

      Please advise.

      Regards.

      Is this the sort of thing you are looking for? You will still need a bit
      more to discard or separate the x and y bits (eg subst(x=1,...))
      Arthur

      Reduce (CSL, rev 6186), 27-Dec-2021 ...

      1: p := ax^2 + by^2 + cxy + dx + ey + f;

          2     2
      

      p := ax + by + cxy + dx + ey + f

      2: part(p, 1);

      2
      ax

      3: part(p, 2);

      2
      by

      4: part(p, 3);

      cxy

      5: part(p, 4);

      dx

      6: part(p, 6);

      f

       
  • Eberhard Schruefer

    Besides Arthur's suggestion, here are two other possibilities:

    1: p := a*x^2 + b*y^2 + c*x*y + d*x + e*y + f;
    
            2      2
    p := a*x  + b*y  + c*x*y + d*x + e*y + f
    
    2: for k := 0:2 do for l := 0:2 do write x^k,",",y^l,":    ", coeffn(coeffn(p,x,k),y,l);
    
    1,1:    f
    
    1,y:    e
    
       2
    1,y :    b
    
    x,1:    d
    
    x,y:    c
    
       2
    x,y :    0
    
     2
    x ,1:    a
    
     2
    x ,y:    0
    
     2  2
    x ,y :    0
    
    6: 
    

    There is also the contributed package coeff2 you could use:

    1: load coeff2;
    
    2: p := a*x^2 + b*y^2 + c*x*y + d*x + e*y + f;
    
            2      2
    p := a*x  + b*y  + c*x*y + d*x + e*y + f
    
    3: coeff2(p, x, y);
    
        2                       2
    #1*x  + #2*x*y + #3*x + #4*y  + #5*y + #6
    
    4: for k := 1:lisp symcount do write nm k;
    
    a
    
    c
    
    d
    
    b
    
    e
    
    f
    
    5:
    

    Eberhard

     

Log in to post a comment.