+ M2 --no-readline --print-width 163
Macaulay2, version 1.8.2
with packages: ConwayPolynomials, Elimination, IntegralClosure, LLLBases, PrimaryDecomposition, ReesAlgebra, TangentCone

i1 : --sometimes we want to resart to clear variables
     restart
Macaulay2, version 1.8.2
with packages: ConwayPolynomials, Elimination, IntegralClosure, LLLBases, PrimaryDecomposition, ReesAlgebra, TangentCone

i1 : --Create a polynomial ring over the rationals
     R=QQ[x]

o1 = R

o1 : PolynomialRing

i2 : --We can also do several variables 
     R=QQ[x,y,z]

o2 = R

o2 : PolynomialRing

i3 : R=QQ[w_1..w_6]

o3 = R

o3 : PolynomialRing

i4 : --Use coefficents from a finite feild 
     R=ZZ/32749[x]

o4 = R

o4 : PolynomialRing

i5 : R=ZZ/32749[v_1..v_4]

o5 = R

o5 : PolynomialRing

i6 : isPrime 977

o6 = true

i7 : R=ZZ/977[x]

o7 = R

o7 : PolynomialRing

i8 : R=ZZ/32749[v_1..v_4]

o8 = R

o8 : PolynomialRing

i9 : I=ideal(v_1^2-6*v_2,v_3*v_1-45)

             2
o9 = ideal (v  - 6v , v v  - 45)
             1     2   1 3

o9 : Ideal of R

i10 : --and check if they are prime
      isPrime I

o10 = true

i11 : --back to one variable
      R=QQ[x]

o11 = R

o11 : PolynomialRing

i12 : I=ideal(x^2-23*x+47)

             2
o12 = ideal(x  - 23x + 47)

o12 : Ideal of R

i13 : isPrime I

o13 = true

i14 : --get the first (and only) generator of I
      f=I_0

       2
o14 = x  - 23x + 47

o14 : R

i15 : --we can try to factor it, and see it is irriducible (which we already knew since the ideal is prime)
      factor(f)

        2
o15 = (x  - 23x + 47)

o15 : Expression of class Product

i16 : --We can define a quotient ring
      S=R/I

o16 = S

o16 : QuotientRing

i17 : --we can do products of things in S
      h=(x^7+24)*(x^2-x-34)

o17 = 33454224741x - 75837638066

o17 : S

i18 : --since S is a feild we can also find inverses (note we need the two slashes)
      g=1//h

         33454224741        693609530977
o18 = ----------------x - ----------------
      6377358925067675    6377358925067675

o18 : S

i19 : g*h

o19 = 1

o19 : S

i20 : --we could also do the following, sing S is a feild
      (x^2-5)//(x+4)

      144    323
o20 = ---x - ---
      155    155

o20 : S

i21 : --One should be careful about reusing names too much in different rings... this can cuase errors, we will restart to avoid this
      restart
Macaulay2, version 1.8.2
with packages: ConwayPolynomials, Elimination, IntegralClosure, LLLBases, PrimaryDecomposition, ReesAlgebra, TangentCone

i1 : R=QQ[x]

o1 = R

o1 : PolynomialRing

i2 : f=x^2-23*x-2

      2
o2 = x  - 23x - 2

o2 : R

i3 : g=23*x^3-34

        3
o3 = 23x  - 34

o3 : R

i4 : gcd(f,g)

o4 = 1

o4 : R

i5 : --since these polynomials have gcd 1 then an ideal containing both must be the whole ring
     --we can check equality of rings and ideals and ideals and ideals with ==
     ideal(f,g)==R

o5 = true

i6 : h=f*(x+5)

      3      2
o6 = x  - 18x  - 117x - 10

o6 : R

i7 : --now we will get a polynomial other than 1
     b=gcd(h,f)

      2
o7 = x  - 23x - 2

o7 : R

i8 : --note that the gcd(h,f) will define the same ideal as f and h
     ideal(f,h)==ideal(b)

o8 = true

i9 : --We can also define Quotient rings in one line
     S=QQ[z,y]/(z^2-y^2,z-1)

o9 = S

o9 : QuotientRing

i10 : S=QQ[x]/(x^4-23*x^3-34)

o10 = S

o10 : QuotientRing

i11 : describe S

           QQ[x]
o11 = --------------
       4      3
      x  - 23x  - 34

i12 : 
