Section 2.1 How to input a matrix into SageMath
After finishing this section, you will learn the following.
- How to input a regular matrix
- How to input a matrix involving variables
Subsection 2.1.1 How to input a regular matrix
Example: Input the matrix below to the SageMath cell.
\begin{equation*}
\begin{pmatrix}
0 \amp 2 \amp -8 \amp 8 \\
1 \amp -2 \amp 1 \amp 0 \\
5 \amp 0 \amp -5 \amp 10
\end{pmatrix}
\end{equation*}
Exercise: Input the matrix below to the SageMath cell.
\begin{equation*}
\begin{pmatrix}
0 \amp 3 \amp -6 \amp 6 \amp 4 \amp -5 \\
3 \amp -7 \amp 8 \amp -5 \amp 8 \amp 9 \\
3 \amp -9 \amp 12 \amp -9 \amp 6 \amp 15
\end{pmatrix}
\end{equation*}
Subsection 2.1.2 How to input an irregular matrix
In SageMath, the variable \(x\) is automatically variable. All the others must be declared.
Example: Input the matrix below to the SageMath cell.
\begin{equation*}
\begin{pmatrix}
a \amp 1\\
3 \amp x
\end{pmatrix}
\end{equation*}
This example is extremely important in this course.