Singularhttp://www.singular.uni-kl.de/forum/ coefficients of multivariable polyomialshttp://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2594 Page 1 of 1

 Author: jcapco [ Tue Apr 04, 2017 1:52 pm ] Post subject: coefficients of multivariable polyomials In maple I can create the following procedure:Code:positivify := proc(f,vars)  description "takes a multivariable polynomial and changes its coefficient to positive"  local c:  c:=coeffs(f,vars,'t'):  convert([seq(abs(c[i])*t[i],i=1..nops([t]))],`+`);end proc:What this does is take a multivariable polynomial over the real numbers, say e.g. 4x^2-x+2xy-3z^4,and creates a new polynomial with the same number of monomials and individual degree of variables but with coefficients that are the absolute value of the coefficient of the old monomials, so for the example it creates 4x^2+x+2xy+3z^4.I would like to do the same in singular. Here, I believe, coeffs in singular works for univariate case (so I need to inquire the coeff of x but then I get values in R[y,z]). Any hints of how I can most efficiently program this in singular? I suppose there is naive way to just walk through all the coefficients of each indeterminate and check for the coefficient, but I fear I will end up writing a very long procedure that way.Thanks for any advise!Jose

 Author: gorzel [ Tue Apr 04, 2017 3:08 pm ] Post subject: Re: coefficients of multivariable polyomials Code:> LIB "general.lib";  // to have the proc absValue at your disposal> proc positify(poly f) {  poly h;  for (int i=0;i<=size(f);i++) {  h = h + absValue(leadcoef(f[i]))*leadmonom(f[i]); } return(h);}> ring r3 = 0,(x,y,z),dp;> poly F = 4*x^2-x+2xy-3*z^4;3z4+4x2+2xy+x> short =0;_;> 3*z^4+4*x^2+2*x*y+xCaveat: When you use the exponentiation sing ^ in the input, then you should also put the * between the variables and the coefficients.Otherwise everything to the left of an ^ (upto an +,-) is treated as a single token.Code:> -2x3y^2;-4x6y2> -2*x^3*y^2;-2x3y2If the variable names consists of single letters only, then -- for the users convenience -- the ^and * can be ommitted. The setting of the variable short only affcts the output format.See 6.4 Miscellaneous oddities 2. monomials and precedence http://www.singular.uni-kl.de/Manual/latest/sing_410.htm#SEC450 and http://www.singular.uni-kl.de/Manual/latest/sing_393.htm#SEC433 for short.

 Author: jcapco [ Tue Apr 04, 2017 11:47 pm ] Post subject: Re: coefficients of multivariable polyomials thanks gorzel. As always, you come up with a very good reply. I now like this singular code better than the maple one.Jose

 Page 1 of 1 All times are UTC + 1 hour [ DST ] Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/