Difference between revisions of "CoCoA:HowTo:Round Coefficients"

From ApCoCoAWiki
m (Rounding Coefficients moved to HowTo:Round Coefficients: tidying up the wiki...)
m
Line 28: Line 28:
 
ToDo
 
ToDo
  
[[Category:CoCoA4]] [[Category:HowTo]]
+
[[Category:CoCoA4]] [[Category:HowTo|{{PAGENAME}}]]

Revision as of 18:28, 22 October 2007

About

CoCoA:CoCoA 4 computes polynomials either Q or in Z/(p). In case you have polynomials in Q and you do some computations with them, after some time their coefficients probably look quite ugly (ToDo: Add Example). To get a feeling for the coefficients, it may be quite handy to get a rounded value instead of these loooong fractions. Their is no code inside CoCoA to do this automatically, but you can do it quite easy, using CoCoA's FloatApprox or FloatStr functions.

first version, converting to string

 P := x^2 + 11/10 y + 1/3 z;
 
 S := Sum(Flatten([ ['( ',FloatStr(LC(M)),'*',Sprint(LT(M)),') +'] | M In Monomials(P)]));
 
 S;

code by dheldt, 23 Jun 2005 (CEST)

second version, only rounding coefficients

 P := x^2 + 11/10 y + 1/3 z;
 
 S := Sum([ FloatApprox(LC(M),1/10^3)LT(M) | M In Monomials(P)]);
 
 S;

code by dheldt, 23 Jun 2005 (CEST)

Examples

ToDo