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

Code

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

Options

Option

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

Code

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

Option

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).

Code

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

Option

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

Code

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

Option

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.

Code

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

Option

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

Code

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

Option

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

Code

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

Option

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.

Code

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

Tags

CC: math.la.i.mat

Primary Tags: Linear algebra: Matrices.

Secondary Tags: Matrices: Matrix basics.

Related Cells

None

Attribute

Permalink: http://linear.ups.edu/html/section-RREF.html

Author: R. Beezer

Date: 24 Jul 2017 13:53

Submitted by: Tom Judson

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License