Post a reply
Username:
Note:If not registered, provide any username. For more comfort, register here.
Subject:
Message body:
Enter your message here, it may contain no more than 60000 characters. 

Smilies
:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:
Font size:
Font colour
Options:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Disable BBCode
Disable smilies
Do not automatically parse URLs
Confirmation of post
To prevent automated posts the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.
Confirmation code:
Enter the code exactly as it appears. All letters are case insensitive, there is no zero.
   

Topic review - coefficients of multivariable polyomials
Author Message
  Post subject:  Re: coefficients of multivariable polyomials  Reply with quote
thanks gorzel. As always, you come up with a very good reply. I now like this singular code better than the maple one.

Jose
Post Posted: Tue Apr 04, 2017 11:47 pm
  Post subject:  Re: coefficients of multivariable polyomials  Reply with quote
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+x

Caveat: 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;
-2x3y2

If 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.
Post Posted: Tue Apr 04, 2017 3:08 pm
  Post subject:  coefficients of multivariable polyomials  Reply with quote
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
Post Posted: Tue Apr 04, 2017 1:52 pm


It is currently Fri May 13, 2022 11:01 am
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group