---
title: "Inner Products"
canonical: "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/PolarSpaces/innerprod.html"
source: "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/PolarSpaces/innerprod.md"
part: "Matrices and Linear Algebra"
chapter: "Polar Spaces"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Matrices and Linear Algebra", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/index-matrices-linear-algebra.md"}
  - {"title": "Polar Spaces", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/PolarSpaces/index-polar-spaces.md"}
prev: {"title": "Reflexive Forms", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/PolarSpaces/reflexive-forms.md"}
next: {"title": "Isotropic and Singular Vectors and Subspaces", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/PolarSpaces/structure.md"}
intrinsics:
  - {"name": "EnsureUpperTriangular", "signature": "EnsureUpperTriangular(A): AlgMatElt -> AlgMatElt"}
  - {"name": "DotProduct", "signature": "DotProduct(u, v): ModTupFldElt, ModTupFldElt -> FldElt"}
  - {"name": "DotProductMatrix", "signature": "DotProductMatrix(S): SeqEnum[ModTupFldElt] -> AlgMatElt"}
  - {"name": "GramMatrix", "signature": "GramMatrix(V): ModTupRng -> AlgMatElt"}
  - {"name": "InnerProductMatrix", "signature": "InnerProductMatrix(V): ModTupRng -> AlgMatElt"}
  - {"name": "OrthogonalComplement", "signature": "OrthogonalComplement(V, X : parameters): ModTupFld, ModTupFld -> ModTupFld"}
  - {"name": "Radical", "signature": "Radical(V : parameters): ModTupFld -> ModTupFld"}
  - {"name": "IsNondegenerate", "signature": "IsNondegenerate(V): ModTupFld -> BoolElt"}
  - {"name": "IsDegenerate", "signature": "IsDegenerate(V): ModTupFld -> BoolElt"}
  - {"name": "SingularRadical", "signature": "SingularRadical(V): ModTupFld -> ModTupFld"}
  - {"name": "IsNonsingular", "signature": "IsNonsingular(V): ModTupFld -> BoolElt"}
examples:
  - "ex-2f3d6e"
  - "ex-9d71da"
  - "ex-af15e4"
---

<a id="innerprod"></a>
<a id="sectinnerprod"></a>
# Inner Products

Every vector space $V$ in Magma created via the `VectorSpace` intrinsic (or its synonym `KSpace`) has an associated bilinear form which is represented by a matrix and which can be accessed via `InnerProductMatrix(V)` or via the attribute `ip_form`. By default the inner product matrix is the identity. If the dimension of $V$ is $n$, then any $n\times n$ matrix defined over the base field of $V$ can serve as the inner product matrix by passing it to `VectorSpace` as an additional parameter.

If $e_1$, $e_2$, …, $e_n$ is a basis for $V$, the matrix of the form $\beta$ with respect to this basis is $J := \big(\beta(e_i,e_j)\big)$.

<a id="example-ex-2f3d6e"></a>
## `Example: Vector Space with a General Form (ex-2f3d6e)`

```magma
> K := GF(11);
> J := Matrix(K,3,3,[1,2,3, 4,5,6, 7,8,9]);
> V := VectorSpace(K,3,J);
> InnerProductMatrix(V);
[ 1  2  3]
[ 4  5  6]
[ 7  8  9]
```

A vector space $V$ may also have an associated quadratic form. This can be assigned by attaching a matrix to $V$ via the function `QuadraticSpace` described in Section [Quadratic Spaces](https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/PolarSpaces/constructions.md#subsectquadsp). If assigned, the matrix can be accessed as the return value of `QuadraticFormMatrix`.

The quadratic form defined by the matrix $A$ is $q(v) = vAv^\mathrm{tr}$, and the matrix of its polar form is $A + A^\mathrm{tr}$. It is always possible to represent a quadratic form by an upper triangular matrix. Furthermore, if the characteristic of the field is not two, the quadratic form may be represented by the symmetric matrix ${1\over 2}J$, where $J$ is the matrix of its polar form.

In order to accommodate hermitian forms, a vector space of type `ModTupFld` has an attribute `Involution`. This attribute is intended to hold an automorphism (of order two) of the base field.

<a id="function-ensureuppertriangular-algmatelt"></a>
## `EnsureUpperTriangular(A): AlgMatElt -> AlgMatElt`

Given an $n\times n$ matrix $A$ this function returns the upper triangular matrix $Q$ which represents the same quadratic form as $A$. That is, for all $n$-tuples $v$ we have $vAv^\mathrm{tr}= vQv^\mathrm{tr}$.

<a id="function-dotproduct-modtupfldelt-modtupfldelt"></a>
## `DotProduct(u, v): ModTupFldElt, ModTupFldElt -> FldElt`

If $V$ is the generic space of the parent of $u$ and $v$, let $\sigma$ be the field automorphism ``V`Involution`` if this attribute is assigned or the identity automorphism if ``V`Involution`` is not assigned. If $J$ is the inner product matrix of $V$, the expression `DotProduct(u,v)` evaluates to $uJ\sigma(v^\mathrm{tr})$. That is, it returns $\beta(u,v)$, where $\beta$ is a bilinear or sesquilinear form on $V$.

<a id="function-dotproductmatrix-seqenum-modtupfldelt"></a>
## `DotProductMatrix(S): SeqEnum[ModTupFldElt] -> AlgMatElt`

The matrix of inner products of the vectors in the sequence $S$. The inner products are calculated using `DotProduct` and therefore take into account any field automorphism attached to the `Involution` attribute of the generic space of the universe of $S$.

<a id="function-grammatrix-modtuprng"></a>
## `GramMatrix(V): ModTupRng -> AlgMatElt`

If $B$ is the basis matrix of $V$ and if $J$ is the inner product matrix, this function returns $BJB^{\hbox{tr}}$. In this case the `Involution` attribute is ignored.

<a id="function-innerproductmatrix-modtuprng"></a>
## `InnerProductMatrix(V): ModTupRng -> AlgMatElt`

The inner product matrix attached to the generic space of $V$. This is the attribute ``V`ip_form``.

<a id="example-ex-9d71da"></a>
## `Example: Gram Matrix Versus Inner Product Matrix (ex-9d71da)`

This example illustrates the difference between `GramMatrix` and `InnerProductMatrix`. The function `GramMatrix` uses the echelonised basis of the subspace $W$. To obtain the matrix of inner products between a given list of vectors, use `DotProductMatrix`.

```magma
> K<a> := QuadraticField(-2);
> J := Matrix(K,3,3,[1,2,1, 2,1,0, 1,0,2]);
> V := VectorSpace(K,3,J);
> W := sub<V| [a,a,a], [1,2,3]>;
> InnerProductMatrix(W);
[1 2 1]
[2 1 0]
[1 0 2]
> GramMatrix(W);
[1 0]
[0 9]
> DotProductMatrix([W.1,W.2]);
[ -20 19*a]
[19*a   37]
```

<a id="example-ex-af15e4"></a>
## `Example: Symmetric and Hermitian Products (ex-af15e4)`

Continuing the previous example, the vector space $V$ does not have the attribute `Involution` assigned and therefore `DotProduct` uses the *symmetric* bilinear form represented by the inner product matrix $J$. However, the field $K$ has a well-defined operation of complex conjugation and so `InnerProduct` uses the *hermitian* form represented by $J$.

```magma
> u := W.1+W.2;
> DotProduct(u,u);
38*a + 17
> InnerProduct(u,u);
57
```

<a id="orthog"></a>
<a id="subsectorthog"></a>
## Orthogonality

If $\beta$ is any bilinear or sesquilinear form, the vectors $u$ and $v$ are *orthogonal* if $\beta(u,v) = 0$. The *left orthogonal complement* of a subset $X$ of $V$ is the subspace

$$
{}^\perp X := \{\,u \in V \mid \beta(u,x) = 0\text{ for all }x\in X\,\}
$$

and the *right orthogonal complement* of $W$ is

$$
X^\perp := \{\,u \in V \mid \beta(x,u) = 0\text{ for all }x\in X\,\}.
$$

If $\beta$ is reflexive, then ${}^\perp X = X^\perp$.

<a id="function-orthogonalcomplement-modtupfld-modtupfld"></a>
### `OrthogonalComplement(V, X : parameters): ModTupFld, ModTupFld -> ModTupFld`

```magma
Right: BoolElt                    Default: false
```

The default value is the left orthogonal complement of $X$ in $V$. To obtain the right orthogonal complement set `Right` to `true`.

<a id="function-radical-modtupfld"></a>
### `Radical(V : parameters): ModTupFld -> ModTupFld`

```magma
Right: BoolElt                    Default: false
```

The left radical of the inner product space $V$, namely ${}^\perp V$. To obtain the right radical set `Right` to `true`.

A bilinear or sesquilinear form $\beta$ is *non-degenerate* if $\hbox{rad}(V) = 0$, where $V$ is the polar space of $\beta$.

<a id="function-isnondegenerate-modtupfld"></a>
### `IsNondegenerate(V): ModTupFld -> BoolElt`

Returns `true` if the determinant of the matrix of inner products of the basis vectors of $V$ is non-zero, otherwise `false`. This function takes into account the field automorphism, if any, attached to the `Involution` attribute of the generic space of $V$.

<a id="function-isdegenerate-modtupfld"></a>
### `IsDegenerate(V): ModTupFld -> BoolElt`

The opposite of the above.

If $V$ is a quadratic space over a perfect field of characteristic 2, the restriction of the quadratic form $Q$ to the radical is a semilinear functional (with respect to $x \mapsto x^2$) whose kernel is the *singular radical* of $V$. A quadratic space is *non-singular* if its singular radical is zero.

<a id="function-singularradical-modtupfld"></a>
### `SingularRadical(V): ModTupFld -> ModTupFld`

The kernel of the restriction of the quadratic form of the quadratic space $V$ to the radical of $V$.

<a id="function-isnonsingular-modtupfld"></a>
### `IsNonsingular(V): ModTupFld -> BoolElt`

Returns `true` if $V$ is a non-singular quadratic space, otherwise `false`.
