numerical coefficient of a term

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 561
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

numerical coefficient of a term

Message par compsystems » jeu. juil. 19, 2018 6:11 pm

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¹

belanger
Messages : 59
Inscription : jeu. juil. 27, 2017 3:26 pm

Re: numerical coefficient of a term

Message par belanger » ven. juil. 20, 2018 3:57 pm

coeff(poly,[x,y],[1,1]) will return the x^1*y^1 coefficient:

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

5

compsystems
Messages : 561
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: numerical coefficient of a term

Message par compsystems » sam. juil. 21, 2018 3:55 pm

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

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: numerical coefficient of a term

Message par parisse » sam. juil. 21, 2018 6:17 pm

coeff(5*x^3*y,[x,y],[1,1]) *is* 0.
Why would you want a string as second argument ?

Répondre