# Structure Operations

## Related Structures

The main structure related to a free algebra is its coefficient ring. Multivariate free algebras belong to the Magma category `AlgFr`.

### `BaseRing(F): AlgFr -> Rng`

### `CoefficientRing(F): AlgFr -> Rng`

Return the coefficient ring of the free algebra $F$.

### `Category(F): AlgFr -> Cat`

### `Parent(F): AlgFr -> Pow`

### `PrimeRing(F): AlgFr -> Rng`

## Numerical Invariants

Note that the `#` operator only returns a value for finite (quotients of) free algebras.

### `Rank(F): AlgFr -> RngIntElt`

Return the number of indeterminates of free algebra $F$ over its coefficient ring.

### `Characteristic(F): AlgFr -> RngIntElt`

### `# F: AlgFr -> RngIntElt`

## Homomorphisms

In its most general form, a homomorphism taking a free algebra $K\langle x_1, \ldots, x_n\rangle$ as domain requires $n+1$ pieces of information, namely, a map (homomorphism) telling how to map the coefficient ring $K$ together with the images of the $n$ indeterminates. The map for the coefficient ring is optional.

### `hom< F -> S | f, y₁, ..., yₙ >: AlgFr, Rng -> Map`

### `hom< F -> S | y₁, ..., yₙ >: AlgFr, Rng -> Map`

Given a free algebra $F=K\langle x_1, \ldots, x_n\rangle$, a ring or associative algebra $S$ (including another FP-algebra or a matrix algebra), and a map $f : K\rightarrow S$ and $n$ elements $y_1, \ldots, y_n\in S$, create the homomorphism $g : F\rightarrow S$ by applying the rules that $g(rx_1^{a_1}\cdots x_n^{a_n})=f(r)y_1^{a_1}\cdots y_n^{a_n}$ for monomials and linearity, that is, $g(M+N)=g(M)+g(N)$. The coefficient ring map may be omitted, in which case the coefficients are mapped into $S$ by the coercion map. No attempt is made to check whether the map defines a genuine homomorphism.

### `Example: Homomorphism (ex-15e82d)`

In this example we map an algebra $F$ first into $F$ itself, and then into a matrix algebra.

```magma
> K := RationalField();
> F<x,y,z> := FreeAlgebra(K, 3);
> h := hom<F -> F | x*y, y*x, z*x>;
> h(x);
x*y
> h(y);
y*x
> h(x*y);
x*y^2*x
> h(x + y + z);
x*y + y*x + z*x
> A := MatrixAlgebra(K, 2);
> M := [A | [1,1,-1,1], [-1,3,4,1], [11,7,-7,8]];
> M;
[
    [ 1  1]
    [-1  1],

    [-1  3]
    [ 4  1],

    [11  7]
    [-7  8]
]
> h := hom<F -> A | M>;
> h(x);
[ 1  1]
[-1  1]
> h(y);
[-1  3]
[ 4  1]
> h(x*y - y*z);
[ 35 -13]
[-32 -38]

```
