Matrices in Sage

## Description

The basic Sage command to enter the matrix

(1)
\begin{align} A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix} \end{align}

is A = matrix([[1, 2, 3], [4, 5, 6]]).

## Sage Cell

The matrix $A$ is a $2 \times 3$ matrix with entries in the integers.

The matrix $A$ below has entires in the rationals, QQ. We may replace QQ with RR (the floating point real numbers) or CC (the floating point complex numbers).

The number of rows (2) and columns (3) can be entered.

You can specify how many rows the matrix will have and provide one big grand list of entries, which will get chopped up, row by row, if you prefer.

The commands A.nrows() and A.ncols() will return the number of rows and columns of the matrix $A$, respectively.

The command A.base_ring() will return the ring or field for the entries in the matrix $A$.

Rows in the matrix $A$ and numbered 0 to 1, while columns are numbered 0 to 2. The command A[i,j] returns the entry in the $i$th row and $j$th column of the matrix $A$ or 6.

## Options

A = matrix([[1, 2, 3], [4, 5, 6]])
A

A = matrix([[1, 2, 3], [4, 5, 6]])
A.parent()

A = matrix(QQ, [[1, 2, 3], [4, 5, 6]])
A.parent()

A = matrix(QQ, 2, 3, [[1, 2, 3], [4, 5, 6]])
A

A = matrix(QQ, 2, [1, 2, 3, 4, 5, 6])
A

A = matrix(QQ, 2, 3, [[1,2,3],[4,5,6]])
A.nrows(), A.ncols()

A = matrix(RR, [[1, 2, 3], [4, 5, 6]])
A.base_ring()

A = matrix([[1, 2, 3], [4, 5, 6]])
A[1,2]


## Tags

CC: math.la.i.mat

Primary Tags: linear algebra

Secondary Tags: matrices

None

## Attribute

Author: R. Beezer

Date: 24 Jul 2017 13:53

Submitted by: Tom Judson