Difference between revisions of "CoCoA:HowTo:Round Coefficients"
From ApCoCoAWiki
m |
m (fixing a link.) |
||
Line 1: | Line 1: | ||
== About == | == About == | ||
− | [[CoCoA 4]] computes polynomials either Q or in Z/(p). In case you have polynomials in Q and you do some computations with them, | + | [[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, | 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. | 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. |
Revision as of 16:19, 14 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