# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# `linalg`::`smithForm`

Smith normal form of a matrix

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```linalg::smithForm(`A`, <var>, <All>)
```

## Description

`linalg::smithForm(A)` computes the Smith normal form of the n-dimensional square matrix A, that is an n×n diagonal matrix S, such that Si - 1, i - 1 divides Si, i for i = 2, …, n.

The Smith normal form of a matrix `A` is unique.

The component ring of `A` must be a Euclidean ring, that is, a domain of category `Cat::EuclideanDomain`.

`linalg::smithForm(A, var)` returns the Smith normal form of `A`, assuming that the elements of `A` are univariate polynomials in the variable `var`. If `A` does not contain `var`, then `smithForm(A)` and `smithForm(A,var)` return different results.

`linalg::smithForm(A, <var>, All)` returns the list `[S, U, V]`, where `S` is the Smith normal form of `A`, and `U` and `V` are unimodular transformation matrices, such that `S = U*A*V`. You can use the `All` option with or without specifying the variable `var`.

## Examples

### Example 1

Create the following matrix of integers.

`A := matrix([[9, -36, 30], [-36, 192, -180], [30, -180, 180]])`

Find the Smith normal form of this matrix.

`linalg::smithForm(A)`

Use the `All` option to find the corresponding transformation matrices.

`[S, U, V] := linalg::smithForm(A, All)`

Verify that `S = U*A*V`.

`S = U*A*V`

### Example 2

Create the following matrix of polynomials.

```B := matrix([[-(x - 3)^2*(x - 2),(x - 3)*(x - 2)*(x - 4)], [(x - 3)*(x - 2)*(x - 4),-(x - 3)^2*(x - 4)] ])```

Find the Smith normal form of this matrix.

`linalg::smithForm(B)`

Use the `All` option to find the corresponding transformation matrices.

`[U, S, V] := linalg::smithForm(B, All)`

### Example 3

If a matrix does not contain a particular variable, and you call `linalg::smithForm` specifying that variable as the second argument, then the result differs from what you get without specifying that variable. For example, create a matrix that does not contain any variables.

`A := matrix([[9, -36, 30], [-36, 192, -180], [30, -180, 180]])`

Call `linalg::smithForm` specifying variable `x` as the second argument. In this case, `linalg::smithForm` assumes that the elements of `A` are univariate polynomials in `x`.

`linalg::hermiteForm(A, x)`

Call `linalg::smithForm` without specifying variables. In this case, `linalg::smithForm` treats `A` as a matrix of integers.

`linalg::hermiteForm(A)`

## Parameters

 `A` A square matrix of a domain of category `Cat::Matrix`

## Options

 `All` Returns the list `[S, U, V]`, where `S` is the Smith normal form of `A`, and `U` and `V` are unimodular transformation matrices, such that `S = U*A*V`.

## Return Values

Matrix of the same domain type as `A`. With the option `All`, `linalg::smithForm` returns the list `[S, U, V]`, where `S` is a matrix of the same domain type as `A`, and `U` and `V` are corresponding transformation matrices.

## Algorithms

An n×n matrix S = (sij) with coefficients in a Euclidean ring is the Smith normal form of a matrix if S is a diagonal matrix (with nonnegative coefficients in case of the ring ), such that si, i divides si + 1, i + 1 for all i < n.