# CoCoA:HowTo:Round Coefficients

From ApCoCoAWiki

## 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, 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 09:23, 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 09:23, 23 Jun 2005 (CEST)

## Examples

ToDo