# Completions

Local rings can be obtained by completing an order at a prime ideal (see Chapter [Number Fields](../../GlobalFields/NumberFields/index-number-fields.md#fldnum-main) and [`Completion`](../../GlobalFields/NumberFieldsAndOrders/operation.md#function-rngord-completion1)).

## `Completion(O, P): RngOrd, RngOrdIdl -> RngPad, Map`

## `Completion(K, P): FldNum, RngOrdIdl -> FldPad, Map`

```magma
Precision: RngIntElt                    Default: 20
```

The completion (as an unbounded precision local ring or field with default precision given by `Precision`) of the order or number field at the prime ideal $P$, and the embedding of the order or number field into the resulting local ring.

## `LocalRing(P, k): RngOrdIdl, RngIntElt -> RngPad, Map`

The completion (as a local ring) of the order of the prime ideal $P$ at $P$ with default precision $k$ and the embedding of the order into the resulting local ring.

## `Example: completion (ex-2bb9ae)`

Here we demonstrate the use of `Completion`.

```magma
> K := NumberField(x^6 - 5*x^5 + 31*x^4 - 85*x^3 + 207*x^2 - 155*x + 123);
> lp := Decomposition(K, 7);
> C, mC := Completion(K, lp[2][1]);
> C;
Totally ramified extension defined by a map over Unramified extension defined by
a map over 7-adic field
> mC;
Mapping from: FldNum: K to FldPad: C given by a rule
> mC(K.1);
(46564489*$.1 - 47959419)*C.1 - 116434149*$.1 - 61099304 + O(C.1^20)
> delta := (K.1 @ mC @@ mC) - K.1;
> delta;
8337821493402521350488*K.1^5 - 69073506960056896464432*K.1^4 +
    189847416443444330877726*K.1^3 - 453361530291976951337876*K.1^2 +
    336979647814116799276099*K.1 - 267520869714197002579071
> // Check the accuracy of the mappings using the valuation of the difference
> Valuation(delta, lp[2][1]);
18
> C`DefaultPrecision := 30;
> mC(K.1);
(1090965976127*$.1 - 1208477074641)*C.1 - 589359803563*$.1 + 288063654676 +
O(C.1^30)
> delta := (K.1 @ mC @@ mC) - K.1;
> delta;
-61980024244160371672868773433490783*K.1^5 +
    1189796803064803092593291088768968754*K.1^4 -
    3202353946933190588864309180653868957*K.1^3 +
    7537386928046164580731145031872017049*K.1^2 -
    5511297002936682579964210586013308810*K.1 +
    4438099444806431313582533435941098722
> Valuation(delta, lp[2][1]);
28
> C`DefaultPrecision := 10;
> mC(K.1);
(-7708*$.1 + 7759)*C.1 + 4747*$.1 - 5859 + O(C.1^10)
> delta := (K.1 @ mC @@ mC) - K.1;
> delta;
1908210240*K.1^5 - 7326424608*K.1^4 + 16701662320*K.1^3 - 35965440540*K.1^2 +
    41324075079*K.1 - 30476856505
> Valuation(delta, lp[2][1]);
8

```
