# Class Group and Unit Group

The `ClassGroup` routine and related functions are described in Section [Ideal Class Groups](../NumberFieldsAndOrders/ideal-class-group.md#rngord-clg). The routines for computing units in maximal orders of number fields are described in Section [Unit Groups](../NumberFieldsAndOrders/unit-group.md#rngord-unit).

## `Example: Class Group Unit Group (ex-c8082f)`

In our field defined by $x^4 - 420*x^2 + 40000$, we obtain the class and unit groups as follows.

```magma
> R<x> := PolynomialRing(Integers());
> f := x^4 - 420*x^2 + 40000;
> K<y> := NumberField(f);
> C := ClassGroup(K);
> C;
Abelian Group of order 1
> U := UnitGroup(K);
> U;
Abelian Group isomorphic to Z/2 + Z + Z + Z
Defined on 4 generators
Relations:
      2*U.1 = 0
> T := TorsionUnitGroup(K);
> T;
Abelian Group isomorphic to Z/2
Defined on 1 generator
Relations:
    2*T.1 = 0

```
