Macaulay2 » Documentation
Packages » Macaulay2Doc > basic commutative algebra > M2SingularBook > Singular Book 1.1.8
next | previous | forward | backward | up | index | toc

Singular Book 1.1.8 -- computation in fields

Computation over ZZ and QQ

In Macaulay2, Integers are arbitrary precision. The ring of integers is denoted ZZ.
i1 : 123456789^5

o1 = 28679718602997181072337614380936720482949
i2 : matrix{{123456789^5}}

o2 = | 28679718602997181072337614380936720482949 |

              1       1
o2 : Matrix ZZ  <-- ZZ
i3 : gcd(3782621293644611237896400,85946734897630958700)

o3 = 100
The ring of rational numbers is denoted by QQ.
i4 : n = 12345/6789

     4115
o4 = ----
     2263

o4 : QQ
i5 : n^5

     1179910858126071875
o5 = -------------------
      59350279669807543

o5 : QQ
i6 : toString(n^5)

o6 = 1179910858126071875/59350279669807543

Computation in finite fields

i7 : A = ZZ/32003;
In order to do arithmetic in this ring, you must construct elements of this ring. n_A gives the image of the integer n in A.
i8 : 123456789 * 1_A

o8 = -10785

o8 : A
i9 : (123456789_A)^5

o9 = 8705

o9 : A
i10 : A2 = GF(8,Variable=>a)

o10 = A2

o10 : GaloisField
i11 : ambient A2

         ZZ
         --[a]
          2
o11 = ----------
       3
      a  + a + 1

o11 : QuotientRing
i12 : a^3+a+1

o12 = 0

o12 : A2
i13 : A3 = ZZ/2[a]/(a^20+a^3+1);
i14 : n = a+a^2

       2
o14 = a  + a

o14 : A3
i15 : n^5

       10    9    6    5
o15 = a   + a  + a  + a

o15 : A3

Computing with real and complex numbers

i16 : n = 123456789.0

o16 = 123456789

o16 : RR (of precision 53)
i17 : n = n * 1_RR

o17 = 123456789

o17 : RR (of precision 53)
i18 : n^5

o18 = 2.86797186029972e40

o18 : RR (of precision 53)

Computing with parameters

i19 : R3 = frac(ZZ[a,b,c])

o19 = R3

o19 : FractionField
i20 : n = 12345*a + 12345/(78*b*c)

      320970a*b*c + 4115
o20 = ------------------
             26b*c

o20 : R3
i21 : n^2

                   2 2 2
      103021740900a b c  + 2641583100a*b*c + 16933225
o21 = -----------------------------------------------
                              2 2
                          676b c

o21 : R3
i22 : n/(9*c)

      320970a*b*c + 4115
o22 = ------------------
                  2
            234b*c

o22 : R3