Macaulay2 » Documentation
Packages » Macaulay2Doc » rings » substitution and maps between rings » working with multiple rings » use(Ring)
next | previous | forward | backward | up | index | toc

# use(Ring) -- install ring variables and ring operations

- Function: use
- Usage:
    `use R`
- Inputs:
  - R, a ring or a monoid
- Consequences:
  - All variables of R are set to global variables. Additionally, certain operations creating elements of R are installed globally.

## Description

When a ring (or a monoid) is assigned to a global variable, this function is automatically called for it.

It is possible to have several polynomial rings defined, perhaps with a variable belonging to several rings.

    i1 : R = QQ[a..d]

    o1 = R

    o1 : PolynomialRing

    i2 : S = QQ[b,c,d,e]

    o2 = S

    o2 : PolynomialRing

    i3 : b

    o3 = b

    o3 : S

At this point, b is thought to be a variable of S. If one typed a+b, an error would occur, since Macaulay2 doesn't know how to add elements of R and S together. This is fixed via:

    i4 : use R

    o4 = R

    o4 : PolynomialRing

    i5 : b

    o5 = b

    o5 : R

    i6 : a+b

    o6 = a + b

    o6 : R

There are several functions that create rings for you. Generally, their variables are not globally visible. However, once you 'use' the ring, the variables are available.For example, the numerator of the Hilbert function is a polynomial in a ring with a variable T.

    i7 : T

    o7 = T

    o7 : Symbol

    i8 : hf = poincare ideal vars S

                    2     3    4
    o8 = 1 - 4T + 6T  - 4T  + T

    o8 : ZZ[T]

    i9 : T

    o9 = T

    o9 : Symbol

    i10 : use ring hf

    o10 = ZZ[T]

    o10 : PolynomialRing

    i11 : T

    o11 = T

    o11 : Symbol

## Caveat

Any values stored in the variables that have been assigned to are lost, hence this operation should not be used by code in a package.

## See also

- GlobalAssignHook -- hook for assignment to global variables

## Ways to use this method:

- `use(Monoid)`
- use(Ring) -- install ring variables and ring operations

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/functions/use-doc.m2:79:0.