Page 1 sur 1

numerical coefficient of a term

Publié : jeu. juil. 19, 2018 6:11 pm
par compsystems
Hello, how can I get the numerical coefficient of a term?

5*x*y

coeff(5*x*y, y,1); returns 5*x // ok 5·x is the coefficient of y¹

coeff(5*x*y, x,1); returns 5*y // ok 5·y is the coefficient of x¹

coeff(5*x*y, 'x*y' ) ; returns 5*x*y =( // 5 is the coefficient of x¹·y¹

Re: numerical coefficient of a term

Publié : ven. juil. 20, 2018 3:57 pm
par belanger
coeff(poly,[x,y],[1,1]) will return the x^1*y^1 coefficient:

>> coeff(5*x*y,[x,y],[1,1])

5

Re: numerical coefficient of a term

Publié : sam. juil. 21, 2018 3:55 pm
par compsystems
coeff(5*x^3*y,[x,y],[1,1]) returns 0 =(

I think Bernard, could improve this function, if specified in the third argument, a string with the variables to get the coefficient

coeff(5*x*y, "x*y" ) => 5
coeff(5*x^3*y, "x*y" ) => 5

Re: numerical coefficient of a term

Publié : sam. juil. 21, 2018 6:17 pm
par parisse
coeff(5*x^3*y,[x,y],[1,1]) *is* 0.
Why would you want a string as second argument ?