next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc :: clean

clean -- Set to zero elements that are approximately zero

Synopsis

Description

If the input is a matrix or a ring element, then the result has the same type, where each real or complex number coefficient that is less than epsilon in absolute value is replaced with zero.

i1 : e = 1e-11;
i2 : M = random(RR^4,RR^4)

o2 = | .515638 .832844 .587399 .764618 |
     | .667678 .969787 .669154 .521848 |
     | .03755  .842419 .771907 .420368 |
     | .770179 .85026  .389884 .117293 |

                4          4
o2 : Matrix RR    <--- RR
              53         53
i3 : M * (M + 1) + 1 - M^2 - M

o3 = | 1            -7.77156e-16 -3.33067e-16 0            |
     | -2.22045e-16 1            1.11022e-16  0            |
     | 0            -2.22045e-16 1            -1.11022e-16 |
     | -1.11022e-16 -2.22045e-16 0            1            |

                4          4
o3 : Matrix RR    <--- RR
              53         53
i4 : clean_e oo

o4 = | 1 0 0 0 |
     | 0 1 0 0 |
     | 0 0 1 0 |
     | 0 0 0 1 |

                4          4
o4 : Matrix RR    <--- RR
              53         53
Cleaning a polynomial is a way to get rid of small terms.
i5 : CC[x];
i6 : f = product(5,j -> x - exp(2*pi*j*ii/5))

      5                                  4                   3     
o6 = x  + (2.22045e-16 - 1.11022e-16*ii)x  - 1.11022e-16*ii*x  + (-
     ------------------------------------------------------------------------
                                   2
     1.11022e-16 - 1.11022e-16*ii)x  - 1.11022e-16*ii*x - 1 + 5.55112e-16*ii

o6 : CC  [x]
       53
i7 : clean_e f  

      5
o7 = x  - 1

o7 : CC  [x]
       53

See also

Ways to use clean :